Skip to content

A staging ground for MLIR dialects and tools.

License

Notifications You must be signed in to change notification settings

drprajap/mlir-extensions

 
 

Repository files navigation

Intel Extension for MLIR

A staging ground for MLIR dialects and tools.

Python frontend

Python frontend provides set of decorators similar to Numba decorators to compile python code.

Example:

from numba_dpcomp import njit
import numpy as np

@njit
def foo(a, b):
    return a + b

result = foo(np.array([1,2,3]), np.array([4,5,6]))
print(result)

Building and testing Python frontend

You will need LLVM built from specific commit, found in llvm-sha.txt.

Linux

Building llvm

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
git checkout $SHA
cd ..
mkdir llvm-build
cd llvm-build
cmake ../llvm-project/llvm -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_USE_LINKER=gold -DLLVM_INSTALL_UTILS=ON -DCMAKE_INSTALL_PREFIX=../llvm-install
ninja install

Getting TBB

wget -O tbb.tgz "https://github.com/oneapi-src/oneTBB/releases/download/v2021.5.0/oneapi-tbb-2021.5.0-lin.tgz"
mkdir tbb
tar -xf "tbb.tgz" -C tbb --strip-components=1

Getting Level Zero loader (Optional, needed for GPU support)

git clone https://github.com/oneapi-src/level-zero.git
cd level-zero
git checkout v1.6.2
cd ..
mkdir level-zero-build
cmake ../level-zero -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../level-zero-install
ninja install

Building and testing Python package

cd numba_dpcomp
conda create -n test-env python=3.9 numba=0.54 numpy=1.20 scikit-learn pytest-xdist ninja scipy pybind11 pytest lit tbb=2021.5.0 cmake -c conda-forge
conda activate test-env
export TBB_PATH=<...>/tbb
export LLVM_PATH=<...>/llvm-install
export LEVEL_ZERO_DIR=<...>/level-zero-install # Optional
export LEVEL_ZERO_VERSION_CHECK_OFF=1 # Optional
python setup.py develop
pytest -n8 --capture=tee-sys -rXF

Windows

TBD

About

A staging ground for MLIR dialects and tools.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 69.0%
  • Python 25.7%
  • CMake 2.7%
  • MLIR 2.6%