Skip to content

Cache torch_mlir Prefix as CMake Variable#4518

Open
sgjzfzzf wants to merge 1 commit intollvm:mainfrom
sgjzfzzf:main
Open

Cache torch_mlir Prefix as CMake Variable#4518
sgjzfzzf wants to merge 1 commit intollvm:mainfrom
sgjzfzzf:main

Conversation

@sgjzfzzf
Copy link
Copy Markdown

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:

  • Added a new CMake cache variable TORCH_MLIR_PYTHON_PACKAGE_PREFIX in CMakeLists.txt to allow customization of the Python package prefix for MLIR bindings, defaulting to "torch_mlir.".
  • Updated python/CMakeLists.txt to use the new TORCH_MLIR_PYTHON_PACKAGE_PREFIX variable in the add_compile_definitions call, replacing the previously hardcoded value.

Signed-off-by: Jinjie Liu <jjliu@baai.ac.cn>
Copilot AI review requested due to automatic review settings March 30, 2026 09:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_PREFIX as a CMake cache string (default: torch_mlir.).
  • Updated python/CMakeLists.txt to use the new cache variable when setting MLIR_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")
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"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)")

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants