The Torch-MLIR project aims to provide first class support from the PyTorch ecosystem to the MLIR ecosystem.
 
 
 
 
 
 
Go to file
Stella Laurenzo bc5ef81d68 Add basicpy.SlotObject type and ops to create/index into it.
* This is intended to provide low-level modeling for built-in objects.
* It is now possible to trace slice tuples (which are tuples of NoneType|EllipsisType|SlotObjectType<slice, ...>).
2020-05-05 18:16:01 -07:00
include/npcomp Add basicpy.SlotObject type and ops to create/index into it. 2020-05-05 18:16:01 -07:00
lib Add basicpy.SlotObject type and ops to create/index into it. 2020-05-05 18:16:01 -07:00
python Create skeleton for 'Basicpy' dialect. 2020-05-04 17:48:02 -07:00
test Add basicpy.SlotObject type and ops to create/index into it. 2020-05-05 18:16:01 -07:00
tools Create skeleton for 'Basicpy' dialect. 2020-05-04 17:48:02 -07:00
.clang-format Add stub numpy dialect. 2020-04-26 17:20:58 -07:00
.gitignore Add stub numpy dialect. 2020-04-26 17:20:58 -07:00
CMakeLists.txt Add npcomp-opt and lit runner. 2020-04-26 17:55:15 -07:00
LICENSE Add license 2020-04-26 20:10:24 -07:00
README.md Add known good llvm-project commit hash to readme. 2020-05-05 14:00:06 -07:00
contributing.md Add contributing.md 2020-04-26 20:17:16 -07:00

README.md

npcomp - An aspirational MLIR based numpy compiler

This is a research prototype of MLIR dialects for representing numpy programs, and a set of reference tracing/compiler tools. The primary purpose at this point is to establish a solid modeling of restricted Python programs and Numpy based computations in MLIR. While this project will provide some reference implementations to prove the design, the intention is to align this with the broader set of tools that exist at this level of abstraction.

Design Notes

As I work through things, I've been jotting down some design notes:

Quick start

LLVM_VERSION=10
export CC=clang-$LLVM_VERSION
export CXX=clang++-$LLVM_VERSION
export LDFLAGS=-fuse-ld=$(which ld.lld-$LLVM_VERSION)
export LLVM_SRC_DIR=/path/to/llvm-project

# Check out last known good commit.
(cd $LLVM_SRC_DIR && git checkout 26777ad7a0916ad7853aa9229bb8ec0346c68a61)

./tools/install_mlir.sh
./tools/cmake_configure.sh

cd build
ninja
ninja check-npcomp-opt
# Note: currently, python tests run separately
./python/run_tests.py

Things to look at:

  • python/npcomp/tracing/mlir_trace_test.py : Simple test case of tracing a function to an MLIR module.

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 some tested versions of Ubuntu, the system package installed with broken cmake files.

If this happens, you must install pybind11 from source.

Building the python native library

# From the build directory
ninja NPCOMPNativePyExt
ninja check-npcomp
python3 ./python/run_tests.py

# Setup PYTHONPATH for interactive use.
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.