2021-10-22 12:18:08 +08:00
|
|
|
# Disables generation of "version soname" (i.e. libFoo.so.<version>), which
|
|
|
|
# causes pure duplication as part of Python wheels.
|
|
|
|
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON)
|
|
|
|
|
2021-09-21 04:55:36 +08:00
|
|
|
# The directory at which the Python import tree begins.
|
|
|
|
# See documentation for `declare_mlir_python_sources`'s ROOT_DIR
|
|
|
|
# argument.
|
|
|
|
set(TORCH_MLIR_PYTHON_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/torch_mlir")
|
|
|
|
|
|
|
|
# We vendor our own MLIR instance in the `torch_mlir` namespace.
|
|
|
|
add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=torch_mlir.")
|
|
|
|
|
2023-12-13 11:02:51 +08:00
|
|
|
# ################################################################################
|
|
|
|
# # Sources
|
|
|
|
# ################################################################################
|
2021-09-11 02:44:38 +08:00
|
|
|
|
2023-12-13 11:02:51 +08:00
|
|
|
declare_mlir_python_sources(TorchMLIRPythonSources.TopLevel
|
2021-09-21 04:55:36 +08:00
|
|
|
ROOT_DIR "${TORCH_MLIR_PYTHON_ROOT_DIR}"
|
2023-12-13 11:02:51 +08:00
|
|
|
ADD_TO_PARENT TorchMLIRPythonTorchExtensionsSources
|
2021-09-11 02:44:38 +08:00
|
|
|
SOURCES
|
2024-02-07 11:07:59 +08:00
|
|
|
torchscript.py
|
2023-12-13 11:02:51 +08:00
|
|
|
_dynamo_fx_importer.py
|
|
|
|
dynamo.py
|
|
|
|
_version.py
|
2021-09-11 02:44:38 +08:00
|
|
|
)
|
|
|
|
|
2022-02-18 09:15:37 +08:00
|
|
|
################################################################################
|
|
|
|
# Lazy Tensor Core
|
|
|
|
################################################################################
|
|
|
|
|
2022-08-06 02:12:20 +08:00
|
|
|
# Reference backend has a separate check for TORCH_MLIR_ENABLE_LTC, since it
|
|
|
|
# generates a dummy Python library when disabled.
|
2023-02-14 04:21:06 +08:00
|
|
|
if(NOT TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS)
|
|
|
|
add_subdirectory(torch_mlir/csrc/reference_lazy_backend)
|
|
|
|
endif()
|
2022-02-18 09:15:37 +08:00
|
|
|
|
2021-09-21 04:55:36 +08:00
|
|
|
################################################################################
|
|
|
|
# Optionally handle JIT IR importer.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER)
|
2023-11-20 04:10:19 +08:00
|
|
|
add_subdirectory(torch_mlir/jit_ir_importer)
|
|
|
|
add_subdirectory(torch_mlir/csrc/jit_ir_importer)
|
2021-09-28 02:36:44 +08:00
|
|
|
add_subdirectory(torch_mlir_e2e_test)
|
2021-09-21 04:55:36 +08:00
|
|
|
endif()
|
|
|
|
|
2022-06-14 05:51:30 +08:00
|
|
|
################################################################################
|
|
|
|
# Custom op example
|
2022-12-14 00:25:41 +08:00
|
|
|
# Required for running the update_torch_ods.sh and update_abstract_interp_lib.sh
|
|
|
|
# scripts.
|
2022-06-14 05:51:30 +08:00
|
|
|
################################################################################
|
|
|
|
|
2022-08-03 04:35:56 +08:00
|
|
|
# add_subdirectory(torch_mlir/_torch_mlir_custom_op_example)
|
2022-06-14 05:51:30 +08:00
|
|
|
|
2021-09-21 04:55:36 +08:00
|
|
|
# TODO: Find a cleaner way to do this.
|
|
|
|
# Can we build the JIT IR importer with `declare_mlir_python_extension`?
|
|
|
|
# Then it would "just work".
|
|
|
|
if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER)
|
2024-04-28 05:08:09 +08:00
|
|
|
add_dependencies(TorchMLIRPythonTorchExtensionsSources
|
2023-12-13 11:02:51 +08:00
|
|
|
TorchMLIRJITIRImporter
|
|
|
|
TorchMLIRJITIRImporterPybind
|
|
|
|
TorchMLIRE2ETestPythonModules
|
|
|
|
)
|
2021-09-21 04:55:36 +08:00
|
|
|
endif()
|
2021-09-28 02:36:44 +08:00
|
|
|
|
2022-07-30 17:54:40 +08:00
|
|
|
if(TORCH_MLIR_ENABLE_LTC)
|
|
|
|
# Add Torch-MLIR LTC backend as dependency
|
2024-04-28 05:08:09 +08:00
|
|
|
add_dependencies(TorchMLIRPythonTorchExtensionsSources
|
2023-12-13 11:02:51 +08:00
|
|
|
torch_mlir_ltc_backend
|
|
|
|
reference_lazy_backend
|
|
|
|
)
|
2022-07-30 17:54:40 +08:00
|
|
|
endif()
|
2022-02-18 09:15:37 +08:00
|
|
|
|
2021-09-28 02:36:44 +08:00
|
|
|
add_subdirectory(test)
|