mirror of https://github.com/llvm/torch-mlir
Set some wheel building optimization options.
* Also adds a requirements.txt and updates docs to reference it versus stringy pip install. * Adds doc with instructions on creating a wheel. Fixes #370pull/377/head
parent
92ae692387
commit
a23d77100b
|
@ -4,6 +4,7 @@
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
.ipynb_checkpoints
|
.ipynb_checkpoints
|
||||||
*.venv/
|
*.venv/
|
||||||
|
mlir_venv/
|
||||||
|
|
||||||
/build/
|
/build/
|
||||||
__pycache__
|
__pycache__
|
||||||
|
|
15
README.md
15
README.md
|
@ -46,8 +46,8 @@ python -m venv mlir_venv
|
||||||
source mlir_venv/bin/activate
|
source mlir_venv/bin/activate
|
||||||
# Some older pip installs may not be able to handle the recent PyTorch deps
|
# Some older pip installs may not be able to handle the recent PyTorch deps
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
# Install latest PyTorch nightlies
|
# Install latest PyTorch nightlies and build requirements.
|
||||||
python -m pip install --pre torch torchvision pybind11 -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
|
python -m pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
@ -178,3 +178,14 @@ manually `source`'d in a shell.
|
||||||
- `#torch-mlir` channel on the LLVM [Discord](https://discord.gg/xS7Z362)
|
- `#torch-mlir` channel on the LLVM [Discord](https://discord.gg/xS7Z362)
|
||||||
- Issues [here](https://github.com/llvm/torch-mlir/issues)
|
- Issues [here](https://github.com/llvm/torch-mlir/issues)
|
||||||
- [`torch-mlir` section](https://llvm.discourse.group/c/projects-that-want-to-become-official-llvm-projects/torch-mlir/41) of LLVM Discourse
|
- [`torch-mlir` section](https://llvm.discourse.group/c/projects-that-want-to-become-official-llvm-projects/torch-mlir/41) of LLVM Discourse
|
||||||
|
|
||||||
|
## Build Python Packages
|
||||||
|
|
||||||
|
We have preliminary support for building Python packages. This can be done
|
||||||
|
with the following commands:
|
||||||
|
|
||||||
|
```
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install -r requirements.txt
|
||||||
|
CMAKE_GENERATOR=Ninja python setup.py bdist_wheel
|
||||||
|
```
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
include(AddMLIRPython)
|
include(AddMLIRPython)
|
||||||
|
|
||||||
|
# Disables generation of "version soname" (i.e. libFoo.so.<version>), which
|
||||||
|
# causes pure duplication as part of Python wheels.
|
||||||
|
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON)
|
||||||
|
|
||||||
# The directory at which the Python import tree begins.
|
# The directory at which the Python import tree begins.
|
||||||
# See documentation for `declare_mlir_python_sources`'s ROOT_DIR
|
# See documentation for `declare_mlir_python_sources`'s ROOT_DIR
|
||||||
# argument.
|
# argument.
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
-f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
|
||||||
|
--pre
|
||||||
|
|
||||||
|
numpy
|
||||||
|
torch
|
||||||
|
torchvision
|
||||||
|
|
||||||
|
# Build requirements.
|
||||||
|
pybind11
|
||||||
|
wheel
|
4
setup.py
4
setup.py
|
@ -64,6 +64,10 @@ class CMakeBuild(build_py):
|
||||||
f"-DLLVM_ENABLE_PROJECTS=mlir",
|
f"-DLLVM_ENABLE_PROJECTS=mlir",
|
||||||
f"-DLLVM_EXTERNAL_PROJECTS=torch-mlir",
|
f"-DLLVM_EXTERNAL_PROJECTS=torch-mlir",
|
||||||
f"-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR={src_dir}",
|
f"-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR={src_dir}",
|
||||||
|
# Optimization options for building wheels.
|
||||||
|
f"-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON",
|
||||||
|
f"-DCMAKE_C_VISIBILITY_PRESET=hidden",
|
||||||
|
f"-DCMAKE_CXX_VISIBILITY_PRESET=hidden",
|
||||||
]
|
]
|
||||||
os.makedirs(cmake_build_dir, exist_ok=True)
|
os.makedirs(cmake_build_dir, exist_ok=True)
|
||||||
cmake_cache_file = os.path.join(cmake_build_dir, "CMakeCache.txt")
|
cmake_cache_file = os.path.join(cmake_build_dir, "CMakeCache.txt")
|
||||||
|
|
Loading…
Reference in New Issue