Skip to content

Commit

Permalink
Redefine TorchMLIRPythonModules to avoid building empty libraries. (l…
Browse files Browse the repository at this point in the history
…lvm#3711)

Trying to build empty libraries causes weird failures based on clang/gcc
and doesn't work with certain versions of python as well. We should
avoid this wherever possible, and this specifically has been leading to
the following issues/failures:

llvm#3663

https://github.com/llvm/torch-mlir-release/actions/runs/10558518843/job/29248139823
  • Loading branch information
saienduri authored Sep 13, 2024
1 parent bc70c50 commit d6cf718
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ option(TORCH_MLIR_OUT_OF_TREE_BUILD "Specifies an out of tree build" OFF)
# But it will be manually enabled in CI build to enable the jit_ir_importer.build_tools.torch_ods_gen
# and abstract_interp_lib_gen.py. Once pure python version of build_tools finished, no need to set it in CI.
option(TORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS "Enables PyTorch native extension features" OFF)
if(TORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS)
add_definitions(-DTORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS)
endif()
# NOTE: The JIT_IR_IMPORTER paths have become unsupportable due to age and lack of maintainers.
# Turning this off disables the old TorchScript path, leaving FX based import as the current supported option.
# The option will be retained for a time, and if a maintainer is interested in setting up testing for it,
Expand Down
10 changes: 6 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,18 @@ set(_source_components
TorchMLIRPythonSources
TorchMLIRPythonExtensions
TorchMLIRSiteInitialize

# Sources related to optional Torch extension dependent features. Typically
# empty unless if project features are enabled.
TorchMLIRPythonTorchExtensionsSources
)

if(TORCH_MLIR_ENABLE_STABLEHLO)
list(APPEND _source_components StablehloPythonExtensions)
endif()

# Sources related to optional Torch extension dependent features. Typically
# empty unless if project features are enabled.
if(TORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS)
list(APPEND _source_components TorchMLIRPythonTorchExtensionsSources)
endif()

add_mlir_python_common_capi_library(TorchMLIRAggregateCAPI
INSTALL_COMPONENT TorchMLIRPythonModules
INSTALL_DESTINATION python_packages/torch_mlir/torch_mlir/_mlir_libs
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _check_env_flag(name: str, default=None) -> bool:
# If true, enable LTC build by default
TORCH_MLIR_ENABLE_LTC = _check_env_flag("TORCH_MLIR_ENABLE_LTC", True)
TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS = _check_env_flag(
"TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS", False
"TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS", True
)
LLVM_INSTALL_DIR = os.getenv("LLVM_INSTALL_DIR", None)
SRC_DIR = pathlib.Path(__file__).parent.absolute()
Expand Down

0 comments on commit d6cf718

Please sign in to comment.