-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] support out of tree dialects and passes for python interface #234
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some quick feedback about the format.
Still reviewing the details.
@@ -0,0 +1,35 @@ | |||
from buddy_mlir.ir import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Lit and FileCheck to test the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run ninja check-buddy
,I got an error like this.
check:37'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4: ModuleNotFoundError: No module named 'buddy_mlir'
I think this is because we don't export the right python path. The CMakeLists.txt tells us the BUDDY_MLIR_PYTHON_PACKAGES_DIR
is ${BUDDY_BUILD_DIR}/python_packages
Line 89 in ce466ba
set(BUDDY_MLIR_PYTHON_PACKAGES_DIR ${BUDDY_BUILD_DIR}/python_packages) |
And
config.buddy_python_packages_dir
equals to BUDDY_MLIR_PYTHON_PACKAGES_DIR
.buddy-mlir/tests/lit.site.cfg.py.in
Lines 37 to 39 in ce466ba
config.buddy_mlir_enable_python_packages = "@BUDDY_MLIR_ENABLE_PYTHON_PACKAGES@" | |
config.buddy_python_packages_dir = "@BUDDY_MLIR_PYTHON_PACKAGES_DIR@" | |
config.mlir_runner_utils_dir = "@LLVM_LIBS_DIR@" |
However, I set generated python packages to
${BUDDY_BUILD_DIR}/midend/python_packages/mlir_core
.
And when I add this path to config.buddy_mlir_enable_python_packages, it works. So we need only one path finally.
Lines 91 to 105 in ce466ba
if config.buddy_mlir_enable_python_packages: | |
llvm_config.with_environment( | |
"PYTHONPATH", | |
[ | |
os.path.join( | |
config.llvm_build_dir, | |
"tools", | |
"mlir", | |
"python_packages", | |
"mlir_core", | |
), | |
config.buddy_python_packages_dir, | |
], | |
append_path=True, | |
) |
Add support for out of tree dialects and passes python interface.
Note: Pybind is needed.
Please follow these commands
Then you can import our dialects and passes using python, an example is
tests/Python/test_python.py