Skip to content

Commit

Permalink
LIT config and zlib cleanup (#3)
Browse files Browse the repository at this point in the history
- point to stock llvm zlib, remove zlib.BUILD
- rename workspace to `mlir_tcp_ws`
- cleanup lit config files to remove unused local.lit.cfg files
  • Loading branch information
sjain-stanford authored Oct 10, 2023
1 parent 9146c00 commit b8052b8
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 139 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
workspace(name = "tensor_compute_primitives_ws")
workspace(name = "mlir_tcp_ws")

load("//:deps.bzl", "third_party_deps")

Expand Down
8 changes: 4 additions & 4 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def third_party_deps():

http_archive(
name = "llvm_zlib",
build_file = "//:zlib.BUILD",
sha256 = "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30",
strip_prefix = "zlib-1.2.13",
build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD",
sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731",
strip_prefix = "zlib-ng-2.0.7",
urls = [
"https://zlib.net/fossils/zlib-1.2.13.tar.gz",
"https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip",
],
)
2 changes: 0 additions & 2 deletions lib/TorchConversion/Transforms/VerifyTcpBackendContract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Also available under a BSD-style license. See LICENSE.
//
//===----------------------------------------------------------------------===//
#ifdef TORCH_MLIR_ENABLE_TCP
#include "PassDetail.h"

#include "IR/TcpDialect.h"
Expand Down Expand Up @@ -65,4 +64,3 @@ std::unique_ptr<OperationPass<ModuleOp>>
mlir::torch::TorchConversion::createVerifyTcpBackendContractPass() {
return std::make_unique<VerifyTcpBackendContractPass>();
}
#endif // TORCH_MLIR_ENABLE_TCP
9 changes: 3 additions & 6 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@llvm-project//llvm:lit_test.bzl", "lit_test", "package_path")
load("@llvm-project//llvm:lit_test.bzl", "lit_test")

expand_template(
name = "lit_site_cfg_py",
testonly = True,
out = "lit.site.cfg.py",
substitutions = {
"@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
"\"@TCP_SOURCE_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'tensor_compute_primitives_ws')",
"\"@TCP_BINARY_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'tensor_compute_primitives_ws')",
"\"@TCP_SOURCE_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'mlir_tcp_ws')",
"\"@TCP_BINARY_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'mlir_tcp_ws')",
"\"@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",
},
template = "lit.site.cfg.py.in",
)
Expand Down
2 changes: 0 additions & 2 deletions test/Conversion/StablehloToTcp/lit.local.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions test/Conversion/TcpToArith/lit.local.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions test/Conversion/TcpToLinalg/lit.local.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions test/Conversion/TorchToTcp/lit.local.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions test/Dialect/Tcp/lit.local.cfg

This file was deleted.

75 changes: 13 additions & 62 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,77 +4,28 @@
# Also available under a BSD-style license. See LICENSE.

import os
import platform
import re
import subprocess
import tempfile

import lit.formats
import lit.util

from lit.llvm import llvm_config
from lit.llvm.subst import ToolSubst
from lit.llvm.subst import FindTool

# Configuration file for the 'lit' test runner.

# name: The name of this test suite.
config.name = 'TENSOR_COMPUTE_PRIMITIVES'

# Populate Lit configuration with the minimal required metadata.
# Some metadata is populated in lit.site.cfg.py.in.
config.name = 'MLIR_TCP_TESTS_SUITE'
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)

# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.mlir', '.py']

# test_source_root: The root path where tests are located.
config.suffixes = ['.mlir']
config.test_source_root = os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.tcp_obj_root, 'test')

config.substitutions.append(('%PATH%', config.environment['PATH']))
config.substitutions.append(('%shlibext', config.llvm_shlib_ext))

llvm_config.with_system_environment(['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])

#llvm_config.use_default_substitutions()

# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = [
'Inputs', 'Examples', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt',
'lit.cfg.py', 'lit.site.cfg.py'
# Make LLVM and TCP tools available in RUN directives
tools = [
'tcp-opt',
'FileCheck',
'count',
'not',
]

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.tcp_obj_root, 'test')
config.standalone_tools_dir = os.path.join(config.tcp_obj_root, 'bin')

# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
# Tweak the PATH to include the binary build dir, in order to pick up CAPI tests during out-of-tree.
llvm_config.with_environment('PATH', os.path.join(config.llvm_build_dir, 'bin'), append_path=True)

# On Windows the path to python could contains spaces in which case it needs to
# be provided in quotes. This is the equivalent of how %python is setup in
# llvm/utils/lit/lit/llvm/config.py.
# if "Windows" in config.host_os:
# config.python_executable = '"%s"' % (config.python_executable)

tool_dirs = [config.standalone_tools_dir, config.llvm_tools_dir, config.tcp_obj_root]
tools = [
'tcp-opt',
ToolSubst('%PYTHON', config.python_executable, unresolved='ignore'),
tool_dirs = [
config.llvm_tools_dir,
config.tcp_tools_dir,
]

llvm_config.add_tool_substitutions(tools, tool_dirs)

# if config.enable_bindings_python:
# llvm_config.with_environment('PYTHONPATH', [
# os.path.join(config.torch_mlir_python_packages_dir, 'torch_mlir'),
# ],
# append_path=True)
21 changes: 7 additions & 14 deletions test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
@LIT_SITE_CFG_IN_HEADER@
# -*- Python -*-
# Part of the LLVM Project, 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
# Also available under a BSD-style license. See LICENSE.

import sys
@LIT_SITE_CFG_IN_HEADER@
config.enable_bindings_python = @MLIR_ENABLE_BINDINGS_PYTHON@
config.tcp_obj_root = "@TCP_BINARY_DIR@"
config.host_os = "@HOST_OS@"
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.tcp_tools_dir = "@TCP_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_build_dir = "@CMAKE_BINARY_DIR@"
config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
config.llvm_shlib_dir = "@SHLIBDIR@"
config.llvm_shlib_ext = "@SHLIBEXT@"
config.llvm_exe_ext = "@EXEEXT@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.python_executable = "@Python3_EXECUTABLE@"

import lit.llvm
lit.llvm.initialize(lit_config, config)
Expand Down
40 changes: 0 additions & 40 deletions zlib.BUILD

This file was deleted.

0 comments on commit b8052b8

Please sign in to comment.