2020-04-27 06:50:23 +08:00
|
|
|
# npcomp - An aspirational MLIR based numpy compiler
|
|
|
|
|
2020-04-27 11:14:20 +08:00
|
|
|
This is a research prototype of MLIR dialects for representing
|
|
|
|
numpy programs, and a set of reference tracing/compiler tools.
|
2020-04-27 06:50:23 +08:00
|
|
|
|
2020-04-27 07:32:10 +08:00
|
|
|
## Quick start
|
2020-04-27 06:50:23 +08:00
|
|
|
|
2020-04-27 07:32:10 +08:00
|
|
|
```
|
|
|
|
export LLVM_SRC_DIR=/path/to/llvm-project
|
|
|
|
./tools/install_mlir.sh
|
|
|
|
./tools/cmake_configure.sh
|
|
|
|
|
|
|
|
cd build
|
|
|
|
ninja
|
|
|
|
./python/run_tests.py
|
2020-04-27 06:50:23 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### Installing pybind11
|
|
|
|
|
|
|
|
The native extension relies on pybind11. In a perfect world, this could just
|
|
|
|
be installed with your system package manager. However, at least on
|
2020-04-27 11:14:20 +08:00
|
|
|
some tested versions of Ubuntu, the system package installed with broken cmake
|
|
|
|
files.
|
2020-04-27 06:50:23 +08:00
|
|
|
|
2020-04-27 11:14:20 +08:00
|
|
|
If this happens, you must install pybind11 from source.
|
2020-04-27 06:50:23 +08:00
|
|
|
|
|
|
|
### Building the python native library
|
|
|
|
|
|
|
|
```shell
|
|
|
|
# From the build directory
|
|
|
|
ninja NPCOMPNativePyExt
|
2020-04-27 11:14:20 +08:00
|
|
|
ninja check-npcomp
|
|
|
|
python3 ./python/run_tests.py
|
|
|
|
|
|
|
|
# Setup PYTHONPATH for interactive use.
|
2020-04-27 06:50:23 +08:00
|
|
|
export PYTHONPATH=$(pwd)/tools/npcomp/python
|
|
|
|
```
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
|
|
|
|
* Python sources are symlinked to the output directory at configure time.
|
|
|
|
Adding sources will require a reconfigure. Editing should not.
|
|
|
|
* It is a very common issue to have both python 2.7 (aka. "python") and python
|
|
|
|
3.x (aka. "python3") on a system at a time (and we can only hope that one
|
|
|
|
day this ends). Since the native library at development time binds to a
|
|
|
|
specific version, if you try to run with a different python, you will get
|
|
|
|
an error about the "native" module not being found.
|
2020-04-27 11:14:20 +08:00
|
|
|
|