-
Notifications
You must be signed in to change notification settings - Fork 639
Update docs and .env file to reflect PYTHONPATH variability #4332
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
base: main
Are you sure you want to change the base?
Changes from all commits
8fde78e
493696f
6978352
3c9a1f8
09de7e5
54a63f8
884a062
3e943b6
41fdb38
55446dc
063d26a
c14a5a2
a86a4eb
ad97a18
cf8a615
0f97763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -194,30 +194,48 @@ TIP: add multiple target options to stack build phases | |||
|
||||
### Setup Python Environment to export the built Python packages | ||||
|
||||
When CMake is configured with `-DMLIR_ENABLE_BINDINGS_PYTHON=ON`, the python packages will typically be located in either: | ||||
|
||||
1. `./build/tools/torch-mlir/python_packages/` if doing an in-tree build. | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't the setting of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose it doesn't need any updating. Hardcoding the Although it does make sense that a developer could come around, customize their build script to do out-of-tree, and then run the CI script to debug a ci failure locally. I'm happy to change this if you think it would be helpful. |
||||
2. `./build/python_packages/` if doing an out-of-tree build. | ||||
|
||||
For the following sections, let `python_pkg_dir` represent whichever of the above is relevant for your build setup. On Linux and macOS, you can run `./build_tools/write_env_file.sh` to generate a file `./.env` in your root source directory with the correct `PYTHONPATH`. | ||||
|
||||
#### Linux and macOS | ||||
|
||||
To get the base `PYTHONPATH`, run: | ||||
|
||||
```shell | ||||
export PYTHONPATH=`pwd`/build/python_packages/torch_mlir:`pwd`/test/python/fx_importer | ||||
./build_tools/write_env_file.sh | ||||
source ./.env && export PYTHONPATH | ||||
``` | ||||
|
||||
To run fx_importer tests, you can append the following: | ||||
|
||||
``` | ||||
export PYTHONPATH="${PYTHONPATH}":/test/python/fx_importer" | ||||
``` | ||||
|
||||
#### Windows PowerShell | ||||
|
||||
To get the base `PYTHONPATH`, identify your `python_pkg_dir` from above and set this variable in your environment: | ||||
|
||||
```shell | ||||
$env:PYTHONPATH = "<python_pkg_dir>/torch-mlir" | ||||
``` | ||||
|
||||
To run fx_importer tests, you can append the following: | ||||
|
||||
```shell | ||||
$env:PYTHONPATH = "$PWD/build/tools/torch-mlir/python_packages/torch_mlir;$PWD/test/python/fx_importer" | ||||
$env:PYTHONPATH += ";$PWD/test/python/fx_importer" | ||||
``` | ||||
|
||||
### Testing MLIR output in various dialects | ||||
|
||||
To test the MLIR output to torch dialect, you can use `test/python/fx_importer/basic_test.py`. | ||||
|
||||
Make sure you have activated the virtualenv and set the `PYTHONPATH` above | ||||
(if running on Windows, modify the environment variable as shown above): | ||||
|
||||
```shell | ||||
source mlir_venv/bin/activate | ||||
export PYTHONPATH=`pwd`/build/tools/torch-mlir/python_packages/torch_mlir:`pwd`/test/python/fx_importer | ||||
python test/python/fx_importer/basic_test.py | ||||
``` | ||||
(if running on Windows, modify the environment variable as shown above). | ||||
|
||||
This will display the basic example in TORCH dialect. | ||||
|
||||
|
@@ -226,10 +244,10 @@ using torchscript with the example `projects/pt1/examples/torchscript_resnet18_a | |||
This path doesn't give access to the current generation work that is being driven via the fx_importer | ||||
and may lead to errors. | ||||
|
||||
Same as above, but with different python path and example: | ||||
The base `PYTHONPATH` should be set as above, then the example can be run with the following command (similar on Windows): | ||||
|
||||
```shell | ||||
export PYTHONPATH=`pwd`/build/tools/torch-mlir/python_packages/torch_mlir:`pwd`/projects/pt1/examples | ||||
export PYTHONPATH="${PYTHONPATH}:$PWD/projects/pt1/examples" | ||||
python projects/pt1/examples/torchscript_resnet18_all_output_types.py | ||||
``` | ||||
|
||||
|
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.
I am not sure if that logic is desired here or if it should be an external argument?
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.
Whether the build was in-tree/out-of-tree?
Yeah, we could make it take a command line arg and error out if the dir is missing, but just checking both seems fine to me, and aligns with the other two scripts that need to set a
PYTHONPATH
.