mirror of https://github.com/llvm/torch-mlir
Re-organize project structure to separate PyTorch dependencies from core project. (#2542)
This is a first step towards the structure we discussed here: https://gist.github.com/stellaraccident/931b068aaf7fa56f34069426740ebf20 There are two primary goals: 1. Separate the core project (C++ dialects and conversions) from the hard PyTorch dependencies. We move all such things into projects/pt1 as a starting point since they are presently entangled with PT1-era APIs. Additional work can be done to disentangle components from that (specifically LTC is identified as likely ultimately living in a `projects/ltc`). 2. Create space for native PyTorch2 Dynamo-based infra to be upstreamed without needing to co-exist with the original TorchScript path. Very little changes in this path with respect to build layering or options. These can be updated in a followup without commingling directory structure changes. This also takes steps toward a couple of other layering enhancements: * Removes the llvm-external-projects/torch-mlir-dialects sub-project, collapsing it into the main tree. * Audits and fixes up the core C++ build to account for issues found while moving things. This is just an opportunistic pass through but roughly ~halves the number of build actions for the project from the high 4000's to the low 2000's. It deviates from the discussed plan by having a `projects/` tree instead of `compat/`. As I was thinking about it, this will better accommodate the follow-on code movement. Once things are roughly in place and the CI passing, followups will focus on more in-situ fixes and cleanups.pull/2549/head snapshot-20231103.1011
parent
536e45cb3b
commit
6961f0a247
|
@ -125,9 +125,8 @@ jobs:
|
||||||
-DCMAKE_OSX_ARCHITECTURES=arm64 \
|
-DCMAKE_OSX_ARCHITECTURES=arm64 \
|
||||||
-DLLVM_ENABLE_ASSERTIONS=ON \
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
||||||
-DLLVM_ENABLE_PROJECTS=mlir \
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
||||||
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
|
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$GITHUB_WORKSPACE" \
|
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$GITHUB_WORKSPACE" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="${GITHUB_WORKSPACE}/externals/llvm-external-projects/torch-mlir-dialects" \
|
|
||||||
-DLLVM_TARGETS_TO_BUILD=AArch64 \
|
-DLLVM_TARGETS_TO_BUILD=AArch64 \
|
||||||
-DLLVM_USE_HOST_TOOLS=ON \
|
-DLLVM_USE_HOST_TOOLS=ON \
|
||||||
-DLLVM_ENABLE_ZSTD=OFF \
|
-DLLVM_ENABLE_ZSTD=OFF \
|
||||||
|
|
|
@ -26,7 +26,7 @@ __pycache__
|
||||||
bazel-*
|
bazel-*
|
||||||
|
|
||||||
# Autogenerated files
|
# Autogenerated files
|
||||||
/python/torch_mlir/csrc/base_lazy_backend/generated
|
/projects/pt1/python/torch_mlir/csrc/base_lazy_backend/generated
|
||||||
|
|
||||||
#Docker builds
|
#Docker builds
|
||||||
build_oot/
|
build_oot/
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Project setup and globals
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
if(POLICY CMP0068)
|
if(POLICY CMP0068)
|
||||||
|
@ -17,30 +21,30 @@ if(POLICY CMP0116)
|
||||||
cmake_policy(SET CMP0116 OLD)
|
cmake_policy(SET CMP0116 OLD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# Project setup and globals
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
project(torch-mlir LANGUAGES CXX C)
|
project(torch-mlir LANGUAGES CXX C)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
macro(torch_mlir_add_llvm_external_project name identifier location)
|
#-------------------------------------------------------------------------------
|
||||||
message(STATUS "Adding LLVM external project ${name} (${identifier}) -> ${location}")
|
# Project options
|
||||||
if(NOT EXISTS "${location}/CMakeLists.txt")
|
#-------------------------------------------------------------------------------
|
||||||
message(FATAL_ERROR "External project location ${location} is not valid")
|
|
||||||
endif()
|
option(TORCH_MLIR_ENABLE_REFBACKEND "Enable reference backend" ON)
|
||||||
list(APPEND LLVM_EXTERNAL_PROJECTS ${name})
|
if(TORCH_MLIR_ENABLE_REFBACKEND)
|
||||||
list(REMOVE_DUPLICATES LLVM_EXTERNAL_PROJECTS)
|
add_definitions(-DTORCH_MLIR_ENABLE_REFBACKEND)
|
||||||
set(LLVM_EXTERNAL_${identifier}_SOURCE_DIR ${location} CACHE STRING "" FORCE)
|
endif()
|
||||||
set(LLVM_EXTERNAL_PROJECTS ${LLVM_EXTERNAL_PROJECTS} CACHE STRING "" FORCE)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
option(TORCH_MLIR_ENABLE_STABLEHLO "Add stablehlo dialect" ON)
|
option(TORCH_MLIR_ENABLE_STABLEHLO "Add stablehlo dialect" ON)
|
||||||
if(TORCH_MLIR_ENABLE_STABLEHLO)
|
if(TORCH_MLIR_ENABLE_STABLEHLO)
|
||||||
add_definitions(-DTORCH_MLIR_ENABLE_STABLEHLO)
|
add_definitions(-DTORCH_MLIR_ENABLE_STABLEHLO)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(TORCH_MLIR_OUT_OF_TREE_BUILD "Specifies an out of tree build" OFF)
|
||||||
|
|
||||||
|
# PT1 options.
|
||||||
|
option(TORCH_MLIR_ENABLE_PROJECT_PT1 "Enables the PyTorch1 project under projects/pt1" OFF)
|
||||||
|
# TODO: Rename/scope these. They use historic names for now to ease migration
|
||||||
|
# burden.
|
||||||
option(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER "Enables JIT IR Importer" ON)
|
option(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER "Enables JIT IR Importer" ON)
|
||||||
option(TORCH_MLIR_ENABLE_LTC "Enables LTC backend" OFF)
|
option(TORCH_MLIR_ENABLE_LTC "Enables LTC backend" OFF)
|
||||||
option(TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS "Build Torch dialect MLIR Python bindings but neither JIT IR Importer nor LTC backend" OFF)
|
option(TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS "Build Torch dialect MLIR Python bindings but neither JIT IR Importer nor LTC backend" OFF)
|
||||||
|
@ -48,21 +52,17 @@ if(TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS)
|
||||||
set(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OFF)
|
set(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OFF)
|
||||||
set(TORCH_MLIR_ENABLE_LTC OFF)
|
set(TORCH_MLIR_ENABLE_LTC OFF)
|
||||||
endif()
|
endif()
|
||||||
|
# Force enable the PT1 project if either the JIT_IR_IMPORTER or LTC is enabled.
|
||||||
if(TORCH_MLIR_ENABLE_LTC)
|
if(NOT TORCH_MLIR_ENABLE_PROJECT_PT1)
|
||||||
set(ENV{TORCH_MLIR_ENABLE_LTC} 1)
|
if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OR TORCH_MLIR_ENABLE_LTC)
|
||||||
message(STATUS "LTC Backend build is enabled")
|
message(STATUS "Enabling projects/pt1 because features requiring it are enabled")
|
||||||
else()
|
set(TORCH_MLIR_ENABLE_PROJECT_PT1 ON)
|
||||||
set(ENV{TORCH_MLIR_ENABLE_LTC} 0)
|
endif()
|
||||||
message(STATUS "LTC Backend build is disabled")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
torch_mlir_add_llvm_external_project(
|
#-------------------------------------------------------------------------------
|
||||||
torch-mlir-dialects
|
# Configure out-of-tree vs in-tree build
|
||||||
TORCH_MLIR_DIALECTS
|
#-------------------------------------------------------------------------------
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/externals/llvm-external-projects/torch-mlir-dialects)
|
|
||||||
|
|
||||||
option(TORCH_MLIR_OUT_OF_TREE_BUILD "Specifies an out of tree build" OFF)
|
|
||||||
|
|
||||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR TORCH_MLIR_OUT_OF_TREE_BUILD)
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR TORCH_MLIR_OUT_OF_TREE_BUILD)
|
||||||
message(STATUS "Torch-MLIR out-of-tree build.")
|
message(STATUS "Torch-MLIR out-of-tree build.")
|
||||||
|
@ -99,11 +99,10 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR TORCH_MLIR_OUT_OF_TREE_
|
||||||
|
|
||||||
# Don't try to compile the python extensions at the moment. We need
|
# Don't try to compile the python extensions at the moment. We need
|
||||||
# to import lots of dependencies from AddMLIRPython to make this work.
|
# to import lots of dependencies from AddMLIRPython to make this work.
|
||||||
set(MLIR_ENABLE_BINDINGS_PYTHON 1)
|
set(MLIR_ENABLE_BINDINGS_PYTHON ON)
|
||||||
|
|
||||||
set(TORCH-MLIR_BUILT_STANDALONE 1)
|
set(TORCH-MLIR_BUILT_STANDALONE ON)
|
||||||
set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
|
set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
|
||||||
add_subdirectory(externals/llvm-external-projects/torch-mlir-dialects)
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Torch-MLIR in-tree build.")
|
message(STATUS "Torch-MLIR in-tree build.")
|
||||||
# In-tree build with LLVM_EXTERNAL_PROJECTS=torch-mlir
|
# In-tree build with LLVM_EXTERNAL_PROJECTS=torch-mlir
|
||||||
|
@ -169,11 +168,7 @@ add_subdirectory(lib)
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
|
|
||||||
add_custom_target(check-torch-mlir-all)
|
add_custom_target(check-torch-mlir-all)
|
||||||
add_dependencies(check-torch-mlir-all
|
add_dependencies(check-torch-mlir-all check-torch-mlir)
|
||||||
check-torch-mlir
|
|
||||||
check-torch-mlir-dialects
|
|
||||||
check-torch-mlir-capi
|
|
||||||
)
|
|
||||||
|
|
||||||
if(MLIR_ENABLE_BINDINGS_PYTHON)
|
if(MLIR_ENABLE_BINDINGS_PYTHON)
|
||||||
# If parent projects want to configure where to place the python packages,
|
# If parent projects want to configure where to place the python packages,
|
||||||
|
@ -181,12 +176,6 @@ if(MLIR_ENABLE_BINDINGS_PYTHON)
|
||||||
if(NOT TORCH_MLIR_PYTHON_PACKAGES_DIR)
|
if(NOT TORCH_MLIR_PYTHON_PACKAGES_DIR)
|
||||||
set(TORCH_MLIR_PYTHON_PACKAGES_DIR "${CMAKE_CURRENT_BINARY_DIR}/python_packages")
|
set(TORCH_MLIR_PYTHON_PACKAGES_DIR "${CMAKE_CURRENT_BINARY_DIR}/python_packages")
|
||||||
endif()
|
endif()
|
||||||
add_dependencies(check-torch-mlir-all
|
|
||||||
check-torch-mlir-python
|
|
||||||
)
|
|
||||||
add_subdirectory(python)
|
|
||||||
else()
|
|
||||||
add_custom_target(TorchMLIRPythonModules)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
@ -237,3 +226,11 @@ if (TORCH_MLIR_ENABLE_STABLEHLO)
|
||||||
EXCLUDE_FROM_ALL)
|
EXCLUDE_FROM_ALL)
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/externals/stablehlo)
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/externals/stablehlo)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Sub-projects
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if(TORCH_MLIR_ENABLE_PROJECT_PT1)
|
||||||
|
add_subdirectory(projects/pt1)
|
||||||
|
endif()
|
||||||
|
|
|
@ -29,7 +29,7 @@ if not TORCH_INCLUDE_DIR.is_dir():
|
||||||
TORCH_INCLUDE_DIR = TORCH_DIR
|
TORCH_INCLUDE_DIR = TORCH_DIR
|
||||||
TORCHGEN_DIR = Path(torchgen.__path__[0]).resolve()
|
TORCHGEN_DIR = Path(torchgen.__path__[0]).resolve()
|
||||||
TORCH_MLIR_DIR = Path(__file__).resolve().parent.parent
|
TORCH_MLIR_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
TORCH_MLIR_PT1_DIR = TORCH_MLIR_DIR / "projects" / "pt1"
|
||||||
|
|
||||||
def reindent(text, prefix=""):
|
def reindent(text, prefix=""):
|
||||||
return indent(dedent(text), prefix)
|
return indent(dedent(text), prefix)
|
||||||
|
@ -114,12 +114,12 @@ class GenTorchMlirLTC:
|
||||||
self.binary_dir = Path(binary_dir)
|
self.binary_dir = Path(binary_dir)
|
||||||
assert self.binary_dir.is_dir(), f"Binary directory not found: {self.binary_dir}"
|
assert self.binary_dir.is_dir(), f"Binary directory not found: {self.binary_dir}"
|
||||||
self.source_yaml = self.binary_dir.joinpath("generated_native_functions.yaml")
|
self.source_yaml = self.binary_dir.joinpath("generated_native_functions.yaml")
|
||||||
self.backend_path = TORCH_MLIR_DIR.joinpath(
|
self.backend_path = TORCH_MLIR_PT1_DIR.joinpath(
|
||||||
"python", "torch_mlir", "csrc", "base_lazy_backend"
|
"python", "torch_mlir", "csrc", "base_lazy_backend"
|
||||||
)
|
)
|
||||||
assert self.backend_path.is_dir()
|
assert self.backend_path.is_dir(), f"Backend path not found: {self.backend_path}"
|
||||||
self.generated_path = self.binary_dir.joinpath(
|
self.generated_path = self.binary_dir.joinpath(
|
||||||
"python", "torch_mlir", "csrc", "base_lazy_backend", "generated"
|
"projects", "pt1", "python", "torch_mlir", "csrc", "base_lazy_backend", "generated"
|
||||||
)
|
)
|
||||||
self.generated_path.mkdir(parents=True, exist_ok=True)
|
self.generated_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,8 @@ cmake -GNinja -B"$build_dir" "$llvm_project_dir/llvm" \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
-DLLVM_ENABLE_PROJECTS=mlir \
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
||||||
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
|
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$project_dir" \
|
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$project_dir" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="${project_dir}"/externals/llvm-external-projects/torch-mlir-dialects \
|
|
||||||
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
||||||
-DLLVM_ENABLE_ASSERTIONS=ON \
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
||||||
-DLLVM_TARGETS_TO_BUILD=host
|
-DLLVM_TARGETS_TO_BUILD=host
|
||||||
|
|
|
@ -234,9 +234,8 @@ function build_in_tree() {
|
||||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
-DLLVM_ENABLE_PROJECTS=mlir \
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
||||||
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
|
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="/main_checkout/torch-mlir" \
|
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="/main_checkout/torch-mlir" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="/main_checkout/torch-mlir/externals/llvm-external-projects/torch-mlir-dialects" \
|
|
||||||
-DLLVM_TARGETS_TO_BUILD=host \
|
-DLLVM_TARGETS_TO_BUILD=host \
|
||||||
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
||||||
-DTORCH_MLIR_ENABLE_LTC=${enable_ltc} \
|
-DTORCH_MLIR_ENABLE_LTC=${enable_ltc} \
|
||||||
|
@ -246,7 +245,7 @@ function build_in_tree() {
|
||||||
-DTM_PYTORCH_INSTALL_WITHOUT_REBUILD=${TM_PYTORCH_INSTALL_WITHOUT_REBUILD} \
|
-DTM_PYTORCH_INSTALL_WITHOUT_REBUILD=${TM_PYTORCH_INSTALL_WITHOUT_REBUILD} \
|
||||||
-DPython3_EXECUTABLE="$(which python3)" \
|
-DPython3_EXECUTABLE="$(which python3)" \
|
||||||
/main_checkout/torch-mlir/externals/llvm-project/llvm
|
/main_checkout/torch-mlir/externals/llvm-project/llvm
|
||||||
cmake --build /main_checkout/torch-mlir/build
|
cmake --build /main_checkout/torch-mlir/build --target tools/torch-mlir/all
|
||||||
ccache -s
|
ccache -s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +287,7 @@ function test_in_tree() {
|
||||||
cmake --build /main_checkout/torch-mlir/build --target check-torch-mlir-all
|
cmake --build /main_checkout/torch-mlir/build --target check-torch-mlir-all
|
||||||
|
|
||||||
cd /main_checkout/torch-mlir/
|
cd /main_checkout/torch-mlir/
|
||||||
export PYTHONPATH="/main_checkout/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir"
|
export PYTHONPATH="/main_checkout/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir:/main_checkout/torch-mlir/projects/pt1"
|
||||||
|
|
||||||
case $torch_version in
|
case $torch_version in
|
||||||
nightly)
|
nightly)
|
||||||
|
|
|
@ -11,9 +11,8 @@ cmake -GNinja -Bbuild \
|
||||||
-DLLVM_TARGETS_TO_BUILD=host \
|
-DLLVM_TARGETS_TO_BUILD=host \
|
||||||
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
||||||
-DPython3_FIND_VIRTUALENV=ONLY \
|
-DPython3_FIND_VIRTUALENV=ONLY \
|
||||||
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
|
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
|
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="$PWD/externals/llvm-external-projects/torch-mlir-dialects" \
|
|
||||||
-DPython3_EXECUTABLE="$(which python)" \
|
-DPython3_EXECUTABLE="$(which python)" \
|
||||||
$GITHUB_WORKSPACE/externals/llvm-project/llvm
|
$GITHUB_WORKSPACE/externals/llvm-project/llvm
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,8 @@ cmake -GNinja -Bbuild \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DPython3_FIND_VIRTUALENV=ONLY \
|
-DPython3_FIND_VIRTUALENV=ONLY \
|
||||||
-DLLVM_ENABLE_PROJECTS=mlir \
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
||||||
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
|
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
|
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
|
||||||
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="$PWD"/externals/llvm-external-projects/torch-mlir-dialects \
|
|
||||||
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
||||||
-DLLVM_TARGETS_TO_BUILD=host \
|
-DLLVM_TARGETS_TO_BUILD=host \
|
||||||
externals/llvm-project/llvm
|
externals/llvm-project/llvm
|
||||||
|
@ -360,6 +359,7 @@ Torch-MLIR has two types of tests:
|
||||||
Alternatively, you can run the tests via Python directly:
|
Alternatively, you can run the tests via Python directly:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
cd projects/pt1
|
||||||
python -m e2e_testing.main -f 'AtenEmbeddingBag'
|
python -m e2e_testing.main -f 'AtenEmbeddingBag'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ ninja check-torch-mlir-all
|
||||||
This can be broken down into
|
This can be broken down into
|
||||||
|
|
||||||
```
|
```
|
||||||
ninja check-torch-mlir check-torch-mlir-dialects check-torch-mlir-python
|
ninja check-torch-mlir check-torch-mlir-python
|
||||||
```
|
```
|
||||||
|
|
||||||
To run more fine-grained tests, you can do, for `check-torch-mlir`:
|
To run more fine-grained tests, you can do, for `check-torch-mlir`:
|
||||||
|
|
|
@ -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,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));
|
|
||||||
}
|
|
|
@ -1 +1,2 @@
|
||||||
add_subdirectory(torch-mlir)
|
add_subdirectory(torch-mlir)
|
||||||
|
add_subdirectory(torch-mlir-dialects)
|
|
@ -15,7 +15,13 @@
|
||||||
namespace mlir {
|
namespace mlir {
|
||||||
namespace torch {
|
namespace torch {
|
||||||
|
|
||||||
|
// Registers all dialects that this project produces and any dependencies.
|
||||||
void registerAllDialects(mlir::DialectRegistry ®istry);
|
void registerAllDialects(mlir::DialectRegistry ®istry);
|
||||||
|
|
||||||
|
// Registers dialects that may be needed to parse torch-mlir inputs and
|
||||||
|
// test cases.
|
||||||
|
void registerOptionalInputDialects(mlir::DialectRegistry ®istry);
|
||||||
|
|
||||||
void registerAllPasses();
|
void registerAllPasses();
|
||||||
|
|
||||||
} // namespace torch
|
} // namespace torch
|
||||||
|
|
|
@ -9,8 +9,6 @@ add_mlir_public_c_api_library(TorchMLIRCAPI
|
||||||
${PROJECT_SOURCE_DIR}/include/torch-mlir-c/
|
${PROJECT_SOURCE_DIR}/include/torch-mlir-c/
|
||||||
|
|
||||||
ENABLE_AGGREGATION
|
ENABLE_AGGREGATION
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
add_subdirectory(CAPI)
|
add_subdirectory(CAPI)
|
||||||
add_subdirectory(Conversion)
|
add_subdirectory(Conversion)
|
||||||
add_subdirectory(Dialect)
|
add_subdirectory(Dialect)
|
||||||
add_subdirectory(RefBackend)
|
|
||||||
|
|
||||||
get_property(extension_libs GLOBAL PROPERTY MLIR_EXTENSION_LIBS)
|
|
||||||
set(LinkedLibs
|
set(LinkedLibs
|
||||||
|
MLIRComplexDialect
|
||||||
MLIRFuncDialect
|
MLIRFuncDialect
|
||||||
|
MLIRFuncInlinerExtension
|
||||||
MLIRIR
|
MLIRIR
|
||||||
|
MLIRMLProgramDialect
|
||||||
|
MLIRMemRefDialect
|
||||||
|
MLIRSCFDialect
|
||||||
|
MLIRTensorDialect
|
||||||
|
MLIRTosaDialect
|
||||||
MLIRSupport
|
MLIRSupport
|
||||||
${extension_libs}
|
|
||||||
|
|
||||||
TorchMLIRTorchPasses
|
TorchMLIRTorchPasses
|
||||||
TorchMLIRTorchConversionDialect
|
TorchMLIRTorchConversionDialect
|
||||||
|
@ -20,15 +24,16 @@ set(LinkedLibs
|
||||||
TorchMLIRTMTensorDialect
|
TorchMLIRTMTensorDialect
|
||||||
|
|
||||||
TorchMLIRConversionPasses
|
TorchMLIRConversionPasses
|
||||||
TorchMLIRRefBackend
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(TORCH_MLIR_ENABLE_REFBACKEND)
|
||||||
|
add_subdirectory(RefBackend)
|
||||||
|
list(APPEND LinkedLibs TorchMLIRRefBackend)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_mlir_library(TorchMLIRInitAll
|
add_mlir_library(TorchMLIRInitAll
|
||||||
InitAll.cpp
|
InitAll.cpp
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
${LinkedLibs}
|
${LinkedLibs}
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,10 +27,6 @@ add_mlir_library(TorchMLIRConversionPasses
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRConversionPassIncGen
|
TorchMLIRConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
${linked_libs}
|
${linked_libs}
|
||||||
#${torch_mlir_conversion_libs}
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,9 +7,6 @@ add_mlir_conversion_library(TorchMLIRTorchConversionToMLProgram
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRConversionPassIncGen
|
TorchMLIRConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRLinalgDialect
|
MLIRLinalgDialect
|
||||||
|
|
|
@ -7,9 +7,6 @@ add_mlir_conversion_library(TorchMLIRTorchToArith
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRConversionPassIncGen
|
TorchMLIRConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRPass
|
MLIRPass
|
||||||
|
|
|
@ -17,9 +17,6 @@ add_mlir_conversion_library(TorchMLIRTorchToLinalg
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRConversionPassIncGen
|
TorchMLIRConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRPass
|
MLIRPass
|
||||||
|
|
|
@ -7,9 +7,6 @@ add_mlir_conversion_library(TorchMLIRTorchToSCF
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRConversionPassIncGen
|
TorchMLIRConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRPass
|
MLIRPass
|
||||||
|
|
|
@ -14,9 +14,6 @@ add_mlir_conversion_library(TorchMLIRTorchToStablehlo
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRConversionPassIncGen
|
TorchMLIRConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRPass
|
MLIRPass
|
||||||
|
|
|
@ -7,9 +7,6 @@ TorchToTMTensor.cpp
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRConversionPassIncGen
|
TorchMLIRConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRPass
|
MLIRPass
|
||||||
|
|
|
@ -9,9 +9,6 @@ add_mlir_conversion_library(TorchMLIRTorchToTosa
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRConversionPassIncGen
|
TorchMLIRConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRPass
|
MLIRPass
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
|
add_subdirectory(TMTensor)
|
||||||
add_subdirectory(Torch)
|
add_subdirectory(Torch)
|
||||||
add_subdirectory(TorchConversion)
|
add_subdirectory(TorchConversion)
|
||||||
|
|
|
@ -26,4 +26,4 @@ add_mlir_library(TorchMLIRTMTensorDialect
|
||||||
MLIRViewLikeInterface
|
MLIRViewLikeInterface
|
||||||
)
|
)
|
||||||
|
|
||||||
torch_mlir_dialects_target_includes(TorchMLIRTMTensorDialect)
|
torch_mlir_target_includes(TorchMLIRTMTensorDialect)
|
|
@ -21,3 +21,5 @@ add_mlir_library(TorchMLIRTMTensorPasses
|
||||||
MLIRTensorDialect
|
MLIRTensorDialect
|
||||||
MLIRTransforms
|
MLIRTransforms
|
||||||
)
|
)
|
||||||
|
|
||||||
|
torch_mlir_target_includes(TorchMLIRTMTensorPasses)
|
|
@ -12,9 +12,6 @@ add_mlir_library(TorchMLIRTorchDialect
|
||||||
MLIRTorchOpsIncGen
|
MLIRTorchOpsIncGen
|
||||||
MLIRTorchTypesIncGen
|
MLIRTorchTypesIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRBytecodeOpInterface
|
MLIRBytecodeOpInterface
|
||||||
MLIRBytecodeReader
|
MLIRBytecodeReader
|
||||||
|
|
|
@ -26,9 +26,6 @@ add_mlir_library(TorchMLIRTorchPasses
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRTorchPassIncGen
|
TorchMLIRTorchPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRPass
|
MLIRPass
|
||||||
|
|
|
@ -9,9 +9,6 @@ add_mlir_dialect_library(TorchMLIRTorchConversionDialect
|
||||||
MLIRTorchConversionOpsIncGen
|
MLIRTorchConversionOpsIncGen
|
||||||
MLIRTorchTypesIncGen
|
MLIRTorchTypesIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
MLIRSupport
|
MLIRSupport
|
||||||
|
|
|
@ -39,9 +39,6 @@ add_mlir_library(TorchMLIRTorchConversionPasses
|
||||||
DEPENDS
|
DEPENDS
|
||||||
TorchMLIRTorchConversionPassIncGen
|
TorchMLIRTorchConversionPassIncGen
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
${LinkedLibs}
|
${LinkedLibs}
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,8 +9,15 @@
|
||||||
|
|
||||||
#include "torch-mlir/InitAll.h"
|
#include "torch-mlir/InitAll.h"
|
||||||
|
|
||||||
|
#include "mlir/Dialect/Complex/IR/Complex.h"
|
||||||
#include "mlir/Dialect/Func/Extensions/InlinerExtension.h"
|
#include "mlir/Dialect/Func/Extensions/InlinerExtension.h"
|
||||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||||
|
#include "mlir/Dialect/Linalg/IR/Linalg.h"
|
||||||
|
#include "mlir/Dialect/MLProgram/IR/MLProgram.h"
|
||||||
|
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||||
|
#include "mlir/Dialect/SCF/IR/SCF.h"
|
||||||
|
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
||||||
|
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
|
||||||
#include "mlir/IR/Dialect.h"
|
#include "mlir/IR/Dialect.h"
|
||||||
#include "torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorDialect.h"
|
#include "torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorDialect.h"
|
||||||
#include "torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.h"
|
#include "torch-mlir-dialects/Dialect/TMTensor/Transforms/Passes.h"
|
||||||
|
@ -29,11 +36,22 @@ void mlir::torch::registerAllDialects(mlir::DialectRegistry ®istry) {
|
||||||
mlir::func::registerInlinerExtension(registry);
|
mlir::func::registerInlinerExtension(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Break this up when backends are separated.
|
||||||
|
void mlir::torch::registerOptionalInputDialects(
|
||||||
|
mlir::DialectRegistry ®istry) {
|
||||||
|
registry.insert<complex::ComplexDialect, linalg::LinalgDialect,
|
||||||
|
memref::MemRefDialect, ml_program::MLProgramDialect,
|
||||||
|
scf::SCFDialect, tensor::TensorDialect, tosa::TosaDialect>();
|
||||||
|
}
|
||||||
|
|
||||||
void mlir::torch::registerAllPasses() {
|
void mlir::torch::registerAllPasses() {
|
||||||
mlir::torch::registerTorchPasses();
|
mlir::torch::registerTorchPasses();
|
||||||
mlir::torch::registerTorchConversionPasses();
|
mlir::torch::registerTorchConversionPasses();
|
||||||
|
|
||||||
mlir::torch::registerConversionPasses();
|
mlir::torch::registerConversionPasses();
|
||||||
mlir::torch::RefBackend::registerRefBackendPasses();
|
|
||||||
mlir::torch::TMTensor::registerPasses();
|
mlir::torch::TMTensor::registerPasses();
|
||||||
|
|
||||||
|
#ifdef TORCH_MLIR_ENABLE_REFBACKEND
|
||||||
|
mlir::torch::RefBackend::registerRefBackendPasses();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
message(STATUS "Building PyTorch1 compatibility project")
|
||||||
|
|
||||||
|
if(TORCH_MLIR_ENABLE_LTC)
|
||||||
|
set(ENV{TORCH_MLIR_ENABLE_LTC} 1)
|
||||||
|
message(STATUS "LTC Backend build is enabled")
|
||||||
|
else()
|
||||||
|
set(ENV{TORCH_MLIR_ENABLE_LTC} 0)
|
||||||
|
message(STATUS "LTC Backend build is disabled")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/python/torch_mlir/cmake/modules")
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Setup python.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
if(MLIR_ENABLE_BINDINGS_PYTHON)
|
||||||
|
add_dependencies(check-torch-mlir-all
|
||||||
|
check-torch-mlir-pt1
|
||||||
|
)
|
||||||
|
add_subdirectory(python)
|
||||||
|
else()
|
||||||
|
add_custom_target(TorchMLIRPythonModules)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(test)
|
|
@ -29,7 +29,7 @@ if (NOT TORCH_MLIR_USE_INSTALLED_PYTORCH)
|
||||||
set(ENV{CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER_LAUNCHER})
|
set(ENV{CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER_LAUNCHER})
|
||||||
set(ENV{CMAKE_CXX_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER_LAUNCHER})
|
set(ENV{CMAKE_CXX_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER_LAUNCHER})
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../build_tools/build_libtorch.sh
|
COMMAND ${TORCH_MLIR_SOURCE_DIR}/build_tools/build_libtorch.sh
|
||||||
RESULT_VARIABLE _result
|
RESULT_VARIABLE _result
|
||||||
)
|
)
|
||||||
if(_result)
|
if(_result)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue