├── benchmarks └── benchmarks │ ├── __init__.py │ ├── npbench │ ├── __init__.py │ ├── crc16 │ │ ├── __init__.py │ │ ├── config.toml │ │ ├── numpy.py │ │ ├── numba.py │ │ └── numba_mlir.py │ ├── nbody │ │ ├── __init__.py │ │ ├── config.toml │ │ ├── numpy.py │ │ └── numba_mlir.py │ ├── spmv │ │ ├── __init__.py │ │ ├── config.toml │ │ ├── numpy.py │ │ ├── numba.py │ │ └── numba_mlir.py │ ├── cavity_flow │ │ ├── __init__.py │ │ └── config.toml │ ├── compute │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ ├── go_fast │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ ├── mandelbrot1 │ │ ├── __init__.py │ │ └── config.toml │ ├── mandelbrot2 │ │ ├── __init__.py │ │ └── config.toml │ ├── pythran │ │ ├── __init__.py │ │ └── arc_distance │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ ├── numba.py │ │ │ └── numba_mlir.py │ ├── azimint_hist │ │ ├── __init__.py │ │ └── config.toml │ ├── azimint_naive │ │ ├── __init__.py │ │ └── config.toml │ ├── channel_flow │ │ ├── __init__.py │ │ └── config.toml │ ├── contour_integral │ │ ├── __init__.py │ │ ├── config.toml │ │ ├── numpy.py │ │ ├── numba.py │ │ ├── numba_mlir.py │ │ └── numba_replace_parfor.py │ ├── deep_learning │ │ ├── __init__.py │ │ ├── lenet │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ ├── numba.py │ │ │ └── numba_mlir.py │ │ ├── mlp │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ ├── numba.py │ │ │ ├── numba_mlir.py │ │ │ └── numba_replace_parfor.py │ │ ├── resnet │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba_mlir.py │ │ ├── softmax │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ ├── numba_mlir.py │ │ │ └── numba.py │ │ └── conv2d_bias │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ ├── numba.py │ │ │ └── numba_mlir.py │ ├── stockham_fft │ │ ├── __init__.py │ │ ├── config.toml │ │ ├── numpy.py │ │ ├── numba.py │ │ ├── numba_mlir.py │ │ └── numba_replace_parfor.py │ ├── weather_stencils │ │ ├── __init__.py │ │ ├── vadv │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ └── hdiff │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ └── scattering_self_energies │ │ ├── __init__.py │ │ ├── config.toml │ │ ├── numpy.py │ │ ├── numba.py │ │ ├── numba_mlir.py │ │ └── numba_replace_parfor.py │ ├── polybench │ ├── __init__.py │ ├── medley │ │ ├── __init__.py │ │ ├── deriche │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba.py │ │ ├── nussinov │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba.py │ │ └── floyd_warshall │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ ├── stencils │ │ ├── __init__.py │ │ ├── adi │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── fdtd_2d │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── heat_3d │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba.py │ │ ├── jacobi_1d │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba.py │ │ ├── jacobi_2d │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba.py │ │ └── seidel_2d │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ ├── datamining │ │ ├── __init__.py │ │ ├── correlation │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ └── covariance │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ └── linear_algebra │ │ ├── __init__.py │ │ ├── blas │ │ ├── __init__.py │ │ ├── gemm │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba.py │ │ ├── symm │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba.py │ │ ├── syrk │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── trmm │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── gemver │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ ├── numpy.py │ │ │ └── numba.py │ │ ├── gesummv │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ └── syr2k │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── kernels │ │ ├── __init__.py │ │ ├── atax │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── bicg │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── k2mm │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── k3mm │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ ├── mvt │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ └── doitgen │ │ │ ├── __init__.py │ │ │ ├── config.toml │ │ │ └── numpy.py │ │ └── solvers │ │ ├── __init__.py │ │ ├── durbin │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ │ ├── lu │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ │ ├── ludcmp │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ │ ├── cholesky │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ │ ├── cholesky2 │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ │ ├── gramschmidt │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ │ └── trisolv │ │ ├── __init__.py │ │ ├── config.toml │ │ └── numpy.py │ └── microbenchmarks │ ├── __init__.py │ ├── dispatcher │ └── __init__.py │ └── kernel_dispatcher │ └── __init__.py ├── .clang-format ├── llvm-sha.txt ├── scripts ├── mkl.env ├── numba-mlir.env ├── runlit.py ├── vcvars.ps1 ├── core-env-win.yml ├── core-env-linux.yml └── bench-env-linux.yml ├── numba_mlir ├── numba_mlir │ ├── mlir_compiler │ │ ├── export_darwin.txt │ │ ├── export.txt │ │ └── lib │ │ │ ├── PyModule.hpp │ │ │ ├── pipelines │ │ │ ├── LowerToGpuTypeConversion.hpp │ │ │ ├── PlierToStdTypeConversion.hpp │ │ │ ├── PlierToLinalgTypeConversion.hpp │ │ │ ├── PlierToScf.hpp │ │ │ ├── PlierToStd.hpp │ │ │ ├── ParallelToTbb.hpp │ │ │ ├── LowerToLlvm.hpp │ │ │ ├── PlierToLinalg.hpp │ │ │ ├── LowerToGpu.hpp │ │ │ ├── BasePipeline.hpp │ │ │ ├── PreLowSimplifications.hpp │ │ │ └── BasePipeline.cpp │ │ │ ├── Mangle.hpp │ │ │ ├── CheckGpuCaps.hpp │ │ │ ├── PyMapTypes.hpp │ │ │ ├── PyTypeConverter.hpp │ │ │ ├── PyTypeConverter.cpp │ │ │ └── CheckGpuCaps.cpp │ ├── mlir │ │ ├── dpnp │ │ │ └── __init__.py │ │ ├── numpy │ │ │ └── __init__.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ └── conftest.py │ │ ├── builtin │ │ │ └── __init__.py │ │ ├── __init__.py │ │ ├── numba_runtime.py │ │ ├── compiler_context.py │ │ ├── python_rt.py │ │ ├── README.md │ │ ├── runtime.py │ │ └── settings.py │ ├── __init__.py │ ├── math_runtime │ │ ├── lib │ │ │ └── Common.cpp │ │ └── include │ │ │ └── Common.hpp │ ├── python_runtime │ │ ├── lib │ │ │ └── PythonRt.hpp │ │ └── CMakeLists.txt │ └── kernel.py ├── conda-recipe │ ├── conda_build_config.yaml │ ├── build.sh │ └── bld.bat ├── CMakeLists.txt ├── setup.cfg ├── build_sycl_runtime_standalone.py ├── MANIFEST.in └── setup.py ├── numba_mlir_gpu_common └── export.txt ├── .gitattributes ├── mlir ├── tools │ ├── CMakeLists.txt │ └── numba-mlir-opt │ │ └── Main.cpp ├── test │ ├── L0_RUNNER │ │ └── lit.local.cfg │ ├── Transforms │ │ └── set-spirv-abi-attr.mlir │ ├── Dialect │ │ └── gpu_runtime │ │ │ └── canonicalize.mlir │ └── CMakeLists.txt ├── include │ ├── numba │ │ ├── Conversion │ │ │ ├── GpuAttributes.hpp │ │ │ ├── CfgToScf.hpp │ │ │ ├── SCFToAffine │ │ │ │ └── SCFToAffine.h │ │ │ ├── MathExtToLibm.hpp │ │ │ ├── UtilConversion.hpp │ │ │ ├── NtensorToMemref.hpp │ │ │ ├── NtensorToLinalg.hpp │ │ │ ├── UtilToLlvm.hpp │ │ │ └── GpuRuntimeToLlvm.hpp │ │ ├── Transforms │ │ │ ├── InlineUtils.hpp │ │ │ ├── CopyRemoval.hpp │ │ │ ├── IndexTypePropagation.hpp │ │ │ ├── ExpandTuple.hpp │ │ │ ├── IfRewrites.hpp │ │ │ ├── LoopRewrites.hpp │ │ │ ├── FuncTransforms.hpp │ │ │ ├── CanonicalizeReductions.hpp │ │ │ ├── ShapeIntegerRangePropagation.hpp │ │ │ ├── LoopUtils.hpp │ │ │ ├── PipelineUtils.hpp │ │ │ ├── UpliftMath.hpp │ │ │ ├── PromoteBoolMemref.hpp │ │ │ ├── CompositePass.hpp │ │ │ ├── MemoryRewrites.hpp │ │ │ ├── CommonOpts.hpp │ │ │ ├── PromoteToParallel.hpp │ │ │ ├── MakeSignless.hpp │ │ │ ├── TypeConversion.hpp │ │ │ ├── ConstUtils.hpp │ │ │ ├── CastLowering.hpp │ │ │ └── CastUtils.hpp │ │ ├── Dialect │ │ │ ├── ntensor │ │ │ │ └── Transforms │ │ │ │ │ ├── PropagateEnvironment.hpp │ │ │ │ │ └── ResolveArrayOps.hpp │ │ │ ├── gpu_runtime │ │ │ │ └── Transforms │ │ │ │ │ └── MakeBarriersUniform.hpp │ │ │ └── plier │ │ │ │ └── CMakeLists.txt │ │ ├── Utils.hpp │ │ └── Analysis │ │ │ └── MemorySsaAnalysis.hpp │ └── legacy │ │ └── Dialect │ │ ├── Linalg │ │ └── Transforms │ │ │ ├── Passes.h │ │ │ ├── CMakeLists.txt │ │ │ └── Passes.td │ │ ├── Tensor │ │ └── Transforms │ │ │ ├── Passes.h │ │ │ ├── CMakeLists.txt │ │ │ └── Passes.td │ │ ├── Arith │ │ └── Transforms │ │ │ ├── Passes.h │ │ │ └── CMakeLists.txt │ │ └── Bufferization │ │ └── Transforms │ │ ├── Passes.h │ │ ├── CMakeLists.txt │ │ └── Passes.td └── lib │ └── Utils.cpp ├── CITATION.bib ├── numba_mlir_runtime ├── lib │ └── AllocToken.cpp └── CMakeLists.txt ├── .github ├── pull_request_template.md └── workflows │ └── pre-commit.yml ├── numba_mlir_gpu_runtime_sycl └── lib │ ├── Utils.hpp │ └── GpuModule.hpp ├── patches └── llvm.diff └── .pre-commit-config.yaml /benchmarks/benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/crc16/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/nbody/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/spmv/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/microbenchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/cavity_flow/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/compute/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/go_fast/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/mandelbrot1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/mandelbrot2/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/pythran/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/azimint_hist/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/azimint_naive/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/channel_flow/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/contour_integral/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/stockham_fft/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/weather_stencils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/datamining/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/deriche/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/adi/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /llvm-sha.txt: -------------------------------------------------------------------------------- 1 | b1edac0496f47374c9780f3f83c6773eed73a66e 2 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/microbenchmarks/dispatcher/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/lenet/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/mlp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/resnet/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/softmax/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/pythran/arc_distance/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/weather_stencils/vadv/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/nussinov/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/fdtd_2d/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/heat_3d/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/jacobi_1d/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/jacobi_2d/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/seidel_2d/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/microbenchmarks/kernel_dispatcher/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/conv2d_bias/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/scattering_self_energies/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/weather_stencils/hdiff/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/datamining/correlation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/datamining/covariance/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gemm/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/symm/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/syrk/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/trmm/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/floyd_warshall/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/mkl.env: -------------------------------------------------------------------------------- 1 | mkl 2 | mkl-devel 3 | mkl-devel-dpcpp=2024.2 4 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gemver/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gesummv/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/syr2k/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/atax/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/bicg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/k2mm/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/k3mm/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/mvt/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/durbin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/lu/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/ludcmp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/doitgen/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/cholesky/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/cholesky2/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/gramschmidt/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/trisolv/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/export_darwin.txt: -------------------------------------------------------------------------------- 1 | _PyInit_mlir_compiler 2 | -------------------------------------------------------------------------------- /numba_mlir_gpu_common/export.txt: -------------------------------------------------------------------------------- 1 | { 2 | global: gpux*; 3 | local: *; 4 | }; 5 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/export.txt: -------------------------------------------------------------------------------- 1 | { 2 | global: PyInit_mlir_compiler; 3 | local: *; 4 | }; 5 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/dpnp/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/numpy/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/builtin/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | numba_mlir/_version.py export-subst 6 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/PyModule.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | -------------------------------------------------------------------------------- /mlir/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | add_subdirectory(level_zero_runner) 6 | add_subdirectory(numba-mlir-opt) 7 | -------------------------------------------------------------------------------- /CITATION.bib: -------------------------------------------------------------------------------- 1 | @software{numbamlir, 2 | author = {Ivan Butygin, Diptorup Deb, Alexander Kalistratov}, 3 | title = {{numba-mlir}: MLIR-based numba backend}, 4 | url = {https://github.com/numba/numba-mlir}, 5 | year = {2023}, 6 | } 7 | -------------------------------------------------------------------------------- /mlir/test/L0_RUNNER/lit.local.cfg: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | config.unsupported = not bool(int(os.environ.get('NUMBA_MLIR_ENABLE_GPU_E2E_TESTS', 0))) 4 | 5 | local_excludes = ['linalg_test_f64.mlir'] 6 | config.excludes.update(local_excludes) 7 | -------------------------------------------------------------------------------- /numba_mlir/conda-recipe/conda_build_config.yaml: -------------------------------------------------------------------------------- 1 | cxx_compiler: 2 | - vs2019 # [win] 3 | numpy: 4 | - 1.23 5 | pin_run_as_build: 6 | https://software.repos.intel.com/python/conda/::dpcpp-cpp-rt: x.x 7 | mkl: x.x 8 | mkl-dpcpp: x.x 9 | -------------------------------------------------------------------------------- /scripts/numba-mlir.env: -------------------------------------------------------------------------------- 1 | pip>=22 2 | numba=0.60.0 3 | numpy=1.24 4 | setuptools<65.6 5 | scikit-learn 6 | pytest-xdist 7 | ninja 8 | scipy 9 | pybind11 10 | pytest 11 | tbb 12 | tbb-devel 13 | lit 14 | cmake 15 | zlib 16 | level-zero-devel 17 | -------------------------------------------------------------------------------- /scripts/runlit.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | 6 | if __name__ == "__main__": 7 | import lit.main 8 | 9 | print("lit version: ", lit.__version__) 10 | lit.main.main() 11 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | from .decorators import * 6 | 7 | from . import _version 8 | 9 | __version__ = _version.get_versions()["version"] 10 | -------------------------------------------------------------------------------- /numba_mlir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | add_subdirectory(numba_mlir/python_runtime) 6 | add_subdirectory(numba_mlir/math_runtime) 7 | add_subdirectory(numba_mlir/mlir_compiler) 8 | -------------------------------------------------------------------------------- /scripts/vcvars.ps1: -------------------------------------------------------------------------------- 1 | pushd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\" 2 | cmd /c "vcvars64.bat & set" | 3 | foreach { 4 | if ($_ -match "=") { 5 | $v = $_.split("=", 2); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])" 6 | } 7 | } 8 | popd 9 | -------------------------------------------------------------------------------- /scripts/core-env-win.yml: -------------------------------------------------------------------------------- 1 | name: dev 2 | channels: 3 | - conda-forge 4 | - https://software.repos.intel.com/python/conda/ 5 | - nodefaults 6 | dependencies: 7 | - cmake 8 | - ninja 9 | - lit 10 | - zlib 11 | - vs2019_win-64 12 | - tbb-devel >=2021.10.0 13 | - level-zero-devel 14 | -------------------------------------------------------------------------------- /scripts/core-env-linux.yml: -------------------------------------------------------------------------------- 1 | name: dev 2 | channels: 3 | - conda-forge 4 | - https://software.repos.intel.com/python/conda/ 5 | - nodefaults 6 | dependencies: 7 | - cmake 8 | - ninja 9 | - lit 10 | - zlib 11 | - gxx_linux-64 12 | - tbb-devel >=2021.10.0 13 | - level-zero-devel 14 | -------------------------------------------------------------------------------- /numba_mlir/setup.cfg: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | [versioneer] 6 | VCS = git 7 | style = pep440 8 | versionfile_source = numba_mlir/_version.py 9 | versionfile_build = numba_mlir/_version.py 10 | tag_prefix = '' 11 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/LowerToGpuTypeConversion.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | class PyTypeConverter; 8 | 9 | void populateGpuTypeConverter(PyTypeConverter &converter); 10 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/PlierToStdTypeConversion.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | class PyTypeConverter; 8 | 9 | void populateStdTypeConverter(PyTypeConverter &converter); 10 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | from . import array_type 6 | from . import dpctl_interop 7 | from .builtin import funcs 8 | from .dpnp import funcs 9 | from .numpy import funcs, overloads 10 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/PlierToLinalgTypeConversion.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | class PyTypeConverter; 8 | 9 | void populateArrayTypeConverter(PyTypeConverter &converter); 10 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/GpuAttributes.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2024 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace gpu_runtime { 10 | 11 | mlir::StringRef getGpuBinaryAttrName(); 12 | 13 | } // namespace gpu_runtime 14 | -------------------------------------------------------------------------------- /mlir/lib/Utils.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include "numba/Utils.hpp" 6 | 7 | #include 8 | 9 | #include "llvm/ADT/Twine.h" 10 | 11 | void numba::reportError(const llvm::Twine &msg) { 12 | throw std::runtime_error(msg.str()); 13 | } 14 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/InlineUtils.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | } 12 | 13 | namespace numba { 14 | std::unique_ptr createForceInlinePass(); 15 | } 16 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/tests/conftest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | 6 | def pytest_configure(config): 7 | config.addinivalue_line("markers", "smoke") 8 | config.addinivalue_line("markers", "numba_parfor") 9 | config.addinivalue_line("markers", "test_gpu") 10 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/CopyRemoval.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | } 12 | 13 | namespace numba { 14 | std::unique_ptr createCopyRemovalPass(); 15 | } // namespace numba 16 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Linalg/Transforms/Passes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mlir/Pass/Pass.h" 4 | 5 | namespace mlir { 6 | namespace linalg { 7 | namespace legacy { 8 | /// Creates an instance of the `linalg` dialect bufferization pass. 9 | std::unique_ptr createLinalgBufferizePass(); 10 | 11 | } // namespace legacy 12 | } // namespace linalg 13 | } // namespace mlir 14 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Tensor/Transforms/Passes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mlir/Pass/Pass.h" 4 | 5 | namespace mlir { 6 | namespace tensor { 7 | namespace legacy { 8 | /// Creates an instance of the `tensor` dialect bufferization pass. 9 | std::unique_ptr createTensorBufferizePass(); 10 | 11 | } // namespace legacy 12 | } // namespace tensor 13 | } // namespace mlir 14 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Arith/Transforms/Passes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mlir/Pass/Pass.h" 4 | 5 | namespace mlir { 6 | namespace arith { 7 | namespace legacy { 8 | /// Create a pass to bufferize arith.constant ops. 9 | std::unique_ptr createConstantBufferizePass(uint64_t alignment = 0); 10 | 11 | } // namespace legacy 12 | } // namespace arith 13 | } // namespace mlir 14 | -------------------------------------------------------------------------------- /numba_mlir/build_sycl_runtime_standalone.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | import sys 6 | 7 | import setup_helper 8 | 9 | if __name__ == "__main__": 10 | install_prefix = sys.argv[1] 11 | setup_helper.build_sycl_runtime(install_prefix) 12 | setup_helper.build_sycl_math_runtime(install_prefix) 13 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Bufferization/Transforms/Passes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mlir/Pass/Pass.h" 4 | 5 | namespace mlir { 6 | namespace bufferization { 7 | namespace legacy { 8 | /// Create a pass that bufferizes ops from the bufferization dialect. 9 | std::unique_ptr createBufferizationBufferizePass(); 10 | 11 | } // namespace legacy 12 | } // namespace bufferization 13 | } // namespace mlir 14 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/IndexTypePropagation.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace mlir { 8 | class RewritePatternSet; 9 | class MLIRContext; 10 | } // namespace mlir 11 | 12 | namespace numba { 13 | void populateIndexPropagatePatterns(mlir::RewritePatternSet &patterns); 14 | } 15 | -------------------------------------------------------------------------------- /scripts/bench-env-linux.yml: -------------------------------------------------------------------------------- 1 | name: bench 2 | channels: 3 | - dppy/label/dev 4 | - conda-forge 5 | - https://software.repos.intel.com/python/conda/ 6 | - nodefaults 7 | dependencies: 8 | - python=3.10 9 | - asv=0.6 10 | - numba-mlir 11 | - dpctl 12 | - dpcpp_linux-64 = 2024.2 13 | - icc_rt 14 | - https://software.repos.intel.com/python/conda/::numpy 15 | - py-cpuinfo 16 | - tomli 17 | - scipy 18 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/ExpandTuple.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | } 12 | 13 | namespace numba { 14 | /// Expand tuple into individual elements. 15 | std::unique_ptr createExpandTuplePass(); 16 | } // namespace numba 17 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/IfRewrites.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace mlir { 8 | class MLIRContext; 9 | class RewritePatternSet; 10 | } // namespace mlir 11 | 12 | namespace numba { 13 | void populateIfRewritesPatterns(mlir::RewritePatternSet &patterns); 14 | 15 | } // namespace numba 16 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/LoopRewrites.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace mlir { 8 | class MLIRContext; 9 | class RewritePatternSet; 10 | } // namespace mlir 11 | 12 | namespace numba { 13 | void populateLoopRewritesPatterns(mlir::RewritePatternSet &patterns); 14 | 15 | } // namespace numba 16 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/CfgToScf.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | } 12 | 13 | namespace numba { 14 | /// Converts function body from CFG form to SCF dialect ops. 15 | std::unique_ptr createCFGToSCFPass(); 16 | } // namespace numba 17 | -------------------------------------------------------------------------------- /numba_mlir/conda-recipe/build.sh: -------------------------------------------------------------------------------- 1 | pushd numba_mlir 2 | 3 | # Intel LLVM must cooperate with compiler and sysroot from conda 4 | echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot -target ${HOST}" > icpx_for_conda.cfg 5 | export ICPXCFG="$(pwd)/icpx_for_conda.cfg" 6 | export ICXCFG="$(pwd)/icpx_for_conda.cfg" 7 | 8 | $PYTHON setup.py install --single-version-externally-managed --record=record.txt 9 | popd 10 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/FuncTransforms.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | } // namespace mlir 12 | 13 | namespace numba { 14 | /// Remove unused functions arguments. 15 | std::unique_ptr createRemoveUnusedArgsPass(); 16 | } // namespace numba 17 | -------------------------------------------------------------------------------- /numba_mlir/conda-recipe/bld.bat: -------------------------------------------------------------------------------- 1 | copy /y "%RECIPE_DIR%"\MKLConfig.cmake "%PREFIX%"\Library\lib\cmake\mkl 2 | if errorlevel 1 exit 1 3 | 4 | set "LIB=%BUILD_PREFIX%\Library\lib;%BUILD_PREFIX%\compiler\lib;%PREFIX%\Library\lib;%PREFIX%\compiler\lib;%LIB%" 5 | set "INCLUDE=%PREFIX%\include;%INCLUDE%" 6 | 7 | pushd numba_mlir 8 | "%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt 9 | if errorlevel 1 exit 1 10 | popd 11 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/SCFToAffine/SCFToAffine.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | 11 | class Pass; 12 | 13 | /// Uplifts scf to affine. Supports: 14 | /// 1. scf.parallel to affine.parallel. 15 | std::unique_ptr createSCFToAffinePass(); 16 | 17 | } // namespace mlir 18 | -------------------------------------------------------------------------------- /numba_mlir/MANIFEST.in: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | include MANIFEST.in 6 | 7 | include setup.py 8 | include versioneer.py 9 | include numba_mlir/_version.py 10 | 11 | recursive-include numba_mlir *.ini 12 | recursive-include numba_mlir *.pyd 13 | recursive-include numba_mlir *.dll 14 | recursive-include numba_mlir *.so 15 | recursive-include numba_mlir *.dylib 16 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/PlierToScf.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace numba { 8 | class PipelineRegistry; 9 | } 10 | 11 | namespace llvm { 12 | class StringRef; 13 | } 14 | 15 | void registerPlierToScfPipeline(numba::PipelineRegistry ®istry); 16 | 17 | llvm::StringRef plierToScfPipelineName(); 18 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/PlierToStd.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace numba { 8 | class PipelineRegistry; 9 | } 10 | 11 | namespace llvm { 12 | class StringRef; 13 | } 14 | 15 | void registerPlierToStdPipeline(numba::PipelineRegistry ®istry); 16 | 17 | llvm::StringRef plierToStdPipelineName(); 18 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/math_runtime/lib/Common.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include "Common.hpp" 6 | #include "numba-mlir-math-runtime_export.h" 7 | 8 | extern "C" { 9 | NUMBA_MLIR_MATH_RUNTIME_EXPORT void nmrtMathRuntimeInit() { 10 | // Nothing 11 | } 12 | 13 | NUMBA_MLIR_MATH_RUNTIME_EXPORT void nmrtMathRuntimeFinalize() { 14 | // Nothing 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/ParallelToTbb.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace numba { 8 | class PipelineRegistry; 9 | } 10 | 11 | namespace llvm { 12 | class StringRef; 13 | } 14 | 15 | void registerParallelToTBBPipeline(numba::PipelineRegistry ®istry); 16 | 17 | llvm::StringRef parallelToTBBPipelineName(); 18 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/CanonicalizeReductions.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | } 12 | 13 | namespace numba { 14 | /// Tries to promote loads/stores in scf.for to loop-carried variables. 15 | std::unique_ptr createCanonicalizeReductionsPass(); 16 | } // namespace numba 17 | -------------------------------------------------------------------------------- /numba_mlir_runtime/lib/AllocToken.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include "numba-mlir-runtime_export.h" 6 | 7 | using AllocToken = void *; 8 | 9 | extern "C" NUMBA_MLIR_RUNTIME_EXPORT AllocToken *nmrtCreateAllocToken() { 10 | return new AllocToken; 11 | } 12 | 13 | extern "C" NUMBA_MLIR_RUNTIME_EXPORT void 14 | nmrtDestroyAllocToken(AllocToken *token) { 15 | delete token; 16 | } 17 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/MathExtToLibm.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | class RewritePatternSet; 12 | } // namespace mlir 13 | 14 | namespace numba { 15 | void populateMathExtToLibmPatterns(mlir::RewritePatternSet &patterns); 16 | 17 | std::unique_ptr createMathExtToLibmPass(); 18 | } // namespace numba 19 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/ShapeIntegerRangePropagation.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | } 12 | 13 | namespace numba { 14 | /// Propagate integer range info through the IR and optimize ops based on this 15 | /// info. 16 | std::unique_ptr createShapeIntegerRangePropagationPass(); 17 | } // namespace numba 18 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/stockham_fft/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "Stockham FFT" 8 | 9 | [benchmark.parameters.S] 10 | R = 2 11 | K = 15 12 | 13 | [benchmark.parameters.M] 14 | R = 2 15 | K = 18 16 | 17 | [benchmark.parameters.L] 18 | R = 2 19 | K = 21 20 | 21 | [benchmark.parameters.paper] 22 | R = 4 23 | K = 10 24 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/LowerToLlvm.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace numba { 8 | class PipelineRegistry; 9 | } 10 | 11 | namespace llvm { 12 | class StringRef; 13 | } 14 | 15 | void registerLowerToLLVMPipeline(numba::PipelineRegistry ®istry); 16 | 17 | llvm::StringRef preLowerToLLVMPipelineName(); 18 | llvm::StringRef lowerToLLVMPipelineName(); 19 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/crc16/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2018 Øystein Sture 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "CRC-16" 9 | 10 | [benchmark.parameters.S] 11 | N = 1600 12 | 13 | [benchmark.parameters.M] 14 | N = 16000 15 | 16 | [benchmark.parameters.L] 17 | N = 160000 18 | 19 | [benchmark.parameters.paper] 20 | N = 1000000 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/go_fast/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2012-2020 Anaconda, Inc. and others 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "GoFast" 9 | 10 | [benchmark.parameters.S] 11 | N = 2000 12 | 13 | [benchmark.parameters.M] 14 | N = 6000 15 | 16 | [benchmark.parameters.L] 17 | N = 20000 18 | 19 | [benchmark.parameters.paper] 20 | N = 12500 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/nussinov/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Nussinov" 9 | 10 | [benchmark.parameters.S] 11 | N = 40 12 | 13 | [benchmark.parameters.M] 14 | N = 90 15 | 16 | [benchmark.parameters.L] 17 | N = 200 18 | 19 | [benchmark.parameters.paper] 20 | N = 500 21 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/python_runtime/lib/PythonRt.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "numba-mlir-python-runtime_export.h" 10 | 11 | using MemInfoDtorFunction = void (*)(void *ptr, size_t size, void *info); 12 | 13 | extern "C" NUMBA_MLIR_PYTHON_RUNTIME_EXPORT void * 14 | nmrtAllocMemInfo(void *data, size_t size, MemInfoDtorFunction dtor, 15 | void *dtorInfo); 16 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/LoopUtils.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace numba { 11 | mlir::LogicalResult naivelyFuseParallelOps(mlir::Region ®ion); 12 | mlir::LogicalResult 13 | prepareForFusion(mlir::Region ®ion, 14 | llvm::function_ref needPrepare); 15 | } // namespace numba 16 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/pythran/arc_distance/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2019 Serge Guelton 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Arc Distance" 9 | 10 | [benchmark.parameters.S] 11 | N = 100000 12 | 13 | [benchmark.parameters.M] 14 | N = 1000000 15 | 16 | [benchmark.parameters.L] 17 | N = 10000000 18 | 19 | [benchmark.parameters.paper] 20 | N = 10000000 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/floyd_warshall/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Floyd-Warshall" 9 | 10 | [benchmark.parameters.S] 11 | N = 200 12 | 13 | [benchmark.parameters.M] 14 | N = 400 15 | 16 | [benchmark.parameters.L] 17 | N = 850 18 | 19 | [benchmark.parameters.paper] 20 | N = 2800 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/lu/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "LU Decomposition" 9 | 10 | [benchmark.parameters.S] 11 | N = 60 12 | 13 | [benchmark.parameters.M] 14 | N = 220 15 | 16 | [benchmark.parameters.L] 17 | N = 700 18 | 19 | [benchmark.parameters.paper] 20 | N = 2000 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Please review these guidelines to help with the review process: 2 | - [ ] Have you provided a meaningful PR description? 3 | - [ ] Have you added a test, a reproducer, or a reference to an issue with a reproducer? 4 | - [ ] Have you tested your changes locally for CPU and GPU devices? 5 | - [ ] Have you made sure that new changes do not introduce compiler warnings? 6 | - [ ] If this PR is a work in progress, are you filing the PR as a draft? 7 | - [ ] Have you organized your commits logically and ensured each can be built by itself? 8 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/ludcmp/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "LU Decomposition" 9 | 10 | [benchmark.parameters.S] 11 | N = 60 12 | 13 | [benchmark.parameters.M] 14 | N = 220 15 | 16 | [benchmark.parameters.L] 17 | N = 650 18 | 19 | [benchmark.parameters.paper] 20 | N = 2000 21 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Arith/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | include_directories(${MLIR_INCLUDE_DIRS}) 6 | 7 | set(LLVM_TARGET_DEFINITIONS Passes.td) 8 | mlir_tablegen(Passes.h.inc -gen-pass-decls -name Transforms) 9 | mlir_tablegen(Transforms.capi.h.inc -gen-pass-capi-header --prefix Transforms) 10 | mlir_tablegen(Transforms.capi.cpp.inc -gen-pass-capi-impl --prefix Transforms) 11 | add_public_tablegen_target(MLIRArithLegacyIncGen) 12 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Linalg/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | include_directories(${MLIR_INCLUDE_DIRS}) 6 | 7 | set(LLVM_TARGET_DEFINITIONS Passes.td) 8 | mlir_tablegen(Passes.h.inc -gen-pass-decls -name Transforms) 9 | mlir_tablegen(Transforms.capi.h.inc -gen-pass-capi-header --prefix Transforms) 10 | mlir_tablegen(Transforms.capi.cpp.inc -gen-pass-capi-impl --prefix Transforms) 11 | add_public_tablegen_target(MLIRLinalgLegacyIncGen) 12 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Tensor/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | include_directories(${MLIR_INCLUDE_DIRS}) 6 | 7 | set(LLVM_TARGET_DEFINITIONS Passes.td) 8 | mlir_tablegen(Passes.h.inc -gen-pass-decls -name Transforms) 9 | mlir_tablegen(Transforms.capi.h.inc -gen-pass-capi-header --prefix Transforms) 10 | mlir_tablegen(Transforms.capi.cpp.inc -gen-pass-capi-impl --prefix Transforms) 11 | add_public_tablegen_target(MLIRTensorLegacyIncGen) 12 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/trisolv/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Triangular solver" 9 | 10 | [benchmark.parameters.S] 11 | N = 2000 12 | 13 | [benchmark.parameters.M] 14 | N = 5000 15 | 16 | [benchmark.parameters.L] 17 | N = 14000 18 | 19 | [benchmark.parameters.paper] 20 | N = 16000 21 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/Mangle.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace llvm { 10 | class StringRef; 11 | class raw_ostream; 12 | } // namespace llvm 13 | 14 | namespace mlir { 15 | class TypeRange; 16 | } 17 | 18 | bool mangle(llvm::raw_ostream &res, llvm::StringRef ident, 19 | mlir::TypeRange types); 20 | 21 | std::string mangle(llvm::StringRef ident, mlir::TypeRange types); 22 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/lenet/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "Lenet-5" 8 | 9 | [benchmark.parameters.S] 10 | N = 4 11 | H = 28 12 | W = 28 13 | 14 | [benchmark.parameters.M] 15 | N = 8 16 | H = 56 17 | W = 56 18 | 19 | [benchmark.parameters.L] 20 | N = 8 21 | H = 176 22 | W = 176 23 | 24 | [benchmark.parameters.paper] 25 | N = 16 26 | H = 256 27 | W = 256 28 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/cholesky/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Cholesky Decomposition" 9 | 10 | [benchmark.parameters.S] 11 | N = 100 12 | 13 | [benchmark.parameters.M] 14 | N = 300 15 | 16 | [benchmark.parameters.L] 17 | N = 900 18 | 19 | [benchmark.parameters.paper] 20 | N = 2000 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/durbin/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Toeplitz system solver" 9 | 10 | [benchmark.parameters.S] 11 | N = 1000 12 | 13 | [benchmark.parameters.M] 14 | N = 6000 15 | 16 | [benchmark.parameters.L] 17 | N = 20000 18 | 19 | [benchmark.parameters.paper] 20 | N = 16000 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/softmax/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "Softmax" 8 | 9 | [benchmark.parameters.S] 10 | N = 16 11 | H = 16 12 | SM = 128 13 | 14 | [benchmark.parameters.M] 15 | N = 32 16 | H = 8 17 | SM = 256 18 | 19 | [benchmark.parameters.L] 20 | N = 64 21 | H = 16 22 | SM = 448 23 | 24 | [benchmark.parameters.paper] 25 | N = 64 26 | H = 16 27 | SM = 512 28 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Bufferization/Transforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | include_directories(${MLIR_INCLUDE_DIRS}) 6 | 7 | set(LLVM_TARGET_DEFINITIONS Passes.td) 8 | mlir_tablegen(Passes.h.inc -gen-pass-decls -name Transforms) 9 | mlir_tablegen(Transforms.capi.h.inc -gen-pass-capi-header --prefix Transforms) 10 | mlir_tablegen(Transforms.capi.cpp.inc -gen-pass-capi-impl --prefix Transforms) 11 | add_public_tablegen_target(MLIRBufferizationLegacyIncGen) 12 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/mvt/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Matrix Vector Product and Transpose" 9 | 10 | [benchmark.parameters.S] 11 | N = 5500 12 | 13 | [benchmark.parameters.M] 14 | N = 11000 15 | 16 | [benchmark.parameters.L] 17 | N = 22000 18 | 19 | [benchmark.parameters.paper] 20 | N = 16000 21 | -------------------------------------------------------------------------------- /mlir/include/numba/Dialect/ntensor/Transforms/PropagateEnvironment.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | } // namespace mlir 12 | 13 | namespace numba { 14 | namespace ntensor { 15 | /// Propagate enviroment attribute through the ntensor ops using dataflow 16 | /// analysis. 17 | std::unique_ptr createPropagateEnvironmentPass(); 18 | } // namespace ntensor 19 | } // namespace numba 20 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/PlierToLinalg.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace numba { 8 | class PipelineRegistry; 9 | } 10 | 11 | namespace llvm { 12 | class StringRef; 13 | } 14 | 15 | void registerPlierToLinalgPipeline(numba::PipelineRegistry ®istry); 16 | 17 | llvm::StringRef plierToLinalgRegionPipelineName(); 18 | llvm::StringRef plierToLinalgGenPipelineName(); 19 | llvm::StringRef plierToLinalgOptPipelineName(); 20 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gemver/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Vector Multiplication and Matrix Addition" 9 | 10 | [benchmark.parameters.S] 11 | N = 1000 12 | 13 | [benchmark.parameters.M] 14 | N = 3000 15 | 16 | [benchmark.parameters.L] 17 | N = 10000 18 | 19 | [benchmark.parameters.paper] 20 | N = 8000 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gesummv/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Scalar, Vector and Matrix Multiplication" 9 | 10 | [benchmark.parameters.S] 11 | N = 2000 12 | 13 | [benchmark.parameters.M] 14 | N = 4000 15 | 16 | [benchmark.parameters.L] 17 | N = 14000 18 | 19 | [benchmark.parameters.paper] 20 | N = 11200 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/cholesky2/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Cholesky Decomposition - version 2" 9 | 10 | [benchmark.parameters.S] 11 | N = 1000 12 | 13 | [benchmark.parameters.M] 14 | N = 2200 15 | 16 | [benchmark.parameters.L] 17 | N = 8000 18 | 19 | [benchmark.parameters.paper] 20 | N = 2000 21 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/kernel.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | from .mlir.kernel_impl import ( 6 | kernel, 7 | get_global_id, 8 | get_local_id, 9 | get_group_id, 10 | get_global_size, 11 | get_local_size, 12 | atomic, 13 | kernel_func, 14 | DEFAULT_LOCAL_SIZE, 15 | barrier, 16 | mem_fence, 17 | LOCAL_MEM_FENCE, 18 | GLOBAL_MEM_FENCE, 19 | local, 20 | private, 21 | group, 22 | ) 23 | from .mlir.kernel_sim import kernel as kernel_sim 24 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/PipelineUtils.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace mlir { 8 | class ArrayAttr; 9 | class ModuleOp; 10 | class StringAttr; 11 | } // namespace mlir 12 | 13 | namespace numba { 14 | mlir::ArrayAttr getPipelineJumpMarkers(mlir::ModuleOp module); 15 | void addPipelineJumpMarker(mlir::ModuleOp module, mlir::StringAttr name); 16 | void removePipelineJumpMarker(mlir::ModuleOp module, mlir::StringAttr name); 17 | } // namespace numba 18 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/CheckGpuCaps.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace numba { 12 | struct OffloadDeviceCapabilities { 13 | uint16_t spirvMajorVersion; 14 | uint16_t spirvMinorVersion; 15 | bool hasFP16; 16 | bool hasFP64; 17 | }; 18 | 19 | std::optional> 20 | getDefaultDevice(); 21 | } // namespace numba 22 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/datamining/correlation/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Correlation" 9 | 10 | [benchmark.parameters.S] 11 | M = 500 12 | N = 600 13 | 14 | [benchmark.parameters.M] 15 | M = 1400 16 | N = 1800 17 | 18 | [benchmark.parameters.L] 19 | M = 3200 20 | N = 4000 21 | 22 | [benchmark.parameters.paper] 23 | M = 1200 24 | N = 1400 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/datamining/covariance/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Covariance" 9 | 10 | [benchmark.parameters.S] 11 | M = 500 12 | N = 600 13 | 14 | [benchmark.parameters.M] 15 | M = 1400 16 | N = 1800 17 | 18 | [benchmark.parameters.L] 19 | M = 3200 20 | N = 4000 21 | 22 | [benchmark.parameters.paper] 23 | M = 1200 24 | N = 1400 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/deriche/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Deriche Edge Detector" 9 | 10 | [benchmark.parameters.S] 11 | W = 400 12 | H = 200 13 | 14 | [benchmark.parameters.M] 15 | W = 1500 16 | H = 1000 17 | 18 | [benchmark.parameters.L] 19 | W = 6000 20 | H = 3000 21 | 22 | [benchmark.parameters.paper] 23 | W = 7680 24 | H = 4320 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/heat_3d/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Heat-3D" 9 | 10 | [benchmark.parameters.S] 11 | TSTEPS = 25 12 | N = 25 13 | 14 | [benchmark.parameters.M] 15 | TSTEPS = 50 16 | N = 40 17 | 18 | [benchmark.parameters.L] 19 | TSTEPS = 100 20 | N = 70 21 | 22 | [benchmark.parameters.paper] 23 | TSTEPS = 500 24 | N = 120 25 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/UpliftMath.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class MLIRContext; 11 | class RewritePatternSet; 12 | class Pass; 13 | } // namespace mlir 14 | 15 | namespace numba { 16 | void populateUpliftMathPatterns(mlir::RewritePatternSet &patterns); 17 | 18 | /// This pass tries to uplift libm-style func call to math dialect ops. 19 | std::unique_ptr createUpliftMathPass(); 20 | } // namespace numba 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/symm/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Symmetric matrix-multiply" 9 | 10 | [benchmark.parameters.S] 11 | M = 40 12 | N = 50 13 | 14 | [benchmark.parameters.M] 15 | M = 120 16 | N = 150 17 | 18 | [benchmark.parameters.L] 19 | M = 350 20 | N = 550 21 | 22 | [benchmark.parameters.paper] 23 | M = 1000 24 | N = 1200 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/syrk/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Symmetric rank-k operations" 9 | 10 | [benchmark.parameters.S] 11 | M = 50 12 | N = 70 13 | 14 | [benchmark.parameters.M] 15 | M = 150 16 | N = 200 17 | 18 | [benchmark.parameters.L] 19 | M = 500 20 | N = 600 21 | 22 | [benchmark.parameters.paper] 23 | M = 1000 24 | N = 1200 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/trmm/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Triangular matrix-multiply" 9 | 10 | [benchmark.parameters.S] 11 | M = 65 12 | N = 80 13 | 14 | [benchmark.parameters.M] 15 | M = 200 16 | N = 250 17 | 18 | [benchmark.parameters.L] 19 | M = 600 20 | N = 700 21 | 22 | [benchmark.parameters.paper] 23 | M = 1000 24 | N = 1200 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/syr2k/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Symmetric rank-2k operations" 9 | 10 | [benchmark.parameters.S] 11 | M = 35 12 | N = 50 13 | 14 | [benchmark.parameters.M] 15 | M = 110 16 | N = 140 17 | 18 | [benchmark.parameters.L] 19 | M = 350 20 | N = 400 21 | 22 | [benchmark.parameters.paper] 23 | M = 1000 24 | N = 1200 25 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/PyMapTypes.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace pybind11 { 8 | class list; 9 | class object; 10 | class handle; 11 | } // namespace pybind11 12 | 13 | namespace mlir { 14 | class Type; 15 | class TypeRange; 16 | } // namespace mlir 17 | 18 | pybind11::object mapTypeToNumba(pybind11::handle typesMod, mlir::Type type); 19 | pybind11::object mapTypesToNumba(pybind11::handle typesMod, 20 | mlir::TypeRange types); 21 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/LowerToGpu.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace numba { 8 | class PipelineRegistry; 9 | } 10 | 11 | namespace llvm { 12 | class StringRef; 13 | } 14 | 15 | void registerLowerToGPUPipeline(numba::PipelineRegistry ®istry); 16 | 17 | llvm::StringRef lowerToGPUPipelineNameRegion(); 18 | llvm::StringRef lowerToGPUPipelineNameHigh(); 19 | llvm::StringRef lowerToGPUPipelineNameMed(); 20 | llvm::StringRef lowerToGPUPipelineNameLow(); 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/spmv/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "Sparse Matrix-Vector Multiplication" 8 | 9 | [benchmark.parameters.S] 10 | M = 4096 11 | N = 4096 12 | nnz = 8192 13 | 14 | [benchmark.parameters.M] 15 | M = 32768 16 | N = 32768 17 | nnz = 65536 18 | 19 | [benchmark.parameters.L] 20 | M = 262144 21 | N = 262144 22 | nnz = 262144 23 | 24 | [benchmark.parameters.paper] 25 | M = 131072 26 | N = 131072 27 | nnz = 262144 28 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/gramschmidt/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Gram-Schmidt decomposition" 9 | 10 | [benchmark.parameters.S] 11 | M = 70 12 | N = 60 13 | 14 | [benchmark.parameters.M] 15 | M = 220 16 | N = 180 17 | 18 | [benchmark.parameters.L] 19 | M = 600 20 | N = 500 21 | 22 | [benchmark.parameters.paper] 23 | M = 240 24 | N = 200 25 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/BasePipeline.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace numba { 10 | class PipelineRegistry; 11 | } 12 | 13 | void registerBasePipeline(numba::PipelineRegistry ®istry); 14 | 15 | struct PipelineStage { 16 | llvm::StringRef begin; 17 | llvm::StringRef end; 18 | }; 19 | 20 | PipelineStage getHighLoweringStage(); // TODO: better name 21 | PipelineStage getLowerLoweringStage(); // TODO: better name 22 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/azimint_hist/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014 Jérôme Kieffer et al. 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Azimuthal Integration - Histogram" 9 | 10 | [benchmark.parameters.S] 11 | N = 400000 12 | npt = 1000 13 | 14 | [benchmark.parameters.M] 15 | N = 4000000 16 | npt = 1000 17 | 18 | [benchmark.parameters.L] 19 | N = 40000000 20 | npt = 1000 21 | 22 | [benchmark.parameters.paper] 23 | N = 1000000 24 | npt = 1000 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/azimint_naive/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014 Jérôme Kieffer et al. 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Azimuthal Integration - Naive" 9 | 10 | [benchmark.parameters.S] 11 | N = 400000 12 | npt = 1000 13 | 14 | [benchmark.parameters.M] 15 | N = 4000000 16 | npt = 1000 17 | 18 | [benchmark.parameters.L] 19 | N = 40000000 20 | npt = 1000 21 | 22 | [benchmark.parameters.paper] 23 | N = 1000000 24 | npt = 1000 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/adi/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Alternating Direction Implicit Method" 9 | 10 | [benchmark.parameters.S] 11 | TSTEPS = 5 12 | N = 100 13 | 14 | [benchmark.parameters.M] 15 | TSTEPS = 20 16 | N = 200 17 | 18 | [benchmark.parameters.L] 19 | TSTEPS = 50 20 | N = 500 21 | 22 | [benchmark.parameters.paper] 23 | TSTEPS = 100 24 | N = 200 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/seidel_2d/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "2-D Seidel stencil computation" 9 | 10 | [benchmark.parameters.S] 11 | TSTEPS = 8 12 | N = 50 13 | 14 | [benchmark.parameters.M] 15 | TSTEPS = 15 16 | N = 100 17 | 18 | [benchmark.parameters.L] 19 | TSTEPS = 40 20 | N = 200 21 | 22 | [benchmark.parameters.paper] 23 | TSTEPS = 100 24 | N = 400 25 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/PreLowSimplifications.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace numba { 8 | class PipelineRegistry; 9 | } 10 | 11 | namespace llvm { 12 | class StringRef; 13 | } 14 | 15 | namespace mlir { 16 | class MLIRContext; 17 | class TypeConverter; 18 | } // namespace mlir 19 | 20 | void registerPreLowSimpleficationsPipeline(numba::PipelineRegistry ®istry); 21 | 22 | llvm::StringRef untuplePipelineName(); 23 | llvm::StringRef removeSignPipelineName(); 24 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/atax/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "A transpose times A times x" 9 | 10 | [benchmark.parameters.S] 11 | M = 4000 12 | N = 5000 13 | 14 | [benchmark.parameters.M] 15 | M = 10000 16 | N = 12500 17 | 18 | [benchmark.parameters.L] 19 | M = 20000 20 | N = 25000 21 | 22 | [benchmark.parameters.paper] 23 | M = 18000 24 | N = 22000 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/bicg/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Bincojugate Gradient Method" 9 | 10 | [benchmark.parameters.S] 11 | M = 4000 12 | N = 5000 13 | 14 | [benchmark.parameters.M] 15 | M = 10000 16 | N = 12500 17 | 18 | [benchmark.parameters.L] 19 | M = 20000 20 | N = 25000 21 | 22 | [benchmark.parameters.paper] 23 | M = 18000 24 | N = 22000 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/jacobi_2d/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "2-D Jacobi stencil computation" 9 | 10 | [benchmark.parameters.S] 11 | TSTEPS = 50 12 | N = 150 13 | 14 | [benchmark.parameters.M] 15 | TSTEPS = 80 16 | N = 350 17 | 18 | [benchmark.parameters.L] 19 | TSTEPS = 200 20 | N = 700 21 | 22 | [benchmark.parameters.paper] 23 | TSTEPS = 1000 24 | N = 2800 25 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | name: pre-commit 6 | 7 | on: 8 | pull_request: 9 | push: 10 | branches: [main] 11 | 12 | jobs: 13 | pre-commit: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/setup-python@v5 18 | with: 19 | python-version: '3.11' 20 | - name: run pre-commit 21 | shell: bash -l {0} 22 | 23 | run: | 24 | pip install pre-commit || exit 1 25 | pre-commit run --all-files || exit 1 26 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/jacobi_1d/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "1-D Jacobi stencil computation" 9 | 10 | [benchmark.parameters.S] 11 | TSTEPS = 800 12 | N = 3200 13 | 14 | [benchmark.parameters.M] 15 | TSTEPS = 3000 16 | N = 12000 17 | 18 | [benchmark.parameters.L] 19 | TSTEPS = 8500 20 | N = 34000 21 | 22 | [benchmark.parameters.paper] 23 | TSTEPS = 4000 24 | N = 32000 25 | -------------------------------------------------------------------------------- /numba_mlir_gpu_runtime_sycl/lib/Utils.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include 6 | #include 7 | 8 | namespace { 9 | template static auto catchAll(F &&func) noexcept { 10 | try { 11 | return func(); 12 | } catch (const std::exception &e) { 13 | fprintf(stdout, "An exception was thrown: %s\n", e.what()); 14 | fflush(stdout); 15 | abort(); 16 | } catch (...) { 17 | fprintf(stdout, "An unknown exception was thrown\n"); 18 | fflush(stdout); 19 | abort(); 20 | } 21 | } 22 | } // namespace 23 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/compute/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Stefan Behnel, Robert Bradshaw, 2 | # Dag Sverre Seljebotn, Greg Ewing, William Stein, Gabriel Gellner, et al. 3 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 4 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 5 | # 6 | # SPDX-License-Identifier: BSD-3-Clause 7 | 8 | [benchmark] 9 | name = "Compute" 10 | 11 | [benchmark.parameters.S] 12 | M = 2000 13 | N = 2000 14 | 15 | [benchmark.parameters.M] 16 | M = 5000 17 | N = 5000 18 | 19 | [benchmark.parameters.L] 20 | M = 16000 21 | N = 16000 22 | 23 | [benchmark.parameters.paper] 24 | M = 12500 25 | N = 12500 26 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/doitgen/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Multiresolution analysis kernel" 9 | 10 | [benchmark.parameters.S] 11 | NR = 60 12 | NQ = 60 13 | NP = 128 14 | 15 | [benchmark.parameters.M] 16 | NR = 110 17 | NQ = 125 18 | NP = 256 19 | 20 | [benchmark.parameters.L] 21 | NR = 220 22 | NQ = 250 23 | NP = 512 24 | 25 | [benchmark.parameters.paper] 26 | NR = 220 27 | NQ = 250 28 | NP = 270 29 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/UtilConversion.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace mlir { 8 | class ConversionTarget; 9 | class MLIRContext; 10 | class RewritePatternSet; 11 | class TypeConverter; 12 | } // namespace mlir 13 | 14 | namespace numba { 15 | /// Convert util ops according to provided type converter. 16 | void populateUtilConversionPatterns(mlir::TypeConverter &converter, 17 | mlir::RewritePatternSet &patterns, 18 | mlir::ConversionTarget &target); 19 | } // namespace numba 20 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/PromoteBoolMemref.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class TypeConverter; 11 | class RewritePatternSet; 12 | class ConversionTarget; 13 | class Pass; 14 | } // namespace mlir 15 | 16 | namespace numba { 17 | void populatePromoteBoolMemrefConversionRewritesAndTarget( 18 | mlir::TypeConverter &typeConverter, mlir::RewritePatternSet &patterns, 19 | mlir::ConversionTarget &target); 20 | 21 | std::unique_ptr createPromoteBoolMemrefPass(); 22 | } // namespace numba 23 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/resnet/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "ResNet-50 Bottleneck Residual Block" 8 | 9 | [benchmark.parameters.S] 10 | N = 8 11 | W = 14 12 | H = 14 13 | C1 = 32 14 | C2 = 8 15 | 16 | [benchmark.parameters.M] 17 | N = 8 18 | W = 28 19 | H = 28 20 | C1 = 64 21 | C2 = 16 22 | 23 | [benchmark.parameters.L] 24 | N = 8 25 | W = 56 26 | H = 56 27 | C1 = 128 28 | C2 = 32 29 | 30 | [benchmark.parameters.paper] 31 | N = 8 32 | W = 56 33 | H = 56 34 | C1 = 256 35 | C2 = 64 36 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/fdtd_2d/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "2-D Finite Different Time Domain Kernel" 9 | 10 | [benchmark.parameters.S] 11 | TMAX = 20 12 | NX = 200 13 | NY = 220 14 | 15 | [benchmark.parameters.M] 16 | TMAX = 60 17 | NX = 400 18 | NY = 450 19 | 20 | [benchmark.parameters.L] 21 | TMAX = 150 22 | NX = 800 23 | NY = 900 24 | 25 | [benchmark.parameters.paper] 26 | TMAX = 500 27 | NX = 1000 28 | NY = 1200 29 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gemm/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "General matrix-matrix multiplication" 9 | 10 | [benchmark.parameters.S] 11 | NI = 1000 12 | NJ = 1100 13 | NK = 1200 14 | 15 | [benchmark.parameters.M] 16 | NI = 2500 17 | NJ = 2750 18 | NK = 3000 19 | 20 | [benchmark.parameters.L] 21 | NI = 7000 22 | NJ = 7500 23 | NK = 8000 24 | 25 | [benchmark.parameters.paper] 26 | NI = 2000 27 | NJ = 2300 28 | NK = 2600 29 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/CompositePass.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace mlir { 12 | class OpPassManager; 13 | class Pass; 14 | } // namespace mlir 15 | 16 | namespace numba { 17 | /// Create composite pass, which runs selected set of passes until fixed point 18 | /// or maximum number of iterations reached. 19 | std::unique_ptr 20 | createCompositePass(std::string name, 21 | std::function populateFunc); 22 | } // namespace numba 23 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/contour_integral/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "Contour Integral" 8 | 9 | [benchmark.parameters.S] 10 | NR = 50 11 | NM = 150 12 | slab_per_bc = 2 13 | num_int_pts = 32 14 | 15 | [benchmark.parameters.M] 16 | NR = 200 17 | NM = 400 18 | slab_per_bc = 2 19 | num_int_pts = 32 20 | 21 | [benchmark.parameters.L] 22 | NR = 600 23 | NM = 1000 24 | slab_per_bc = 2 25 | num_int_pts = 32 26 | 27 | [benchmark.parameters.paper] 28 | NR = 500 29 | NM = 1000 30 | slab_per_bc = 2 31 | num_int_pts = 32 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/mlp/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "Multi-layer Perceptron" 8 | 9 | [benchmark.parameters.S] 10 | C_in = 3 11 | N = 8 12 | S0 = 30000 13 | S1 = 2000 14 | S2 = 2000 15 | 16 | [benchmark.parameters.M] 17 | C_in = 3 18 | N = 8 19 | S0 = 30000 20 | S1 = 10000 21 | S2 = 10000 22 | 23 | [benchmark.parameters.L] 24 | C_in = 3 25 | N = 8 26 | S0 = 30000 27 | S1 = 30000 28 | S2 = 30000 29 | 30 | [benchmark.parameters.paper] 31 | C_in = 3 32 | N = 8 33 | S0 = 30000 34 | S1 = 10000 35 | S2 = 1000 36 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/weather_stencils/vadv/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014-2021 ETH Zurich 2 | # SPDX-FileCopyrightText: 2007 Free Software Foundation, Inc. 3 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 4 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 5 | # 6 | # SPDX-License-Identifier: GPL-3.0-or-later 7 | 8 | [benchmark] 9 | name = "Vertical Advection" 10 | 11 | [benchmark.parameters.S] 12 | I = 60 13 | J = 60 14 | K = 40 15 | 16 | [benchmark.parameters.M] 17 | I = 112 18 | J = 112 19 | K = 80 20 | 21 | [benchmark.parameters.L] 22 | I = 180 23 | J = 180 24 | K = 160 25 | 26 | [benchmark.parameters.paper] 27 | I = 256 28 | J = 256 29 | K = 160 30 | -------------------------------------------------------------------------------- /mlir/include/numba/Dialect/gpu_runtime/Transforms/MakeBarriersUniform.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class MLIRContext; 11 | class Pass; 12 | class RewritePatternSet; 13 | } // namespace mlir 14 | 15 | namespace gpu_runtime { 16 | void populateMakeBarriersUniformPatterns(mlir::RewritePatternSet &patterns); 17 | 18 | /// gpu barriers ops require uniform control flow, this pass tries to rearrange 19 | /// control flow in a way to satisfy this requirement. 20 | std::unique_ptr createMakeBarriersUniformPass(); 21 | } // namespace gpu_runtime 22 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/weather_stencils/hdiff/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014-2021 ETH Zurich 2 | # SPDX-FileCopyrightText: 2007 Free Software Foundation, Inc. 3 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 4 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 5 | # 6 | # SPDX-License-Identifier: GPL-3.0-or-later 7 | 8 | [benchmark] 9 | name = "Horizontal Diffusion" 10 | 11 | [benchmark.parameters.S] 12 | I = 64 13 | J = 64 14 | K = 60 15 | 16 | [benchmark.parameters.M] 17 | I = 128 18 | J = 128 19 | K = 160 20 | 21 | [benchmark.parameters.L] 22 | I = 384 23 | J = 384 24 | K = 160 25 | 26 | [benchmark.parameters.paper] 27 | I = 256 28 | J = 256 29 | K = 160 30 | -------------------------------------------------------------------------------- /mlir/test/Transforms/set-spirv-abi-attr.mlir: -------------------------------------------------------------------------------- 1 | // RUN: numba-mlir-opt --set-spirv-abi-attrs %s | FileCheck %s 2 | 3 | gpu.module @main_kernel { 4 | gpu.func @main_kernel(%arg0: memref<8xf32>, %arg1: memref<8xf32>, %arg2: memref<8xf32>) kernel { 5 | 6 | // CHECK: gpu.func @main_kernel(%arg0: memref<8xf32>, %arg1: memref<8xf32>, %arg2: memref<8xf32>) kernel attributes {spirv.entry_point_abi = #spirv.entry_point_abi<>} { 7 | 8 | cf.br ^bb1 9 | ^bb1: // pred: ^bb0 10 | %0 = gpu.block_id x 11 | %1 = memref.load %arg0[%0] : memref<8xf32> 12 | %2 = memref.load %arg1[%0] : memref<8xf32> 13 | %3 = arith.addf %1, %2 : f32 14 | memref.store %3, %arg2[%0] : memref<8xf32> 15 | gpu.return 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /numba_mlir_gpu_runtime_sycl/lib/GpuModule.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include 6 | 7 | struct GPUModule; 8 | struct GPUKernel; 9 | 10 | GPUModule *createGPUModule(sycl::queue &queue, const void *data, 11 | size_t dataSize); 12 | void destoyGPUModule(GPUModule *mod); 13 | 14 | GPUKernel *getGPUKernel(GPUModule *mod, const char *name); 15 | void destroyGPUKernel(GPUKernel *kernel); 16 | 17 | sycl::kernel getSYCLKernel(GPUKernel *kernel); 18 | 19 | void suggestGPUBlockSize(GPUKernel *kernel, const uint32_t *gridSize, 20 | uint32_t *blockSize, size_t numDims); 21 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/conv2d_bias/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "Conv2D with Bias" 8 | 9 | [benchmark.parameters.S] 10 | N = 8 11 | C_in = 3 12 | C_out = 16 13 | K = 2 14 | H = 32 15 | W = 32 16 | 17 | [benchmark.parameters.M] 18 | N = 8 19 | C_in = 3 20 | C_out = 8 21 | K = 5 22 | H = 64 23 | W = 64 24 | 25 | [benchmark.parameters.L] 26 | N = 8 27 | C_in = 3 28 | C_out = 8 29 | K = 10 30 | H = 128 31 | W = 128 32 | 33 | [benchmark.parameters.paper] 34 | N = 8 35 | C_in = 3 36 | C_out = 16 37 | K = 20 38 | H = 256 39 | W = 256 40 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/k2mm/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "2 Matrix Multiplications" 9 | 10 | [benchmark.parameters.S] 11 | NI = 800 12 | NJ = 850 13 | NK = 900 14 | NL = 950 15 | 16 | [benchmark.parameters.M] 17 | NI = 2000 18 | NJ = 2250 19 | NK = 2500 20 | NL = 2750 21 | 22 | [benchmark.parameters.L] 23 | NI = 6000 24 | NJ = 6500 25 | NK = 7000 26 | NL = 7500 27 | 28 | [benchmark.parameters.paper] 29 | NI = 3200 30 | NJ = 3600 31 | NK = 4400 32 | NL = 4800 33 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/numba_runtime.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | from .compiler_context import global_compiler_context 6 | from .. import mlir_compiler 7 | 8 | from numba.core.runtime import _nrt_python as _nrt 9 | 10 | 11 | def _register_symbols(): 12 | names = [ 13 | "MemInfo_alloc_safe_aligned", 14 | "MemInfo_call_dtor", 15 | ] 16 | 17 | helpers = _nrt.c_helpers 18 | 19 | for name in names: 20 | func_name = "NRT_" + name 21 | sym = helpers[name] 22 | mlir_compiler.register_symbol(global_compiler_context, func_name, sym) 23 | 24 | 25 | _register_symbols() 26 | del _register_symbols 27 | -------------------------------------------------------------------------------- /mlir/include/numba/Dialect/ntensor/Transforms/ResolveArrayOps.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class MLIRContext; 11 | class Pass; 12 | class RewritePatternSet; 13 | } // namespace mlir 14 | 15 | namespace numba { 16 | namespace ntensor { 17 | void populateResolveArrayOpsPatterns(mlir::RewritePatternSet &patterns); 18 | 19 | /// This pass translates high level array manipulation ops into primitive 20 | /// ops like `resolve_index`, `subview`, `load`, `store` etc. 21 | std::unique_ptr createResolveArrayOpsPass(); 22 | } // namespace ntensor 23 | } // namespace numba 24 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/MemoryRewrites.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace mlir { 12 | class AnalysisManager; 13 | class Pass; 14 | } // namespace mlir 15 | 16 | namespace numba { 17 | std::optional optimizeMemoryOps(mlir::AnalysisManager &am); 18 | 19 | std::unique_ptr createMemoryOptPass(); 20 | 21 | /// Normalizes memref types shape and layout to most static one across func 22 | /// call boudaries. 23 | std::unique_ptr createNormalizeMemrefArgsPass(); 24 | } // namespace numba 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/nbody/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 Philip Mocz 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | [benchmark] 8 | name = "Nbody" 9 | 10 | [benchmark.parameters.S] 11 | N = 25 12 | tEnd = 2.0 13 | dt = 0.05 14 | softening = 0.1 15 | G = 1.0 16 | 17 | [benchmark.parameters.M] 18 | N = 50 19 | tEnd = 5.0 20 | dt = 0.02 21 | softening = 0.1 22 | G = 1.0 23 | 24 | [benchmark.parameters.L] 25 | N = 100 26 | tEnd = 9.0 27 | dt = 0.01 28 | softening = 0.1 29 | G = 1.0 30 | 31 | [benchmark.parameters.paper] 32 | N = 100 33 | tEnd = 10.0 34 | dt = 0.01 35 | softening = 0.1 36 | G = 1.0 37 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/NtensorToMemref.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class ConversionTarget; 11 | class MLIRContext; 12 | class Pass; 13 | class RewritePatternSet; 14 | class TypeConverter; 15 | } // namespace mlir 16 | 17 | namespace numba { 18 | void populateNtensorToMemrefRewritesAndTarget(mlir::TypeConverter &converter, 19 | mlir::RewritePatternSet &patterns, 20 | mlir::ConversionTarget &target); 21 | 22 | std::unique_ptr createNtensorToMemrefPass(); 23 | } // namespace numba 24 | -------------------------------------------------------------------------------- /mlir/include/numba/Utils.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include 10 | 11 | namespace llvm { 12 | class Twine; 13 | } 14 | 15 | namespace numba { 16 | [[noreturn]] void reportError(const llvm::Twine &msg); 17 | 18 | template 19 | void scopedDiagHandler(T &ctx, H &&diag_handler, F &&func) { 20 | auto &diagEngine = ctx.getDiagEngine(); 21 | auto diagId = diagEngine.registerHandler(std::forward(diag_handler)); 22 | auto diagGuard = 23 | llvm::make_scope_exit([&]() { diagEngine.eraseHandler(diagId); }); 24 | func(); 25 | } 26 | } // namespace numba 27 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/CommonOpts.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | class RewritePatternSet; 12 | } // namespace mlir 13 | 14 | namespace numba { 15 | void populateCanonicalizationPatterns(mlir::RewritePatternSet &patterns); 16 | 17 | void populatePoisonOptsPatterns(mlir::RewritePatternSet &patterns); 18 | void populateLoopOptsPatterns(mlir::RewritePatternSet &patterns); 19 | void populateCommonOptsPatterns(mlir::RewritePatternSet &patterns); 20 | 21 | std::unique_ptr createCommonOptsPass(); 22 | std::unique_ptr createMoveIntoParallelPass(); 23 | } // namespace numba 24 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/PromoteToParallel.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class Pass; 11 | class RewritePatternSet; 12 | } // namespace mlir 13 | 14 | namespace numba { 15 | void populatePromoteWhilePatterns(mlir::RewritePatternSet &patterns); 16 | void populatePromoteToParallelPatterns(mlir::RewritePatternSet &patterns); 17 | 18 | /// This pass tries to promote `scf.while` ops to `scf.for`. 19 | std::unique_ptr createPromoteWhilePass(); 20 | 21 | /// This pass tries to promote `scf.for` ops to `scf.parallel`. 22 | std::unique_ptr createPromoteToParallelPass(); 23 | } // namespace numba 24 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/k3mm/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "3 Matrix Multiplications" 9 | 10 | [benchmark.parameters.S] 11 | NI = 800 12 | NJ = 8500 13 | NK = 900 14 | NL = 950 15 | NM = 1000 16 | 17 | [benchmark.parameters.M] 18 | NI = 2000 19 | NJ = 2200 20 | NK = 2400 21 | NL = 2600 22 | NM = 2800 23 | 24 | [benchmark.parameters.L] 25 | NI = 5500 26 | NJ = 6000 27 | NK = 6500 28 | NL = 7000 29 | NM = 7500 30 | 31 | [benchmark.parameters.paper] 32 | NI = 3200 33 | NJ = 3600 34 | NK = 4000 35 | NL = 4400 36 | NM = 4800 37 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/MakeSignless.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class ConversionTarget; 11 | class MLIRContext; 12 | class Pass; 13 | class RewritePatternSet; 14 | class TypeConverter; 15 | } // namespace mlir 16 | 17 | namespace numba { 18 | void populateMakeSignlessRewritesAndTarget(mlir::TypeConverter &converter, 19 | mlir::RewritePatternSet &patterns, 20 | mlir::ConversionTarget &target); 21 | 22 | /// Convert types of various signedness to corresponding signless type. 23 | std::unique_ptr createMakeSignlessPass(); 24 | } // namespace numba 25 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/NtensorToLinalg.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class MLIRContext; 11 | class Pass; 12 | class RewritePatternSet; 13 | } // namespace mlir 14 | 15 | namespace numba { 16 | void populateNtensorToLinalgPatterns(mlir::RewritePatternSet &patterns); 17 | 18 | /// Creates a pass for ntensor alias analysis, required by ntensor-to-linalg. 19 | std::unique_ptr createNtensorAliasAnalysisPass(); 20 | 21 | /// Creates a pass to convert ntensor array ops to linalg. 22 | std::unique_ptr createNtensorToLinalgPass(); 23 | 24 | std::unique_ptr createNtensorLowerToTensorCopyPass(); 25 | } // namespace numba 26 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/UtilToLlvm.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace mlir { 11 | class LowerToLLVMOptions; 12 | class MLIRContext; 13 | class Pass; 14 | } // namespace mlir 15 | 16 | namespace numba { 17 | 18 | /// Convert operations from the numba_util dialect to the LLVM dialect. 19 | /// 20 | /// TODO: We cannot pass LowerToLLVMOptions directly to the pass as it requires 21 | /// mlir context which is not yet available at this point, pass creation 22 | /// function instead. 23 | std::unique_ptr createUtilToLLVMPass( 24 | std::function optsGetter); 25 | } // namespace numba 26 | -------------------------------------------------------------------------------- /mlir/include/numba/Conversion/GpuRuntimeToLlvm.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace mlir { 10 | class ConversionTarget; 11 | class LLVMTypeConverter; 12 | class Pass; 13 | class RewritePatternSet; 14 | } // namespace mlir 15 | 16 | namespace gpu_runtime { 17 | /// Populates the given list with patterns that convert from gpu_runtime to 18 | /// LLVM. 19 | void populateGpuToLLVMPatternsAndLegality(mlir::LLVMTypeConverter &converter, 20 | mlir::RewritePatternSet &patterns, 21 | mlir::ConversionTarget &target); 22 | 23 | std::unique_ptr createGPUToLLVMPass(); 24 | 25 | } // namespace gpu_runtime 26 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/scattering_self_energies/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | [benchmark] 7 | name = "Scattering Self Energies" 8 | 9 | [benchmark.parameters.S] 10 | Nkz = 2 11 | NE = 4 12 | Nqz = 2 13 | Nw = 2 14 | N3D = 2 15 | NA = 6 16 | NB = 2 17 | Norb = 3 18 | 19 | [benchmark.parameters.M] 20 | Nkz = 3 21 | NE = 5 22 | Nqz = 3 23 | Nw = 2 24 | N3D = 2 25 | NA = 10 26 | NB = 3 27 | Norb = 4 28 | 29 | [benchmark.parameters.L] 30 | Nkz = 3 31 | NE = 10 32 | Nqz = 3 33 | Nw = 3 34 | N3D = 3 35 | NA = 12 36 | NB = 4 37 | Norb = 4 38 | 39 | [benchmark.parameters.paper] 40 | Nkz = 4 41 | NE = 10 42 | Nqz = 4 43 | Nw = 3 44 | N3D = 3 45 | NA = 20 46 | NB = 4 47 | Norb = 4 48 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/stockham_fft/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import get_numpy_context 9 | 10 | 11 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 12 | params = presets 13 | param_names = ["preset"] 14 | 15 | def get_func(self): 16 | return get_impl(get_numpy_context()) 17 | 18 | def initialize(self, preset): 19 | preset = parameters[preset] 20 | return initialize(**preset) 21 | 22 | def validate(self, args, res): 23 | # Assume numpy impl is valid 24 | pass 25 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/TypeConversion.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace mlir { 8 | class ConversionTarget; 9 | class MLIRContext; 10 | class RewritePatternSet; 11 | class TypeConverter; 12 | } // namespace mlir 13 | 14 | namespace numba { 15 | void populateControlFlowTypeConversionRewritesAndTarget( 16 | mlir::TypeConverter &typeConverter, mlir::RewritePatternSet &patterns, 17 | mlir::ConversionTarget &target); 18 | 19 | void populateTupleTypeConverter(mlir::TypeConverter &typeConverter); 20 | 21 | void populateTupleTypeConversionRewritesAndTarget( 22 | mlir::TypeConverter &typeConverter, mlir::RewritePatternSet &patterns, 23 | mlir::ConversionTarget &target); 24 | } // namespace numba 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/contour_integral/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import get_numpy_context 9 | 10 | 11 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 12 | params = presets 13 | param_names = ["preset"] 14 | 15 | def get_func(self): 16 | return get_impl(get_numpy_context()) 17 | 18 | def initialize(self, preset): 19 | preset = parameters[preset] 20 | return initialize(**preset) 21 | 22 | def validate(self, args, res): 23 | # Assume numpy impl is valid 24 | pass 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/lenet/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import get_numpy_context 9 | 10 | 11 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 12 | params = presets 13 | param_names = ["preset"] 14 | 15 | def get_func(self): 16 | return get_impl(get_numpy_context()) 17 | 18 | def initialize(self, preset): 19 | preset = parameters[preset] 20 | return initialize(**preset) 21 | 22 | def validate(self, args, res): 23 | # Assume numpy impl is valid 24 | pass 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/mlp/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import get_numpy_context 9 | 10 | 11 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 12 | params = presets 13 | param_names = ["preset"] 14 | 15 | def get_func(self): 16 | return get_impl(get_numpy_context()) 17 | 18 | def initialize(self, preset): 19 | preset = parameters[preset] 20 | return initialize(**preset) 21 | 22 | def validate(self, args, res): 23 | # Assume numpy impl is valid 24 | pass 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/resnet/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import get_numpy_context 9 | 10 | 11 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 12 | params = presets 13 | param_names = ["preset"] 14 | 15 | def get_func(self): 16 | return get_impl(get_numpy_context()) 17 | 18 | def initialize(self, preset): 19 | preset = parameters[preset] 20 | return initialize(**preset) 21 | 22 | def validate(self, args, res): 23 | # Assume numpy impl is valid 24 | pass 25 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Tensor/Transforms/Passes.td: -------------------------------------------------------------------------------- 1 | //===-- Passes.td - pass definition file -------------------*- tablegen -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef MLIR_DIALECT_TENSOR_TRANSFORMS_PASSES 10 | #define MLIR_DIALECT_TENSOR_TRANSFORMS_PASSES 11 | 12 | include "mlir/Pass/PassBase.td" 13 | 14 | def TensorBufferize : Pass<"tensor-bufferize", "func::FuncOp"> { 15 | let summary = "Bufferize the `tensor` dialect"; 16 | let constructor = "mlir::tensor::createTensorBufferizePass()"; 17 | } 18 | 19 | #endif // MLIR_DIALECT_TENSOR_TRANSFORMS_PASSES 20 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/conv2d_bias/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import get_numpy_context 9 | 10 | 11 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 12 | params = presets 13 | param_names = ["preset"] 14 | 15 | def get_func(self): 16 | return get_impl(get_numpy_context()) 17 | 18 | def initialize(self, preset): 19 | preset = parameters[preset] 20 | return initialize(**preset) 21 | 22 | def validate(self, args, res): 23 | # Assume numpy impl is valid 24 | pass 25 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/softmax/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import get_numpy_context 9 | 10 | 11 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 12 | params = presets 13 | param_names = ["preset"] 14 | 15 | def get_func(self): 16 | return get_impl(get_numpy_context()) 17 | 18 | def initialize(self, preset): 19 | preset = parameters[preset] 20 | return initialize(**preset) 21 | 22 | def validate(self, args, res): 23 | # Assume numpy impl is valid 24 | pass 25 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/compiler_context.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | from .settings import DEBUG_TYPE, DUMP_LLVM, DUMP_OPTIMIZED, DUMP_ASSEMBLY 6 | from .. import mlir_compiler 7 | 8 | 9 | def _init_compiler(): 10 | def _print(s): 11 | print(s, end="") 12 | 13 | def _get_printer(enabled): 14 | return _print if enabled else None 15 | 16 | settings = {} 17 | settings["debug_type"] = DEBUG_TYPE 18 | settings["llvm_printer"] = _get_printer(DUMP_LLVM) 19 | settings["optimized_printer"] = _get_printer(DUMP_OPTIMIZED) 20 | settings["asm_printer"] = _get_printer(DUMP_ASSEMBLY) 21 | return mlir_compiler.init_compiler(settings) 22 | 23 | 24 | global_compiler_context = _init_compiler() 25 | del _init_compiler 26 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/scattering_self_energies/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import get_numpy_context 10 | 11 | 12 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 13 | params = presets 14 | param_names = ["preset"] 15 | 16 | def get_func(self): 17 | return get_impl(get_numpy_context()) 18 | 19 | def initialize(self, preset): 20 | preset = parameters[preset] 21 | return initialize(**preset) 22 | 23 | def validate(self, args, res): 24 | # Assume numpy impl is valid 25 | pass 26 | -------------------------------------------------------------------------------- /patches/llvm.diff: -------------------------------------------------------------------------------- 1 | diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp 2 | index 5313a64ed47e..e16a4154c9bf 100644 3 | --- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp 4 | +++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp 5 | @@ -188,6 +188,10 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx, 6 | if (!block->isEntryBlock() || 7 | !isa(block->getParentOp())) 8 | return std::nullopt; 9 | + if (!mlir::isa(barePtr.getType())) 10 | + return std::nullopt; 11 | + if (!resultType.hasStaticShape()) 12 | + return std::nullopt; 13 | desc = MemRefDescriptor::fromStaticShape(builder, loc, *this, resultType, 14 | inputs[0]); 15 | } else { 16 | -------------------------------------------------------------------------------- /mlir/test/Dialect/gpu_runtime/canonicalize.mlir: -------------------------------------------------------------------------------- 1 | // RUN: numba-mlir-opt %s -allow-unregistered-dialect -canonicalize --split-input-file | FileCheck %s 2 | 3 | // CHECK-LABEL: @test 4 | // CHECK: numba_util.env_region #gpu_runtime.region_desc 5 | // CHECK-NOT: numba_util.env_region #gpu_runtime.region_desc 6 | // CHECK: "test.test"() : () -> () 7 | func.func @test() { 8 | numba_util.env_region #gpu_runtime.region_desc { 9 | numba_util.env_region "test" { 10 | numba_util.env_region #gpu_runtime.region_desc { 11 | "test.test"() : () -> () 12 | } 13 | } 14 | } 15 | return 16 | } 17 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/python_rt.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | import ctypes 6 | from numba.core.runtime import _nrt_python as _nrt 7 | from .utils import load_lib, register_cfunc 8 | 9 | runtime_lib = load_lib("numba-mlir-python-runtime") 10 | 11 | 12 | def _register_funcs(): 13 | _funcs = ["nmrtAllocMemInfo", "nmrtUnboxSyclInterface"] 14 | 15 | for name in _funcs: 16 | func = getattr(runtime_lib, name) 17 | register_cfunc(name, func) 18 | 19 | _alloc_func = runtime_lib.nmrtSetMemInfoAllocFunc 20 | _alloc_func.argtypes = [ctypes.c_void_p] 21 | _numba_alloc_ptr = ctypes.cast(_nrt.c_helpers["Allocate"], ctypes.c_void_p) 22 | _alloc_func(_numba_alloc_ptr.value) 23 | 24 | 25 | _register_funcs() 26 | del _register_funcs 27 | -------------------------------------------------------------------------------- /mlir/include/numba/Analysis/MemorySsaAnalysis.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include "numba/Analysis/MemorySsa.hpp" 8 | 9 | #include 10 | 11 | namespace mlir { 12 | class Operation; 13 | class AliasAnalysis; 14 | } // namespace mlir 15 | 16 | namespace numba { 17 | class MemorySSAAnalysis { 18 | public: 19 | MemorySSAAnalysis(mlir::Operation *op, mlir::AnalysisManager &am); 20 | MemorySSAAnalysis(const MemorySSAAnalysis &) = delete; 21 | 22 | mlir::LogicalResult optimizeUses(); 23 | 24 | static bool isInvalidated(const mlir::AnalysisManager::PreservedAnalyses &pa); 25 | 26 | std::optional memssa; 27 | mlir::AliasAnalysis *aliasAnalysis = nullptr; 28 | }; 29 | } // namespace numba 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/crc16/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2018 Øystein Sture 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import get_numpy_context 10 | 11 | 12 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 13 | params = presets 14 | param_names = ["preset"] 15 | 16 | def get_func(self): 17 | return get_impl(get_numpy_context()) 18 | 19 | def initialize(self, preset): 20 | preset = parameters[preset] 21 | return initialize(**preset) 22 | 23 | def validate(self, args, res): 24 | # Assume numpy impl is valid 25 | pass 26 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/nbody/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 Philip Mocz 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import get_numpy_context 10 | 11 | 12 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 13 | params = presets 14 | param_names = ["preset"] 15 | 16 | def get_func(self): 17 | return get_impl(get_numpy_context()) 18 | 19 | def initialize(self, preset): 20 | preset = parameters[preset] 21 | return initialize(**preset) 22 | 23 | def validate(self, args, res): 24 | # Assume numpy impl is valid 25 | pass 26 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/spmv/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | # Sparse Matrix-Vector Multiplication (SpMV) 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/cavity_flow/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Lorena A. Barba, Gilbert F. Forsyth. 2 | # SPDX-FileCopyrightText: 2018 Barba, Lorena A., and Forsyth, Gilbert F. 3 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 4 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 5 | # 6 | # SPDX-License-Identifier: BSD-3-Clause 7 | 8 | [benchmark] 9 | name = "Cavity Flow" 10 | 11 | [benchmark.parameters.S] 12 | ny = 61 13 | nx = 61 14 | nt = 25 15 | nit = 5 16 | rho = 1.0 17 | nu = 0.1 18 | 19 | [benchmark.parameters.M] 20 | ny = 121 21 | nx = 121 22 | nt = 50 23 | nit = 10 24 | rho = 1.0 25 | nu = 0.1 26 | 27 | [benchmark.parameters.L] 28 | ny = 201 29 | nx = 201 30 | nt = 100 31 | nit = 20 32 | rho = 1.0 33 | nu = 0.1 34 | 35 | [benchmark.parameters.paper] 36 | ny = 101 37 | nx = 101 38 | nt = 700 39 | nit = 50 40 | rho = 1.0 41 | nu = 0.1 42 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/channel_flow/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Lorena A. Barba, Gilbert F. Forsyth. 2 | # SPDX-FileCopyrightText: 2018 Barba, Lorena A., and Forsyth, Gilbert F. 3 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 4 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 5 | # 6 | # SPDX-License-Identifier: BSD-3-Clause 7 | 8 | [benchmark] 9 | name = "Channel Flow" 10 | 11 | [benchmark.parameters.S] 12 | ny = 61 13 | nx = 61 14 | nit = 5 15 | rho = 1.0 16 | nu = 0.1 17 | F = 1.0 18 | 19 | [benchmark.parameters.M] 20 | ny = 121 21 | nx = 121 22 | nit = 10 23 | rho = 1.0 24 | nu = 0.1 25 | F = 1.0 26 | 27 | [benchmark.parameters.L] 28 | ny = 201 29 | nx = 201 30 | nit = 20 31 | rho = 1.0 32 | nu = 0.1 33 | F = 1.0 34 | 35 | [benchmark.parameters.paper] 36 | ny = 101 37 | nx = 101 38 | nit = 50 39 | rho = 1.0 40 | nu = 0.1 41 | F = 1.0 42 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/pythran/arc_distance/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2019 Serge Guelton 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/deriche/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/adi/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /numba_mlir/setup.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | import os 6 | from setuptools import find_packages, setup 7 | import versioneer 8 | import platform 9 | 10 | 11 | root_dir = os.path.dirname(os.path.abspath(__file__)) 12 | 13 | 14 | if int(os.environ.get("NUMBA_MLIR_SETUP_RUN_CMAKE", 1)): 15 | import setup_helper 16 | 17 | install_dir = os.path.join(root_dir, "numba_mlir") 18 | setup_helper.build_runtime(install_dir) 19 | 20 | packages = find_packages(where=root_dir, include=["numba_mlir", "numba_mlir.*"]) 21 | 22 | metadata = dict( 23 | name="numba-mlir", 24 | version=versioneer.get_version(), 25 | cmdclass=versioneer.get_cmdclass(), 26 | packages=packages, 27 | install_requires=["numba>=0.60.0,<0.60.1"], 28 | include_package_data=True, 29 | ) 30 | 31 | setup(**metadata) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/nussinov/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/fdtd_2d/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/heat_3d/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/jacobi_1d/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/jacobi_2d/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/seidel_2d/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/datamining/correlation/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/datamining/covariance/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gemm/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/symm/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/syrk/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/trmm/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/floyd_warshall/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Numba-MLIR Python implementation 8 | 9 | ## numpy functions 10 | 11 | *numpy/funcs.py* file contains implemented numpy functions. 12 | 13 | General form is: 14 | ``` 15 | @register_func('numpy.', numpy.) 16 | def _impl(builder, ): 17 | def body(): 18 | 19 | return 20 | 21 | return eltwise(builder, , body, ) 22 | ``` 23 | 24 | *Note:* Python math functions can be used. 25 | In this case do not forget to add implemented function to *math_funcs.py* in *_funcs* list. 26 | 27 | Tests should be added to *tests/test_numpy.py* file. 28 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gemver/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gesummv/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/syr2k/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/atax/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/bicg/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/k2mm/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/k3mm/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/mvt/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/durbin/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/lu/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/ludcmp/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/kernels/doitgen/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/cholesky/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/cholesky2/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/gramschmidt/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/solvers/trisolv/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Bufferization/Transforms/Passes.td: -------------------------------------------------------------------------------- 1 | //===-- Passes.td - Bufferization pass definition file --------*- tablegen -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_LEGACY_PASSES 9 | #define MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_LEGACY_PASSES 10 | 11 | include "mlir/Pass/PassBase.td" 12 | 13 | def BufferizationBufferize : Pass<"bufferization-bufferize", "func::FuncOp"> { 14 | let summary = "Bufferize the `bufferization` dialect"; 15 | let constructor = "mlir::bufferization::createBufferizationBufferizePass()"; 16 | } 17 | 18 | #endif // MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_LEGACY_PASSES 19 | -------------------------------------------------------------------------------- /mlir/tools/numba-mlir-opt/Main.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "numba/Dialect/gpu_runtime/IR/GpuRuntimeOps.hpp" 11 | #include "numba/Dialect/ntensor/IR/NTensorOps.hpp" 12 | #include "numba/Dialect/numba_util/Dialect.hpp" 13 | 14 | int main(int argc, char **argv) { 15 | mlir::registerAllPasses(); 16 | mlir::DialectRegistry registry; 17 | mlir::registerAllDialects(registry); 18 | registry.insert(); 19 | registry.insert(); 20 | registry.insert(); 21 | return mlir::failed(MlirOptMain( 22 | argc, argv, "numba-mlir modular optimizer driver\n", registry)); 23 | } 24 | -------------------------------------------------------------------------------- /mlir/include/legacy/Dialect/Linalg/Transforms/Passes.td: -------------------------------------------------------------------------------- 1 | //===-- Passes.td - Linalg pass definition file ------------*- tablegen -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef MLIR_DIALECT_LINALG_LEGACY_PASSES 10 | #define MLIR_DIALECT_LINALG_LEGACY_PASSES 11 | 12 | include "mlir/Pass/PassBase.td" 13 | 14 | def LinalgBufferizePass : Pass<"linalg-bufferize"> { 15 | let summary = "Bufferize the linalg dialect"; 16 | let dependentDialects = [ 17 | "affine::AffineDialect", 18 | "bufferization::BufferizationDialect", 19 | "linalg::LinalgDialect", 20 | "memref::MemRefDialect", 21 | ]; 22 | } 23 | 24 | #endif // MLIR_DIALECT_LINALG_LEGACY_PASSES 25 | -------------------------------------------------------------------------------- /mlir/include/numba/Dialect/plier/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | include_directories(${MLIR_INCLUDE_DIRS}) 6 | set(dialect PlierOps) 7 | set(dialect_namespace plier) 8 | set(LLVM_TARGET_DEFINITIONS ${dialect}.td) 9 | mlir_tablegen(${dialect}Enums.h.inc -gen-enum-decls) 10 | mlir_tablegen(${dialect}Enums.cpp.inc -gen-enum-defs) 11 | mlir_tablegen(${dialect}.h.inc -gen-op-decls) 12 | mlir_tablegen(${dialect}.cpp.inc -gen-op-defs) 13 | mlir_tablegen(${dialect}Dialect.h.inc -gen-dialect-decls -dialect=${dialect_namespace}) 14 | mlir_tablegen(${dialect}Dialect.cpp.inc -gen-dialect-defs -dialect=${dialect_namespace}) 15 | mlir_tablegen(${dialect}Types.h.inc -gen-typedef-decls) 16 | mlir_tablegen(${dialect}Types.cpp.inc -gen-typedef-defs) 17 | add_public_tablegen_target(MLIR${dialect}IncGen) 18 | add_dependencies(mlir-headers MLIR${dialect}IncGen) 19 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/ConstUtils.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include "mlir/IR/BuiltinAttributeInterfaces.h" 8 | #include 9 | #include 10 | 11 | namespace mlir { 12 | class Operation; 13 | class IntegerAttr; 14 | } // namespace mlir 15 | 16 | namespace numba { 17 | mlir::TypedAttr getConstVal(mlir::Operation *op); 18 | mlir::TypedAttr getConstVal(mlir::Value op); 19 | 20 | template T getConstVal(mlir::Operation *op) { 21 | return mlir::dyn_cast_or_null(getConstVal(op)); 22 | } 23 | 24 | template T getConstVal(mlir::Value op) { 25 | return mlir::dyn_cast_or_null(getConstVal(op)); 26 | } 27 | 28 | mlir::TypedAttr getConstAttr(mlir::Type type, double val); 29 | 30 | int64_t getIntAttrValue(mlir::IntegerAttr attr); 31 | } // namespace numba 32 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/PyTypeConverter.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace mlir { 13 | class MLIRContext; 14 | class Type; 15 | } // namespace mlir 16 | 17 | namespace pybind11 { 18 | class handle; 19 | } 20 | 21 | class PyTypeConverter { 22 | public: 23 | PyTypeConverter() = default; 24 | PyTypeConverter(const PyTypeConverter &) = delete; 25 | 26 | using Conversion = std::function( 27 | mlir::MLIRContext &, pybind11::handle)>; 28 | 29 | void addConversion(Conversion conv); 30 | 31 | mlir::Type convertType(mlir::MLIRContext &context, 32 | pybind11::handle pyObj) const; 33 | 34 | private: 35 | llvm::SmallVector conversions; 36 | }; 37 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/runtime.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | import ctypes 6 | import atexit 7 | from numba.np.ufunc.parallel import get_thread_count 8 | from .utils import load_lib, register_cfunc 9 | 10 | runtime_lib = load_lib("numba-mlir-runtime") 11 | 12 | _init_func = runtime_lib.nmrtParallelInit 13 | _init_func.argtypes = [ctypes.c_int] 14 | _init_func(get_thread_count()) 15 | 16 | _finalize_func = runtime_lib.nmrtParallelFinalize 17 | 18 | _funcs = [ 19 | "memrefCopy", 20 | "nmrtParallelFor", 21 | "nmrtPurgeContext", 22 | "nmrtReleaseContext", 23 | "nmrtTakeContext", 24 | "nmrtCreateAllocToken", 25 | "nmrtDestroyAllocToken", 26 | ] 27 | 28 | for name in _funcs: 29 | func = getattr(runtime_lib, name) 30 | register_cfunc(name, func) 31 | 32 | 33 | @atexit.register 34 | def _cleanup(): 35 | _finalize_func() 36 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | # See https://pre-commit.com for more information 6 | # See https://pre-commit.com/hooks.html for more hooks 7 | repos: 8 | - repo: https://github.com/PyCQA/bandit 9 | rev: '1.7.0' 10 | hooks: 11 | - id: bandit 12 | pass_filenames: false 13 | args: ["-r", "numba_mlir", "-lll", "-c", "bandit.yaml"] 14 | - repo: https://github.com/pre-commit/pre-commit-hooks 15 | rev: v4.0.1 16 | hooks: 17 | - id: end-of-file-fixer 18 | - id: trailing-whitespace 19 | - repo: https://github.com/psf/black 20 | rev: 23.1.0 21 | hooks: 22 | - id: black 23 | exclude: "numba_mlir/versioneer.py|numba_mlir/numba_mlir/_version.py" 24 | - repo: https://github.com/pocc/pre-commit-hooks 25 | rev: v1.1.1 26 | hooks: 27 | - id: clang-format 28 | args: ["-i"] 29 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/PyTypeConverter.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include "PyTypeConverter.hpp" 6 | 7 | #include 8 | 9 | #include 10 | 11 | void PyTypeConverter::addConversion(Conversion conv) { 12 | assert(conv && "Invalid conversion func"); 13 | conversions.emplace_back(std::move(conv)); 14 | } 15 | 16 | mlir::Type PyTypeConverter::convertType(mlir::MLIRContext &context, 17 | pybind11::handle pyObj) const { 18 | // Iterate in reverse order to follow mlir type conversion behavior. 19 | for (auto &conv : llvm::reverse(conversions)) { 20 | assert(conv && "Invalid conversion func"); 21 | std::optional result = conv(context, pyObj); 22 | if (!result) 23 | continue; 24 | 25 | return *result; 26 | } 27 | return nullptr; 28 | } 29 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/go_fast/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2012-2020 Anaconda, Inc. and others 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | # https://numba.readthedocs.io/en/stable/user/5minguide.html 8 | 9 | from .common import initialize, get_impl, parameters, presets 10 | import numba_mlir.mlir.benchmarking 11 | from numba_mlir.mlir.benchmarking import get_numpy_context 12 | 13 | 14 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 15 | params = presets 16 | param_names = ["preset"] 17 | 18 | def get_func(self): 19 | return get_impl(get_numpy_context()) 20 | 21 | def initialize(self, preset): 22 | preset = parameters[preset] 23 | return initialize(**preset) 24 | 25 | def validate(self, args, res): 26 | # Assume numpy impl is valid 27 | pass 28 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/weather_stencils/hdiff/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014-2021 ETH Zurich 2 | # SPDX-FileCopyrightText: 2007 Free Software Foundation, Inc. 3 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 4 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 5 | # 6 | # SPDX-License-Identifier: GPL-3.0-or-later 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/weather_stencils/vadv/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014-2021 ETH Zurich 2 | # SPDX-FileCopyrightText: 2007 Free Software Foundation, Inc. 3 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 4 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 5 | # 6 | # SPDX-License-Identifier: GPL-3.0-or-later 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import get_numpy_context 11 | 12 | 13 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 14 | params = presets 15 | param_names = ["preset"] 16 | 17 | def get_func(self): 18 | return get_impl(get_numpy_context()) 19 | 20 | def initialize(self, preset): 21 | preset = parameters[preset] 22 | return initialize(**preset) 23 | 24 | def validate(self, args, res): 25 | # Assume numpy impl is valid 26 | pass 27 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/mandelbrot1/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Nicolas P. Rougier 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Mandelbrot1" 9 | 10 | [benchmark.parameters.S] 11 | xmin = -1.75 12 | xmax = 0.25 13 | xn = 125 14 | ymin = -1.0 15 | ymax = 1.0 16 | yn = 125 17 | maxiter = 60 18 | horizon = 2.0 19 | 20 | [benchmark.parameters.M] 21 | xmin = -1.75 22 | xmax = 0.25 23 | xn = 250 24 | ymin = -1.0 25 | ymax = 1.0 26 | yn = 250 27 | maxiter = 150 28 | horizon = 2.0 29 | 30 | [benchmark.parameters.L] 31 | xmin = -2.0 32 | xmax = 0.5 33 | xn = 833 34 | ymin = -1.25 35 | ymax = 1.25 36 | yn = 833 37 | maxiter = 200 38 | horizon = 2.0 39 | 40 | [benchmark.parameters.paper] 41 | xmin = -2.25 42 | xmax = 0.75 43 | xn = 1000 44 | ymin = -1.25 45 | ymax = 1.25 46 | yn = 1000 47 | maxiter = 200 48 | horizon = 2.0 49 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/mandelbrot2/config.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Nicolas P. Rougier 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | [benchmark] 8 | name = "Mandelbrot2" 9 | 10 | [benchmark.parameters.S] 11 | xmin = -2.0 12 | xmax = 0.5 13 | xn = 200 14 | ymin = -1.25 15 | ymax = 1.25 16 | yn = 200 17 | itermax = 40 18 | horizon = 2.0 19 | 20 | [benchmark.parameters.M] 21 | xmin = -2.0 22 | xmax = 0.5 23 | xn = 500 24 | ymin = -1.25 25 | ymax = 1.25 26 | yn = 500 27 | itermax = 80 28 | horizon = 2.0 29 | 30 | [benchmark.parameters.L] 31 | xmin = -2.25 32 | xmax = 0.75 33 | xn = 1000 34 | ymin = -1.5 35 | ymax = 1.5 36 | yn = 1000 37 | itermax = 100 38 | horizon = 2.0 39 | 40 | [benchmark.parameters.paper] 41 | xmin = -2.25 42 | xmax = 0.75 43 | xn = 1000 44 | ymin = -1.25 45 | ymax = 1.25 46 | yn = 1000 47 | itermax = 200 48 | horizon = 2.0 49 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/contour_integral/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl(get_numba_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res) 30 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/CastLowering.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "numba/Dialect/plier/Dialect.hpp" 10 | 11 | #include 12 | 13 | namespace mlir { 14 | class TypeConverter; 15 | } 16 | 17 | namespace numba { 18 | struct CastOpLowering : public mlir::OpRewritePattern { 19 | using cast_t = std::function; 21 | 22 | CastOpLowering(mlir::TypeConverter &typeConverter, mlir::MLIRContext *context, 23 | cast_t cast_func = nullptr); 24 | 25 | mlir::LogicalResult 26 | matchAndRewrite(plier::CastOp op, 27 | mlir::PatternRewriter &rewriter) const override; 28 | 29 | private: 30 | mlir::TypeConverter &converter; 31 | cast_t castFunc; 32 | }; 33 | } // namespace numba 34 | -------------------------------------------------------------------------------- /mlir/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | # Needed for llvm lit to work. 6 | find_package (Python3 COMPONENTS Interpreter REQUIRED) 7 | 8 | configure_lit_site_cfg( 9 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in 10 | ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py 11 | MAIN_CONFIG 12 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py 13 | ) 14 | 15 | set(NUMBA_MLIR_TEST_DEPENDS 16 | FileCheck 17 | level_zero_runner 18 | numba-mlir-opt 19 | numba-mlir-runtime 20 | ) 21 | 22 | add_lit_testsuite(check-numba-mlir "Running the numba mlir regression tests" 23 | ${CMAKE_CURRENT_BINARY_DIR} 24 | DEPENDS ${NUMBA_MLIR_TEST_DEPENDS} 25 | ) 26 | set_target_properties(check-numba-mlir PROPERTIES FOLDER "Tests") 27 | 28 | add_lit_testsuites(numba-mlir-tests ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${NUMBA_MLIR_TEST_DEPENDS}) 29 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir/settings.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | 6 | from .utils import readenv 7 | from ..mlir_compiler import is_mkl_supported, is_sycl_mkl_supported 8 | 9 | 10 | USE_MLIR = readenv("NUMBA_MLIR_ENABLE", int, 1) 11 | DUMP_PLIER = readenv("NUMBA_MLIR_DUMP_PLIER", int, 0) 12 | DUMP_IR = readenv("NUMBA_MLIR_DUMP_IR", int, 0) 13 | DUMP_DIAGNOSTICS = readenv("NUMBA_MLIR_DUMP_DIAGNOSTICS", int, 0) 14 | DUMP_LLVM = readenv("NUMBA_MLIR_DUMP_LLVM", int, 0) 15 | DUMP_OPTIMIZED = readenv("NUMBA_MLIR_DUMP_OPTIMIZED", int, 0) 16 | DUMP_ASSEMBLY = readenv("NUMBA_MLIR_DUMP_ASSEMBLY", int, 0) 17 | DEBUG_TYPE = list(filter(None, readenv("NUMBA_MLIR_DEBUG_TYPE", str, "").split(","))) 18 | MKL_AVAILABLE = is_mkl_supported() 19 | SYCL_MKL_AVAILABLE = is_sycl_mkl_supported() 20 | OPT_LEVEL = readenv("NUMBA_MLIR_OPT_LEVEL", int, 3) 21 | DISABLE_VECTORIZE = readenv("NUMBA_MLIR_DISABLE_VECTORIZE", int, 0) 22 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/CheckGpuCaps.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include "CheckGpuCaps.hpp" 6 | 7 | #include 8 | 9 | namespace py = pybind11; 10 | 11 | std::optional> 12 | numba::getDefaultDevice() { 13 | py::object mod = py::module::import("numba_mlir.mlir.dpctl_interop"); 14 | py::object res = mod.attr("get_default_device")(); 15 | if (res.is_none()) 16 | return std::nullopt; 17 | 18 | numba::OffloadDeviceCapabilities caps{}; 19 | auto name = res.attr("filter_string").cast(); 20 | caps.spirvMajorVersion = res.attr("spirv_major_version").cast(); 21 | caps.spirvMinorVersion = res.attr("spirv_minor_version").cast(); 22 | caps.hasFP16 = res.attr("has_fp16").cast(); 23 | caps.hasFP64 = res.attr("has_fp64").cast(); 24 | return std::pair{name, caps}; 25 | } 26 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/scattering_self_energies/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import ( 10 | get_numba_context, 11 | get_numpy_context, 12 | assert_allclose_recursive, 13 | ) 14 | 15 | 16 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 17 | params = presets 18 | param_names = ["preset"] 19 | 20 | def get_func(self): 21 | return get_impl(get_numba_context()) 22 | 23 | def initialize(self, preset): 24 | preset = parameters[preset] 25 | return initialize(**preset) 26 | 27 | def validate(self, args, res): 28 | np_ver = get_impl(get_numpy_context()) 29 | np_res = np_ver(*args) 30 | assert_allclose_recursive(res, np_res) 31 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/contour_integral/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import ( 10 | get_numba_mlir_context, 11 | get_numpy_context, 12 | assert_allclose_recursive, 13 | ) 14 | 15 | 16 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 17 | params = presets 18 | param_names = ["preset"] 19 | 20 | def get_func(self): 21 | return get_impl(get_numba_mlir_context()) 22 | 23 | def initialize(self, preset): 24 | preset = parameters[preset] 25 | return initialize(**preset) 26 | 27 | def validate(self, args, res): 28 | np_ver = get_impl(get_numpy_context()) 29 | np_res = np_ver(*args) 30 | assert_allclose_recursive(res, np_res) 31 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/stockham_fft/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/scattering_self_energies/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import ( 10 | get_numba_mlir_context, 11 | get_numpy_context, 12 | assert_allclose_recursive, 13 | ) 14 | 15 | 16 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 17 | params = presets 18 | param_names = ["preset"] 19 | 20 | def get_func(self): 21 | return get_impl(get_numba_mlir_context()) 22 | 23 | def initialize(self, preset): 24 | preset = parameters[preset] 25 | return initialize(**preset) 26 | 27 | def validate(self, args, res): 28 | np_ver = get_impl(get_numpy_context()) 29 | np_res = np_ver(*args) 30 | assert_allclose_recursive(res, np_res) 31 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/mlp/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/softmax/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_mlir_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl(get_numba_mlir_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/stockham_fft/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_mlir_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_mlir_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res) 30 | -------------------------------------------------------------------------------- /numba_mlir_runtime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | project(numba-mlir-runtime LANGUAGES CXX C) 6 | 7 | include(GenerateExportHeader) 8 | 9 | if(NUMBA_MLIR_ENABLE_TBB_SUPPORT) 10 | find_package(TBB REQUIRED) 11 | endif() 12 | 13 | find_package(MLIR REQUIRED CONFIG) 14 | 15 | set(SOURCES_LIST 16 | lib/AllocToken.cpp 17 | lib/Context.cpp 18 | lib/Memory.cpp 19 | lib/TbbParallel.cpp 20 | ) 21 | set(HEADERS_LIST 22 | ) 23 | 24 | add_library(${PROJECT_NAME} SHARED ${SOURCES_LIST} ${HEADERS_LIST}) 25 | generate_export_header(${PROJECT_NAME}) 26 | 27 | target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE 28 | ${MLIR_INCLUDE_DIRS} 29 | PRIVATE 30 | ${PROJECT_BINARY_DIR} 31 | ) 32 | 33 | if(NUMBA_MLIR_ENABLE_TBB_SUPPORT) 34 | target_compile_definitions(${PROJECT_NAME} PRIVATE NUMBA_MLIR_ENABLE_TBB_SUPPORT=1) 35 | target_link_libraries(${PROJECT_NAME} TBB::tbb) 36 | endif() 37 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/crc16/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2018 Øystein Sture 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import ( 10 | get_numba_context, 11 | get_numpy_context, 12 | assert_allclose_recursive, 13 | ) 14 | 15 | 16 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 17 | params = presets 18 | param_names = ["preset"] 19 | 20 | def get_func(self): 21 | return get_impl(get_numba_context()) 22 | 23 | def initialize(self, preset): 24 | preset = parameters[preset] 25 | return initialize(**preset) 26 | 27 | def validate(self, args, res): 28 | np_ver = get_impl(get_numpy_context()) 29 | np_res = np_ver(*args) 30 | assert_allclose_recursive(res, np_res) 31 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/lenet/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/softmax/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/contour_integral/numba_replace_parfor.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_replace_parfor_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl(get_numba_replace_parfor_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/conv2d_bias/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/spmv/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | # Sparse Matrix-Vector Multiplication (SpMV) 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/mlp/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_mlir_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_mlir_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /mlir/include/numba/Transforms/CastUtils.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | namespace mlir { 8 | class Value; 9 | class Location; 10 | class OpBuilder; 11 | class Type; 12 | class IntegerType; 13 | class MemRefType; 14 | } // namespace mlir 15 | 16 | namespace numba { 17 | mlir::Value indexCast(mlir::OpBuilder &builder, mlir::Location loc, 18 | mlir::Value src, mlir::Type dst_type); 19 | mlir::Value indexCast(mlir::OpBuilder &builder, mlir::Location loc, 20 | mlir::Value src); 21 | 22 | mlir::Type makeSignlessType(mlir::Type type); 23 | mlir::IntegerType makeSignlessType(mlir::IntegerType type); 24 | mlir::MemRefType makeSignlessType(mlir::MemRefType type); 25 | 26 | bool canConvert(mlir::Type srcType, mlir::Type dstType); 27 | mlir::Value doConvert(mlir::OpBuilder &rewriter, mlir::Location loc, 28 | mlir::Value val, mlir::Type dstType); 29 | } // namespace numba 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/crc16/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2018 Øystein Sture 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import ( 10 | get_numba_mlir_context, 11 | get_numpy_context, 12 | assert_allclose_recursive, 13 | ) 14 | 15 | 16 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 17 | params = presets 18 | param_names = ["preset"] 19 | 20 | def get_func(self): 21 | return get_impl(get_numba_mlir_context()) 22 | 23 | def initialize(self, preset): 24 | preset = parameters[preset] 25 | return initialize(**preset) 26 | 27 | def validate(self, args, res): 28 | np_ver = get_impl(get_numpy_context()) 29 | np_res = np_ver(*args) 30 | assert_allclose_recursive(res, np_res) 31 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/lenet/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_mlir_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_mlir_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/resnet/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_mlir_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_mlir_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=0.002) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/conv2d_bias/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_mlir_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_mlir_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/pythran/arc_distance/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2019 Serge Guelton 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/scattering_self_energies/numba_replace_parfor.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | 7 | from .common import initialize, get_impl, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import ( 10 | get_numba_replace_parfor_context, 11 | get_numpy_context, 12 | assert_allclose_recursive, 13 | ) 14 | 15 | 16 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 17 | params = presets 18 | param_names = ["preset"] 19 | 20 | def get_func(self): 21 | return get_impl(get_numba_replace_parfor_context()) 22 | 23 | def initialize(self, preset): 24 | preset = parameters[preset] 25 | return initialize(**preset) 26 | 27 | def validate(self, args, res): 28 | np_ver = get_impl(get_numpy_context()) 29 | np_res = np_ver(*args) 30 | assert_allclose_recursive(res, np_res) 31 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/spmv/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | # Sparse Matrix-Vector Multiplication (SpMV) 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_mlir_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_mlir_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/math_runtime/include/Common.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | #define fatal_failure(format, ...) \ 11 | do { \ 12 | fprintf(stderr, format, ##__VA_ARGS__); \ 13 | fflush(stderr); \ 14 | abort(); \ 15 | } while (0) 16 | 17 | template struct Memref { 18 | void *userData; 19 | T *data; 20 | size_t offset; 21 | std::array dims; 22 | std::array strides; 23 | }; 24 | 25 | template 26 | static T *getMemrefData(const Memref *src) { 27 | return src->data + src->offset; 28 | } 29 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/compute/numpy.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Stefan Behnel, Robert Bradshaw, 2 | # Dag Sverre Seljebotn, Greg Ewing, William Stein, Gabriel Gellner, et al. 3 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 4 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 5 | # 6 | # SPDX-License-Identifier: BSD-3-Clause 7 | 8 | # https://cython.readthedocs.io/en/latest/src/userguide/numpy_tutorial.html 9 | 10 | from .common import initialize, get_impl, parameters, presets 11 | import numba_mlir.mlir.benchmarking 12 | from numba_mlir.mlir.benchmarking import get_numpy_context 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl(get_numpy_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | # Assume numpy impl is valid 28 | pass 29 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/stockham_fft/numba_replace_parfor.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_replace_parfor_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_replace_parfor_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res) 30 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/python_runtime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | project(numba-mlir-python-runtime LANGUAGES CXX C) 6 | 7 | # Use pybind11 cmake as it more robust than find_package(Python3) 8 | find_package(pybind11 REQUIRED) 9 | 10 | include(GenerateExportHeader) 11 | 12 | set(SOURCES_LIST 13 | lib/Boxing.cpp 14 | lib/PythonRt.cpp 15 | ) 16 | set(HEADERS_LIST 17 | lib/PythonRt.hpp 18 | ) 19 | 20 | add_library(${PROJECT_NAME} SHARED ${SOURCES_LIST} ${HEADERS_LIST}) 21 | generate_export_header(${PROJECT_NAME}) 22 | 23 | target_link_libraries(${PROJECT_NAME} PRIVATE pybind11::module) 24 | 25 | if (NOT Python3_NumPy_INCLUDE_DIRS) 26 | message(FATAL_ERROR "Python3_NumPy_INCLUDE_DIRS is not set") 27 | endif() 28 | message(STATUS "Python3_NumPy_INCLUDE_DIRS ${Python3_NumPy_INCLUDE_DIRS}") 29 | 30 | target_include_directories(${PROJECT_NAME} PRIVATE 31 | ${PROJECT_BINARY_DIR} 32 | ${Python3_NumPy_INCLUDE_DIRS} 33 | ) 34 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/deriche/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/medley/nussinov/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/heat_3d/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /numba_mlir/numba_mlir/mlir_compiler/lib/pipelines/BasePipeline.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 - 2022 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | #include "pipelines/BasePipeline.hpp" 6 | 7 | #include "numba/Compiler/PipelineRegistry.hpp" 8 | 9 | namespace { 10 | static const constexpr llvm::StringLiteral passes[] = { 11 | "init", 12 | "lowering", 13 | "terminate", 14 | }; 15 | 16 | void dummyPassFunc(mlir::OpPassManager &) {} 17 | } // namespace 18 | 19 | void registerBasePipeline(numba::PipelineRegistry ®istry) { 20 | for (std::size_t i = 0; i < std::size(passes); ++i) { 21 | registry.registerPipeline([i](auto sink) { 22 | if (0 == i) { 23 | sink(passes[i], {}, {}, {}, dummyPassFunc); 24 | } else { 25 | sink(passes[i], {passes[i - 1]}, {}, {}, dummyPassFunc); 26 | } 27 | }); 28 | } 29 | } 30 | 31 | PipelineStage getHighLoweringStage() { return {passes[0], passes[1]}; } 32 | 33 | PipelineStage getLowerLoweringStage() { return {passes[1], passes[2]}; } 34 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/pythran/arc_distance/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2019 Serge Guelton 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_mlir_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_mlir_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/jacobi_1d/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/stencils/jacobi_2d/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/deep_learning/mlp/numba_replace_parfor.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 2 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 3 | # 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 7 | import numba_mlir.mlir.benchmarking 8 | from numba_mlir.mlir.benchmarking import ( 9 | get_numba_replace_parfor_context, 10 | get_numpy_context, 11 | assert_allclose_recursive, 12 | ) 13 | 14 | 15 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 16 | params = presets 17 | param_names = ["preset"] 18 | 19 | def get_func(self): 20 | return get_impl_numba(get_numba_replace_parfor_context()) 21 | 22 | def initialize(self, preset): 23 | preset = parameters[preset] 24 | return initialize(**preset) 25 | 26 | def validate(self, args, res): 27 | np_ver = get_impl(get_numpy_context()) 28 | np_res = np_ver(*args) 29 | assert_allclose_recursive(res, np_res, rtol=1e-05) 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/npbench/nbody/numba_mlir.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 Philip Mocz 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | from .common import initialize, get_impl, get_impl_numba, parameters, presets 8 | import numba_mlir.mlir.benchmarking 9 | from numba_mlir.mlir.benchmarking import ( 10 | get_numba_mlir_context, 11 | get_numpy_context, 12 | assert_allclose_recursive, 13 | ) 14 | 15 | 16 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 17 | params = presets 18 | param_names = ["preset"] 19 | 20 | def get_func(self): 21 | return get_impl_numba(get_numba_mlir_context()) 22 | 23 | def initialize(self, preset): 24 | preset = parameters[preset] 25 | return initialize(**preset) 26 | 27 | def validate(self, args, res): 28 | np_ver = get_impl(get_numpy_context()) 29 | np_res = np_ver(*args) 30 | assert_allclose_recursive(res, np_res) 31 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gemm/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/gemver/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/polybench/linear_algebra/blas/symm/numba.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2010-2016 Ohio State University 2 | # SPDX-FileCopyrightText: 2021 ETH Zurich and the NPBench authors 3 | # SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | 7 | 8 | from .common import initialize, get_impl, parameters, presets 9 | import numba_mlir.mlir.benchmarking 10 | from numba_mlir.mlir.benchmarking import ( 11 | get_numba_context, 12 | get_numpy_context, 13 | assert_allclose_recursive, 14 | ) 15 | 16 | 17 | class Benchmark(numba_mlir.mlir.benchmarking.BenchmarkBase): 18 | params = presets 19 | param_names = ["preset"] 20 | 21 | def get_func(self): 22 | return get_impl(get_numba_context()) 23 | 24 | def initialize(self, preset): 25 | preset = parameters[preset] 26 | return initialize(**preset) 27 | 28 | def validate(self, args, res): 29 | np_ver = get_impl(get_numpy_context()) 30 | np_res = np_ver(*args) 31 | assert_allclose_recursive(res, np_res) 32 | --------------------------------------------------------------------------------