Cache torch_mlir Prefix as CMake Variable#4518
Conversation
Signed-off-by: Jinjie Liu <jjliu@baai.ac.cn>
There was a problem hiding this comment.
Pull request overview
Introduces a configurable CMake cache variable to control the Python package prefix used by the MLIR Python bindings, replacing a previously hardcoded prefix in the Python build.
Changes:
- Added
TORCH_MLIR_PYTHON_PACKAGE_PREFIXas a CMake cache string (default:torch_mlir.). - Updated
python/CMakeLists.txtto use the new cache variable when settingMLIR_PYTHON_PACKAGE_PREFIX.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| CMakeLists.txt | Defines the new cache variable for the MLIR Python package prefix. |
| python/CMakeLists.txt | Uses the cache variable for the MLIR_PYTHON_PACKAGE_PREFIX compile definition. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| option(TORCH_MLIR_ENABLE_WERROR_FLAG "Enable `-Werror` flag on supported directories, treat warning as error" OFF) | ||
| option(TORCH_MLIR_USE_INSTALLED_PYTORCH "If depending on PyTorch use it as installed in the current Python environment" ON) | ||
| set(TORCH_MLIR_PYTHON_PACKAGE_PREFIX "torch_mlir." CACHE STRING | ||
| "Python package prefix used for MLIR python bindings in torch-mlir") |
There was a problem hiding this comment.
TORCH_MLIR_PYTHON_PACKAGE_PREFIX is introduced as the configurable prefix, but MLIR_PYTHON_PACKAGE_PREFIX is still hardcoded to torch_mlir. in projects/pt1/python/CMakeLists.txt. This makes prefix customization inconsistent depending on which Python bindings are built. Consider updating that CMakeLists (and any other occurrences) to use TORCH_MLIR_PYTHON_PACKAGE_PREFIX as well so the cache variable applies across the build system.
| "Python package prefix used for MLIR python bindings in torch-mlir") | |
| "Python package prefix used for MLIR python bindings in torch-mlir") | |
| set(MLIR_PYTHON_PACKAGE_PREFIX "${TORCH_MLIR_PYTHON_PACKAGE_PREFIX}" CACHE STRING | |
| "Python package prefix used for MLIR python bindings (legacy variable, kept for compatibility)") |
This pull request introduces a new configurable CMake variable for the Python package prefix used in MLIR Python bindings, improving flexibility and maintainability in how the prefix is set across the build system.
Configuration improvements:
TORCH_MLIR_PYTHON_PACKAGE_PREFIXinCMakeLists.txtto allow customization of the Python package prefix for MLIR bindings, defaulting to"torch_mlir.".python/CMakeLists.txtto use the newTORCH_MLIR_PYTHON_PACKAGE_PREFIXvariable in theadd_compile_definitionscall, replacing the previously hardcoded value.