Commit d8fbe52b authored by Diego Caballero's avatar Diego Caballero Committed by omarkanawi

[MLIR] Add config files for LIT testing (#3523)

* [MLIR] Add config files for LIT

LIT is the LLVM testing tool that is used in LLVM and MLIR. It's
necessary to enable all the MLIR testing in nGraph. This will provide
a complementary finer grain level of testing than the one currently done
with gtest. LIT will allow testing each MLIR-based nGraph transformation
without having to run the whole nGraph pipeline. For example, we will be
able to write an nGraph dialect input, invoke an single MLIR transformation
on it and check that the output is the expected.

This PR adds the basic configuration files to enable LIT tool
in nGraph for MLIR Compiler. `affine_lowering/lit_test.mlir` is a
dummy test to exercise the new testing feature. Lit testing will be
enabled in CMAKE in a subsequent PR.

* Address feedback
parent 9b9b184a
......@@ -22,10 +22,15 @@ set(MLIR_REPO_URL https://github.com/tensorflow/mlir.git)
# Change these commit IDs to move to latest stable versions
set(MLIR_LLVM_COMMIT_ID 3b9a27b)
set(MLIR_COMMIT_ID 0cdb20a)
# MLIR environment variables. Some of them are used by LIT tool.
set(MLIR_PROJECT_ROOT ${CMAKE_CURRENT_BINARY_DIR}/mlir_project)
set(MLIR_LLVM_ROOT ${MLIR_PROJECT_ROOT}/llvm-projects)
set(MLIR_SOURCE_DIR ${MLIR_LLVM_ROOT}/llvm/projects/mlir)
set(MLIR_BUILD_DIR ${MLIR_LLVM_ROOT}/build)
set(MLIR_TOOLS_DIR ${MLIR_BUILD_DIR}/bin)
set(NGRAPH_LIT_TEST_SRC_DIR ${CMAKE_SOURCE_DIR}/test/mlir)
set(NGRAPH_LIT_TEST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/test/mlir)
# MLIR has to be pre-built before ngraph build starts
# this will clone and build MLIR during cmake config instead
......
// RUN: mlir-opt %s | FileCheck %s
// CHECK-LABEL: func @test()
func @test() {
llvm.return
}
#*****************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#*****************************************************************************
import lit.formats
from lit.llvm import llvm_config
from lit.llvm.subst import ToolSubst
# name: The name of this test suite.
config.name = 'NGRAPH MLIR Compiler'
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
# test_source_root: The root path where tests are located.
config.test_source_root = config.ngraph_mlir_test_dir
# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.ngraph_mlir_test_dir
llvm_config.use_default_substitutions()
# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
tool_dirs = [
config.mlir_tools_dir, config.llvm_tools_dir
]
tool_names = [
'mlir-opt', 'mlir-translate'
]
tools = [ToolSubst(s, unresolved='ignore') for s in tool_names]
llvm_config.add_tool_substitutions(tools, tool_dirs)
#*****************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#*****************************************************************************
import lit.llvm
config.llvm_tools_dir = "@MLIR_TOOLS_DIR@"
config.mlir_obj_root = "@MLIR_BUILD_DIR@"
config.mlir_tools_dir = "@MLIR_TOOLS_DIR@"
config.suffixes = ['.mlir']
config.ngraph_mlir_test_dir = "@NGRAPH_LIT_TEST_SRC_DIR@"
lit.llvm.initialize(lit_config, config)
# Let the main config do the real work.
lit_config.load_config(config, "@NGRAPH_LIT_TEST_SRC_DIR@/lit.cfg.py")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment