mirror of https://github.com/llvm/torch-mlir
Enable torch-mlir LIT tests in Bazel (#1585)
Adds support to run `.mlir` LIT tests in bazel. ``` bazel test @torch-mlir//test/... ``` Follow-on PR will contain these updates: - Add tests to GHA CI workflow - Add `.py` LIT tests to bazelpull/1593/head
parent
4032eeca64
commit
fc4c8d4ed9
|
@ -63,7 +63,7 @@ llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
|
|||
if "Windows" in config.host_os:
|
||||
config.python_executable = '"%s"' % (config.python_executable)
|
||||
|
||||
tool_dirs = [config.standalone_tools_dir, config.llvm_tools_dir]
|
||||
tool_dirs = [config.standalone_tools_dir, config.llvm_tools_dir, config.torch_mlir_obj_root]
|
||||
tools = [
|
||||
'torch-mlir-opt',
|
||||
ToolSubst('%PYTHON', config.python_executable, unresolved='ignore'),
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
|
||||
load("@llvm-project//llvm:lit_test.bzl", "lit_test", "package_path")
|
||||
|
||||
package(
|
||||
default_visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "lit_site_cfg_py",
|
||||
testonly = True,
|
||||
out = "lit.site.cfg.py",
|
||||
substitutions = {
|
||||
"@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
|
||||
"@TORCH_MLIR_SOURCE_DIR@": package_path("@torch-mlir//:BUILD"),
|
||||
"\"@TORCH_MLIR_BINARY_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'torch-mlir')",
|
||||
"\"@LLVM_TOOLS_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'llvm-project', 'llvm')",
|
||||
# All disabled, but required to substituted because they are not in quotes.
|
||||
"@MLIR_ENABLE_BINDINGS_PYTHON@": "0",
|
||||
"@TORCH_MLIR_ENABLE_JIT_IR_IMPORTER@": "0",
|
||||
"@TORCH_MLIR_ENABLE_MHLO@": "0",
|
||||
},
|
||||
template = "lit.site.cfg.py.in",
|
||||
)
|
||||
|
||||
# Common data used by most lit tests.
|
||||
filegroup(
|
||||
name = "lit_data",
|
||||
testonly = True,
|
||||
data = [
|
||||
"lit.cfg.py",
|
||||
"lit.site.cfg.py",
|
||||
"@llvm-project//llvm:FileCheck",
|
||||
"@llvm-project//llvm:count",
|
||||
"@llvm-project//llvm:not",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,15 @@
|
|||
load("@llvm-project//llvm:lit_test.bzl", "lit_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
[
|
||||
lit_test(
|
||||
name = "%s.test" % src,
|
||||
srcs = [src],
|
||||
data = [
|
||||
"@torch-mlir//:torch-mlir-opt",
|
||||
"@torch-mlir//test:lit_data",
|
||||
],
|
||||
)
|
||||
for src in glob(["**/*.mlir"])
|
||||
]
|
|
@ -0,0 +1,15 @@
|
|||
load("@llvm-project//llvm:lit_test.bzl", "lit_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
[
|
||||
lit_test(
|
||||
name = "%s.test" % src,
|
||||
srcs = [src],
|
||||
data = [
|
||||
"@torch-mlir//:torch-mlir-opt",
|
||||
"@torch-mlir//test:lit_data",
|
||||
],
|
||||
)
|
||||
for src in glob(["**/*.mlir"])
|
||||
]
|
|
@ -0,0 +1,15 @@
|
|||
load("@llvm-project//llvm:lit_test.bzl", "lit_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
[
|
||||
lit_test(
|
||||
name = "%s.test" % src,
|
||||
srcs = [src],
|
||||
data = [
|
||||
"@torch-mlir//:torch-mlir-opt",
|
||||
"@torch-mlir//test:lit_data",
|
||||
],
|
||||
)
|
||||
for src in glob(["**/*.mlir"])
|
||||
]
|
Loading…
Reference in New Issue