mirror of https://github.com/llvm/torch-mlir
Move torch-mlir-dialects into the main source tree.
parent
5322c925e5
commit
af20d259b9
|
@ -1,64 +0,0 @@
|
|||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
# The cmake configuration to build torch-mlir-dialects as
|
||||
# an out-of-tree project has not been implemented. It can
|
||||
# be built as part of LLVM or as a subdirectory of torch-mlir.
|
||||
message(FATAL_ERROR
|
||||
"This project is intended to be built as part of LLVM via "
|
||||
"-DLLVM_EXTERNAL_PROJECTS=torch-mlir-dialects "
|
||||
"-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
option(MLIR_ENABLE_BINDINGS_PYTHON "Enables MLIR Python Bindings" OFF)
|
||||
|
||||
set(TORCH_MLIR_DIALECTS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(TORCH_MLIR_DIALECTS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
message(STATUS "Building torch-mlir-dialects project at ${TORCH_MLIR_DIALECTS_SOURCE_DIR} (into ${TORCH_MLIR_DIALECTS_BINARY_DIR})")
|
||||
|
||||
if(MLIR_FOUND)
|
||||
message(STATUS "LLVM and MLIR packages have already been configured.")
|
||||
else()
|
||||
message(STATUS "torch-mlir-dialect is being built in-tree")
|
||||
# An in-tree build, LLVM hasn't been installed yet.
|
||||
# We compute these properties manually, they're otherwise
|
||||
# contributed by find_package(MLIR...)
|
||||
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir)
|
||||
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include)
|
||||
set(MLIR_GENERATED_INCLUDE_DIR ${LLVM_BINARY_DIR}/tools/mlir/include)
|
||||
set(MLIR_INCLUDE_DIRS ${MLIR_INCLUDE_DIR} ${MLIR_GENERATED_INCLUDE_DIR})
|
||||
set(LLVM_INCLUDE_DIRS ${LLVM_MAIN_INCLUDE_DIR})
|
||||
|
||||
# Configure CMake and tablegen.
|
||||
list(APPEND CMAKE_MODULE_PATH ${MLIR_MAIN_SRC_DIR}/cmake/modules)
|
||||
list(APPEND CMAKE_MODULE_PATH ${LLVM_MAIN_SRC_DIR}/cmake)
|
||||
|
||||
include(TableGen)
|
||||
include(AddLLVM)
|
||||
include(AddMLIR)
|
||||
endif()
|
||||
|
||||
function(torch_mlir_dialects_target_includes target)
|
||||
set(_dirs
|
||||
$<BUILD_INTERFACE:${MLIR_INCLUDE_DIRS}>
|
||||
$<BUILD_INTERFACE:${TORCH_MLIR_DIALECTS_SOURCE_DIR}/include>
|
||||
$<BUILD_INTERFACE:${TORCH_MLIR_DIALECTS_BINARY_DIR}/include>
|
||||
)
|
||||
# In LLVM parlance, the actual target may just be an interface and may not
|
||||
# be responsible for actually compiling anything. The corresponding obj.
|
||||
# target, when present, is just used for compilation and does not
|
||||
# contribute to the interface properties.
|
||||
# TODO: Normalize this upstream.
|
||||
target_include_directories(${target} PUBLIC "${_dirs}")
|
||||
if(TARGET obj.${target})
|
||||
target_include_directories(obj.${target} PRIVATE "${_dirs}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# TODO: Needed for tablegen. Remove.
|
||||
include_directories(SYSTEM ${MLIR_INCLUDE_DIRS})
|
||||
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
|
||||
include_directories(SYSTEM ${TORCH_MLIR_DIALECTS_SOURCE_DIR}/include)
|
||||
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(tools)
|
||||
add_subdirectory(test)
|
|
@ -1,11 +0,0 @@
|
|||
# Torch-MLIR Dialects Project
|
||||
|
||||
Sources for torch-mlir's public dialects (containing ops/types/attributes that
|
||||
are unique to Torch-MLIR at the moment)
|
||||
|
||||
This project is intended to be used via LLVM's external projects setup:
|
||||
|
||||
* `-DLLVM_EXTERNAL_PROJECTS=torch-mlir-dialects`
|
||||
* `-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR={this_directory}`
|
||||
|
||||
It depends on the `mlir` project.
|
|
@ -1 +0,0 @@
|
|||
add_subdirectory(torch-mlir-dialects)
|
|
@ -1 +0,0 @@
|
|||
add_subdirectory(Dialect)
|
|
@ -1 +0,0 @@
|
|||
add_subdirectory(TMTensor)
|
|
@ -1,21 +0,0 @@
|
|||
# lit needs to find the tools, and the location differs for in-tree and out-of-tree builds.
|
||||
get_target_property(TORCH_MLIR_DIALECTS_TOOLS_DIR torch-mlir-dialects-opt RUNTIME_OUTPUT_DIRECTORY)
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
|
||||
MAIN_CONFIG
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
|
||||
)
|
||||
|
||||
set(TORCH_MLIR_DIALECTS_TEST_DEPENDS
|
||||
FileCheck count not
|
||||
torch-mlir-dialects-opt
|
||||
)
|
||||
|
||||
add_lit_testsuite(check-torch-mlir-dialects "Running the torch-mlir-dialects regression tests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS ${TORCH_MLIR_DIALECTS_TEST_DEPENDS}
|
||||
)
|
||||
set_target_properties(check-torch-mlir-dialects PROPERTIES FOLDER "Tests")
|
||||
|
||||
add_lit_testsuites(TORCH_MLIR_DIALECTS ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${TORCH_MLIR_DIALECTS_TEST_DEPENDS})
|
|
@ -1,69 +0,0 @@
|
|||
# -*- 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 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 = 'TORCH_MLIR_DIALECTS'
|
||||
|
||||
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.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.torch_mlir_dialects_obj_root, 'test')
|
||||
|
||||
config.substitutions.append(('%PATH%', config.environment['PATH']))
|
||||
config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
|
||||
config.substitutions.append(
|
||||
('%resources_dir', os.path.join(config.torch_mlir_dialects_obj_root,
|
||||
'resources')))
|
||||
|
||||
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'
|
||||
]
|
||||
|
||||
# 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.torch_mlir_dialects_obj_root, 'test')
|
||||
config.standalone_tools_dir = os.path.join(config.torch_mlir_dialects_obj_root, 'bin')
|
||||
|
||||
# Tweak the PATH to include the tools dir.
|
||||
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
|
||||
tool_dirs = [config.torch_mlir_dialects_tools_dir, config.llvm_tools_dir]
|
||||
tools = [
|
||||
"torch-mlir-dialects-opt",
|
||||
ToolSubst('%PYTHON', config.python_executable, unresolved='ignore'),
|
||||
]
|
||||
|
||||
llvm_config.add_tool_substitutions(tools, tool_dirs)
|
|
@ -1,27 +0,0 @@
|
|||
# -*- 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.
|
||||
|
||||
@LIT_SITE_CFG_IN_HEADER@
|
||||
|
||||
import sys
|
||||
|
||||
config.torch_mlir_dialects_obj_root = "@TORCH_MLIR_DIALECTS_BINARY_DIR@"
|
||||
config.torch_mlir_dialects_tools_dir = "@TORCH_MLIR_DIALECTS_TOOLS_DIR@"
|
||||
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
|
||||
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
|
||||
config.llvm_tools_dir = "@LLVM_TOOLS_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 = sys.executable
|
||||
|
||||
import lit.llvm
|
||||
lit.llvm.initialize(lit_config, config)
|
||||
|
||||
# Let the main config do the real work.
|
||||
lit_config.load_config(config, "@TORCH_MLIR_DIALECTS_SOURCE_DIR@/test/lit.cfg.py")
|
|
@ -1 +0,0 @@
|
|||
add_subdirectory(torch-mlir-dialects-opt)
|
|
@ -1,22 +0,0 @@
|
|||
set(LIBS
|
||||
MLIRArithDialect
|
||||
MLIRDialect
|
||||
MLIRLinalgDialect
|
||||
MLIRMemRefDialect
|
||||
MLIROptLib
|
||||
MLIRSCFDialect
|
||||
MLIRSCFTransforms
|
||||
MLIRFuncDialect
|
||||
MLIRTensorDialect
|
||||
MLIRTransforms
|
||||
TorchMLIRTMTensorDialect
|
||||
TorchMLIRTMTensorPasses
|
||||
)
|
||||
|
||||
add_llvm_tool(torch-mlir-dialects-opt
|
||||
torch-mlir-dialects-opt.cpp
|
||||
|
||||
DEPENDS
|
||||
${LIBS}
|
||||
)
|
||||
target_link_libraries(torch-mlir-dialects-opt PRIVATE ${LIBS})
|
|
@ -1,48 +0,0 @@
|
|||
//===------------------------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/Dialect/Arith/IR/Arith.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/Linalg/IR/Linalg.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/SCF/IR/SCF.h"
|
||||
#include "mlir/Dialect/SCF/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
||||
#include "mlir/IR/AsmState.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/Tools/mlir-opt/MlirOptMain.h"
|
||||
#include "mlir/Transforms/Passes.h"
|
||||
#include "torch-mlir-dialects/Dialect/TMTensor/IR/ScalarLoopOpInterface.h"
|
||||
#include "torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorDialect.h"
|
||||
#include "torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
registerAsmPrinterCLOptions();
|
||||
registerMLIRContextCLOptions();
|
||||
|
||||
registerTransformsPasses();
|
||||
registerSCFPasses();
|
||||
|
||||
// Local dialects.
|
||||
mlir::torch::TMTensor::registerPasses();
|
||||
|
||||
DialectRegistry registry;
|
||||
registry.insert<
|
||||
// Local dialects
|
||||
mlir::torch::TMTensor::TMTensorDialect,
|
||||
// Upstream dialects
|
||||
mlir::arith::ArithDialect, mlir::linalg::LinalgDialect,
|
||||
mlir::func::FuncDialect, mlir::memref::MemRefDialect,
|
||||
mlir::scf::SCFDialect, mlir::tensor::TensorDialect>();
|
||||
|
||||
return mlir::asMainReturnCode(mlir::MlirOptMain(
|
||||
argc, argv, "MLIR modular optimizer driver\n", registry));
|
||||
}
|
Loading…
Reference in New Issue