├── docs ├── demos │ └── apt.txt ├── assets │ ├── viz │ │ ├── fuse1.png │ │ ├── fuse2.png │ │ ├── fuse3.png │ │ ├── fuse1a.png │ │ ├── fuse1b.png │ │ ├── fuse2a.png │ │ ├── fuse2a_A.png │ │ ├── fuse2b.png │ │ ├── fuse3a.png │ │ ├── fuse3b.png │ │ ├── fuse3c.png │ │ ├── space_12_15_3.png │ │ ├── space_3_12_15.png │ │ ├── fuse1b_animated.gif │ │ ├── fuse2b_animated.gif │ │ ├── AMD_FP32_16x16x4_1.png │ │ ├── space_3_12_15_slice.png │ │ ├── space_3_12_15_postsplit.png │ │ ├── space_3_12_15_presplit.png │ │ ├── space_3_15_15_postsplit.png │ │ ├── space_3_15_15_presplit.png │ │ ├── space_3_4_3_15_slice1.png │ │ ├── space_3_4_3_15_slice2.png │ │ ├── space_3_4_3_15_slice3.png │ │ └── AMD_FP32_32x32x2_1_animated.gif │ └── logos │ │ ├── favicon.png │ │ ├── A_darktext.png │ │ ├── A_lighttext.png │ │ ├── Accera_darktext.png │ │ └── Accera_lighttext.png ├── CMakeLists.txt ├── .bumpversion.cfg ├── Tutorials │ ├── hello_matmul_gpu │ │ ├── matmul_utils.py │ │ ├── tensor_input_output_cache_matmul_gpu_generator.py │ │ ├── tensor_zero_init_matmul_gpu_generator.py │ │ ├── tensor_alpha_scaling_matmul_gpu_generator.py │ │ ├── tensor_sched_policy_matmul_gpu_generator.py │ │ └── tensor_input_double_buffer_cache_matmul_gpu_generator.py │ ├── hello_matmul │ │ ├── hello_matmul_runner.cpp │ │ └── hello_matmul_generator.py │ ├── cross_compilation_pi3 │ │ └── hello_matmul_pi3_runner.cpp │ └── optimized_matmul │ │ └── optimized_matmul_runner.cpp ├── Reference │ ├── classes │ │ ├── Target │ │ │ ├── Category.md │ │ │ ├── Runtime.md │ │ │ └── Architecture.md │ │ ├── Nest │ │ │ ├── create_schedule.md │ │ │ ├── get_indices.md │ │ │ ├── Nest.md │ │ │ └── create_plan.md │ │ ├── Package │ │ │ ├── Package.md │ │ │ ├── Mode.md │ │ │ ├── Platform.md │ │ │ ├── Format.md │ │ │ └── add_description.md │ │ ├── FusedSchedule │ │ │ ├── get_fusing_index.md │ │ │ ├── get_fused_indices.md │ │ │ └── get_unfused_indices.md │ │ ├── Schedule │ │ │ ├── get_indices.md │ │ │ ├── create_plan.md │ │ │ ├── pad.md │ │ │ ├── tile.md │ │ │ ├── skew.md │ │ │ ├── split.md │ │ │ └── reorder.md │ │ ├── Plan │ │ │ ├── unroll.md │ │ │ ├── vectorize.md │ │ │ └── kernelize.md │ │ ├── Array │ │ │ └── Layout.md │ │ └── Scalar │ │ │ └── Scalar.md │ ├── functions │ │ └── create_parameters.md │ └── enumerations │ │ ├── Role.md │ │ ├── MMAFragmentOp.md │ │ ├── ScalarType.md │ │ ├── MMASchedulingPolicy.md │ │ └── CacheStrategy.md ├── Install │ ├── README.md │ ├── Installing_Accera_on_Ubuntu.md │ └── Installing_Accera_on_MacOS.md ├── build.bat ├── build.sh ├── update_versions.sh ├── Manual │ └── README.md └── Case Studies │ └── README.md ├── tools ├── viz │ ├── gif │ │ └── requirements.txt │ ├── .gitignore │ ├── requirements.txt │ ├── static │ │ └── styles.css │ ├── README.md │ ├── run.sh │ └── run.bat ├── CMakeLists.txt └── benchmarkers │ ├── .gitignore │ ├── CMakeLists.txt │ ├── gemm_big.csv │ ├── gemm_big_A6000.csv │ ├── gemm_big_MI100.csv │ ├── cublas │ └── CMakeLists.txt │ ├── rocblas │ └── CMakeLists.txt │ ├── requirements.txt │ ├── gemm_small_A6000.csv │ ├── gemm_small_MI100.csv │ ├── gemm_small.csv │ ├── config.py │ ├── gemm_bert_assorted.csv │ ├── gemm_rectangle_A6000.csv │ ├── gemm_rectangle_MI100.csv │ └── gemm_square.csv ├── accera ├── ir │ ├── src │ │ ├── nest │ │ │ ├── LoopNestInterfaces.cpp │ │ │ ├── AffineExpression.cpp │ │ │ └── OperandIndex.cpp │ │ ├── intrinsics │ │ │ └── AcceraIntrinsicsDialect.cpp │ │ └── accera │ │ │ └── AcceraOps.cpp │ ├── test │ │ ├── CMakeLists.txt │ │ ├── ir_tests │ │ │ └── CMakeLists.txt │ │ └── nest_dialect_test │ │ │ ├── CMakeLists.txt │ │ │ ├── nest_test_main.cpp │ │ │ ├── Test.h │ │ │ ├── LoopNestTestVerification.h │ │ │ └── IRTestVerification.h │ └── include │ │ ├── InitializeAccera.h │ │ ├── value │ │ ├── ValueEnums.h │ │ ├── ValueAttributes.h │ │ ├── ValueRangeOp.h │ │ └── CMakeLists.txt │ │ ├── nest │ │ ├── LoopNestInterfaces.h │ │ ├── LoopIndexInfo.h │ │ └── LoopNestExportedInterfaces.td │ │ ├── CMakeLists.txt │ │ ├── DialectRegistry.h │ │ ├── intrinsics │ │ ├── CMakeLists.txt │ │ └── AcceraIntrinsicsDialect.h │ │ ├── exec │ │ ├── ExecutionPlanEnums.h │ │ ├── InPlaceUnrollInfo.h │ │ ├── ExecutionPlanInterfaces.td │ │ ├── ParallelizationInfo.h │ │ └── VectorizationInfo.h │ │ ├── argo │ │ ├── ArgoTypes.h │ │ ├── ArgoBase.td │ │ └── CMakeLists.txt │ │ ├── accera │ │ └── CMakeLists.txt │ │ ├── LLVMEmitterTargets.h.in │ │ └── TranslateToHeader.h ├── python │ ├── .gitignore │ ├── llvm │ │ ├── pyproject.toml │ │ ├── src │ │ │ └── __init__.py │ │ └── CMakeLists.txt │ ├── samples │ │ └── __init__.py │ ├── gpu │ │ ├── pyproject.toml │ │ ├── src │ │ │ └── __init__.py │ │ ├── CMakeLists.txt │ │ └── setup.cfg │ ├── compilers │ │ ├── pyproject.toml │ │ ├── src │ │ │ └── __init__.py │ │ ├── CMakeLists.txt │ │ └── setup.cfg │ └── accera │ │ ├── Constants.py │ │ ├── algorithms │ │ └── __init__.py │ │ ├── lang │ │ ├── __init__.py │ │ ├── DimensionUtilities.py │ │ ├── LoopIndex.py │ │ └── NativeLoopNestContext.py │ │ └── __init__.py ├── onnx-emitter │ ├── test │ │ ├── requirements.txt │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── hat │ └── scripts │ │ └── __init__.py ├── acc-translate │ └── src │ │ ├── CMakeLists.txt │ │ └── Target │ │ ├── CMakeLists.txt │ │ ├── LLVMIR │ │ ├── CMakeLists.txt │ │ └── IntrinsicToLLVMIRTranslation.h │ │ └── Cpp │ │ ├── AMDGPU.h │ │ ├── TranslateToCpp.h │ │ └── LLVMDialectCppPrinter.h ├── transforms │ ├── src │ │ ├── CMakeLists.txt │ │ ├── nest │ │ │ ├── CMakeLists.txt │ │ │ └── LoopNestToValue.td │ │ ├── value │ │ │ ├── CMakeLists.txt │ │ │ └── ValueConversion.td │ │ ├── util │ │ │ └── DebugUtilities.cpp │ │ └── gpu │ │ │ └── SerializeToHSACO.cpp │ └── include │ │ ├── CMakeLists.txt │ │ ├── util │ │ ├── DebugUtilities.h │ │ ├── MathUtilities.h │ │ └── DebugFunctionPass.h │ │ ├── affine │ │ ├── AffineLoopNormalize.h │ │ ├── AffineSimplifications.h │ │ └── CheckBoundsPass.h │ │ ├── value │ │ ├── ValueUnrollingPass.h │ │ ├── BarrierOptPass.h │ │ ├── RangeValueOptimizePass.h │ │ ├── FunctionPointerResolutionPass.h │ │ ├── ValueSimplifyPass.h │ │ └── ValueFuncToTargetPass.h │ │ ├── nest │ │ └── LoopNestPasses.h │ │ ├── gpu │ │ └── AcceraVulkanPasses.h │ │ └── vectorization │ │ └── VectorizationPass.h ├── testing │ ├── src │ │ └── CatchMain.cpp │ └── CMakeLists.txt ├── vulkanRuntime │ └── README.md ├── acc-opt │ └── test │ │ ├── commandline.mlir │ │ ├── lit.site.cfg.py.in │ │ └── ValueFuncToTarget.mlir ├── value │ ├── include │ │ ├── ScalarIndex.h │ │ ├── FastMath.h │ │ ├── VectorizationInformation.h │ │ ├── Index.h │ │ ├── ExecutionOptions.h │ │ ├── Range.h │ │ ├── IterationDomain.h │ │ ├── ScalarDimension.h │ │ ├── Profiling.h │ │ ├── ArrayOperations.h │ │ └── MLOperations.h │ ├── test │ │ └── include │ │ │ ├── Functions_test.h │ │ │ ├── Tensor_test.h │ │ │ ├── Vector_test.h │ │ │ ├── Matrix_test.h │ │ │ ├── LoopNest_convolution_test.h │ │ │ └── Scalar_test.h │ └── src │ │ ├── Emittable.cpp │ │ ├── ScalarDimension.cpp │ │ └── Profiling.cpp ├── toml │ └── CMakeLists.txt ├── runtime │ ├── CMakeLists.txt │ └── include │ │ └── Random.h ├── export │ └── AcceraConfig.cmake.in ├── mlirHelpers │ ├── include │ │ ├── TranslateToLLVMIR.h │ │ └── ConvertToLLVM.h │ └── src │ │ └── TranslateToLLVMIR.cpp ├── acc-gpu-runner │ └── acc_gpu_runner_config.py.in ├── acc-lsp-server │ ├── CMakeLists.txt │ └── src │ │ └── acc-lsp-server.cpp ├── utilities │ ├── test │ │ └── src │ │ │ ├── Hash_test.cpp │ │ │ └── TypeName_test.cpp │ └── src │ │ └── TypeName.cpp └── CMakeLists.txt ├── .azure ├── cuda │ ├── .gitignore │ ├── scripts │ │ ├── install.dbgdeps.sh │ │ └── install.azp.sh │ ├── build_agent.sh │ └── Dockerfile ├── rocm │ ├── .gitignore │ ├── scripts │ │ ├── install.dbgdeps.sh │ │ ├── install.builddeps.sh │ │ └── install.azp.sh │ └── build_agent.sh └── manylinux │ ├── scripts │ ├── install.vcpkg.sh │ ├── install.manylinux.sh │ └── install.vulkanloader.sh │ ├── manylinux-llvm.yml │ └── Dockerfile ├── .dockerignore ├── .gitmodules ├── external └── llvm │ ├── vcpkg.json │ ├── lld_usage │ ├── mlir_usage │ ├── llvm_usage │ ├── 0005-Fix-issue-where-passed-in-op-printing-flags-were-ign.patch │ └── README.md ├── .github ├── pull_request_template.md ├── workflows │ └── docs.yml └── ISSUE_TEMPLATE │ ├── question.md │ └── feature_request.md ├── requirements.txt ├── .style.yapf ├── CODE_OF_CONDUCT.md ├── SUPPORT.md ├── CMake ├── Catch2Setup.cmake ├── BuildTargetSetup.cmake ├── LLVMSetupDefault.cmake ├── AddPyBind11.cmake ├── CompilerCache.cmake ├── GetGitVersion.cmake └── VulkanSetup.cmake ├── pyproject.toml ├── setup.py └── LICENSE /docs/demos/apt.txt: -------------------------------------------------------------------------------- 1 | gcc 2 | -------------------------------------------------------------------------------- /tools/viz/gif/requirements.txt: -------------------------------------------------------------------------------- 1 | Pillow -------------------------------------------------------------------------------- /accera/ir/src/nest/LoopNestInterfaces.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /accera/python/.gitignore: -------------------------------------------------------------------------------- 1 | _lang_python.* 2 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(benchmarkers) 2 | -------------------------------------------------------------------------------- /tools/benchmarkers/.gitignore: -------------------------------------------------------------------------------- 1 | *.csv 2 | *.cu 3 | *.hat 4 | _tmp/ 5 | -------------------------------------------------------------------------------- /.azure/cuda/.gitignore: -------------------------------------------------------------------------------- 1 | # created when running run_agent.sh in debug mode 2 | .token -------------------------------------------------------------------------------- /.azure/rocm/.gitignore: -------------------------------------------------------------------------------- 1 | # created when running run_agent.sh in debug mode 2 | .token -------------------------------------------------------------------------------- /tools/viz/.gitignore: -------------------------------------------------------------------------------- 1 | visualizations/output/ 2 | gif/*.gif 3 | static/Accera_*.svg -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | build/ 2 | external/vcpkg/downloads 3 | external/vcpkg/buildtrees 4 | *.egg-info -------------------------------------------------------------------------------- /tools/benchmarkers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(cublas) 2 | add_subdirectory(rocblas) 3 | -------------------------------------------------------------------------------- /docs/assets/viz/fuse1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse1.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse2.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse3.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse1a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse1a.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse1b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse1b.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse2a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse2a.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse2a_A.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse2a_A.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse2b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse2b.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse3a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse3a.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse3b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse3b.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse3c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse3c.png -------------------------------------------------------------------------------- /docs/assets/logos/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/logos/favicon.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/vcpkg"] 2 | path = external/vcpkg 3 | url = https://github.com/microsoft/vcpkg 4 | -------------------------------------------------------------------------------- /docs/assets/logos/A_darktext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/logos/A_darktext.png -------------------------------------------------------------------------------- /docs/assets/logos/A_lighttext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/logos/A_lighttext.png -------------------------------------------------------------------------------- /docs/assets/viz/space_12_15_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_12_15_3.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_12_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_12_15.png -------------------------------------------------------------------------------- /docs/assets/viz/fuse1b_animated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse1b_animated.gif -------------------------------------------------------------------------------- /docs/assets/viz/fuse2b_animated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/fuse2b_animated.gif -------------------------------------------------------------------------------- /tools/viz/requirements.txt: -------------------------------------------------------------------------------- 1 | bottle==0.12.20 2 | 3 | # optional dependency for exporting to video 4 | # ffmpeg-python==0.2.0 -------------------------------------------------------------------------------- /docs/assets/logos/Accera_darktext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/logos/Accera_darktext.png -------------------------------------------------------------------------------- /docs/assets/logos/Accera_lighttext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/logos/Accera_lighttext.png -------------------------------------------------------------------------------- /docs/assets/viz/AMD_FP32_16x16x4_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/AMD_FP32_16x16x4_1.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_12_15_slice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_12_15_slice.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_12_15_postsplit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_12_15_postsplit.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_12_15_presplit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_12_15_presplit.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_15_15_postsplit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_15_15_postsplit.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_15_15_presplit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_15_15_presplit.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_4_3_15_slice1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_4_3_15_slice1.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_4_3_15_slice2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_4_3_15_slice2.png -------------------------------------------------------------------------------- /docs/assets/viz/space_3_4_3_15_slice3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/space_3_4_3_15_slice3.png -------------------------------------------------------------------------------- /accera/onnx-emitter/test/requirements.txt: -------------------------------------------------------------------------------- 1 | onnx==1.13.0 2 | onnxruntime==1.7.0 3 | protobuf==3.20.2 # tied to the version of onnx above 4 | sympy -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Install) 2 | add_subdirectory(Manual) 3 | add_subdirectory(Miscellaneous) 4 | add_subdirectory(Reference) -------------------------------------------------------------------------------- /docs/assets/viz/AMD_FP32_32x32x2_1_animated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Accera/main/docs/assets/viz/AMD_FP32_32x32x2_1_animated.gif -------------------------------------------------------------------------------- /accera/python/llvm/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel", 5 | "pybind11>=2.6.0", 6 | "conan" 7 | ] 8 | 9 | build-backend = "setuptools.build_meta" -------------------------------------------------------------------------------- /accera/hat/scripts/__init__.py: -------------------------------------------------------------------------------- 1 | from .onnx_hat_package import ONNXHATPackage 2 | 3 | _package_exports = [ 4 | # Classes 5 | 'ONNXHATPackage' 6 | ] 7 | 8 | __all__ = _package_exports 9 | 10 | -------------------------------------------------------------------------------- /external/llvm/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "accera-llvm", 3 | "version-string": "15.0.0", 4 | "description": "LLVM Compiler Infrastructure for Accera.", 5 | "homepage": "https://llvm.org", 6 | "supports": "!uwp" 7 | } -------------------------------------------------------------------------------- /accera/python/samples/__init__.py: -------------------------------------------------------------------------------- 1 | from .MatrixMultiplication import MLAS, Options as MLASOptions 2 | from .OfflineCacheMatrixMultiplication import EmitTimeCacheMLAS, RuntimeInitCacheMLAS, Options as OfflineCacheMLASOptions 3 | -------------------------------------------------------------------------------- /accera/python/gpu/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "setuptools_scm[toml]", 5 | "wheel", 6 | "pybind11>=2.6.0", 7 | "conan" 8 | ] 9 | 10 | build-backend = "setuptools.build_meta" -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_big.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 2048,2048,2048,0,0,1,1,2048,2048,2048 3 | 2048,2048,2048,1,0,1,1,2048,2048,2048 4 | 4096,4096,4096,0,0,1,1,4096,4096,4096 5 | 4096,4096,4096,1,0,1,1,4096,4096,4096 -------------------------------------------------------------------------------- /accera/python/compilers/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "setuptools_scm[toml]", 5 | "wheel", 6 | "pybind11>=2.6.0", 7 | "conan" 8 | ] 9 | 10 | build-backend = "setuptools.build_meta" -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_big_A6000.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 1536,1152,2048,0,0,1,1,1536,2048,1536 3 | 1536,1152,2048,1,0,1,1,2048,2048,1536 4 | 3072,2304,4096,0,0,1,1,3072,4096,3072 5 | 3072,2304,4096,1,0,1,1,4096,4096,3072 -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_big_MI100.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 2560,1536,2048,0,0,1,1,2560,2048,2560 3 | 2560,1536,2048,1,0,1,1,2048,2048,2560 4 | 5120,3072,4096,0,0,1,1,5120,4096,5120 5 | 5120,3072,4096,1,0,1,1,4096,4096,5120 -------------------------------------------------------------------------------- /tools/benchmarkers/cublas/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(CUDAToolkit) # requires cmake >= 3.17 2 | 3 | if(TARGET CUDA::cublas) 4 | add_executable(cublas_gemm main.cpp) 5 | target_link_libraries(cublas_gemm CUDA::cudart CUDA::cublas) 6 | endif() 7 | -------------------------------------------------------------------------------- /external/llvm/lld_usage: -------------------------------------------------------------------------------- 1 | The package lld provides CMake targets: 2 | 3 | find_package(LLD CONFIG REQUIRED) 4 | target_include_directories(main PRIVATE ${LLD_INCLUDE_DIRS}) 5 | target_link_libraries(main PRIVATE lldCommon lldCore lldDriver ...) 6 | -------------------------------------------------------------------------------- /external/llvm/mlir_usage: -------------------------------------------------------------------------------- 1 | The package mlir provides CMake targets: 2 | 3 | find_package(MLIR CONFIG REQUIRED) 4 | target_include_directories(main PRIVATE ${MLIR_INCLUDE_DIRS}) 5 | target_link_libraries(main PRIVATE MLIRIR MLIRParser MLIRPass MLIRSupport ...) 6 | -------------------------------------------------------------------------------- /tools/benchmarkers/rocblas/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(rocblas_gemm EXCLUDE_FROM_ALL main.cpp) 2 | target_include_directories(rocblas_gemm PUBLIC /opt/rocm/include) 3 | target_link_directories(rocblas_gemm PUBLIC /opt/rocm/lib) 4 | target_link_libraries(rocblas_gemm rocblas amdhip64) 5 | -------------------------------------------------------------------------------- /tools/benchmarkers/requirements.txt: -------------------------------------------------------------------------------- 1 | azure-core==1.1.1 2 | azure-cosmos==4.2.0 3 | certifi==2019.11.28 4 | chardet==3.0.4 5 | gitpython==3.1.27 6 | idna==2.8 7 | requests>=2.22.0 8 | six==1.13.0 9 | urllib3>=1.26.5 10 | virtualenv==16.7.9 11 | virtualenv-clone==0.5.3 12 | progressbar==2.5 13 | psutil -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | **Describe the pull request** 2 | 3 | - #### What does your PR fix? 4 | Fixes #... 5 | 6 | - #### Is this a documentation-only fix? 7 | 8 | 9 | **If you are still working on the PR, open it as a Draft: https://github.blog/2019-02-14-introducing-draft-pull-requests/** 10 | -------------------------------------------------------------------------------- /docs/.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 1.2 3 | 4 | [bumpversion:glob:**/*.md] 5 | search = Version: v{current_version} 6 | replace = Version: v{new_version} 7 | 8 | [bumpversion:glob:Reference/**/*.md] 9 | search = Accera v{current_version} Reference 10 | replace = Accera v{new_version} Reference 11 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | setuptools>=42 2 | setuptools_scm 3 | pandas 4 | tomlkit>=0.11.1, <0.11.5 5 | wheel 6 | pybind11>=2.6.0 7 | six 8 | conan<2.0.0 9 | lit 10 | packaging 11 | pytest 12 | hatlib==0.0.39 # keep setup.cfg in sync; prefer == (avoids picking up breaking changes) 13 | varname 14 | py-cpuinfo 15 | termcolor 16 | -------------------------------------------------------------------------------- /docs/Tutorials/hello_matmul_gpu/matmul_utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import accera as acc 3 | 4 | def add_function_build_pkg(plan: acc.Plan, A, B, C, func_name: str): 5 | package = acc.Package() 6 | package.add(plan, args=(A, B, C), base_name=func_name) 7 | package.build(func_name, format=acc.Package.Format.HAT_SOURCE) -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_small_A6000.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 384,288,512,0,0,1,1,384,512,384 3 | 384,288,512,1,0,1,1,512,512,384 4 | 384,288,512,0,1,1,1,384,288,384 5 | 384,288,512,1,1,1,1,512,288,384 6 | 768,576,1024,0,0,1,1,768,1024,768 7 | 768,576,1024,1,0,1,1,1024,1024,768 8 | 768,576,1024,0,1,1,1,768,576,768 9 | 768,576,1024,1,1,1,1,1024,576,768 -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_small_MI100.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 640,384,512,0,0,1,1,640,512,640 3 | 640,384,512,1,0,1,1,512,512,640 4 | 640,384,512,0,1,1,1,640,384,640 5 | 640,384,512,1,1,1,1,512,384,640 6 | 1280,768,1024,0,0,1,1,1280,1024,1280 7 | 1280,768,1024,1,0,1,1,1024,1024,1280 8 | 1280,768,1024,0,1,1,1,1280,768,1280 9 | 1280,768,1024,1,1,1,1,1024,768,1280 -------------------------------------------------------------------------------- /docs/Reference/classes/Target/Category.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Target.Category` 7 | 8 | Defines the target processor category. 9 | 10 | type | description 11 | --- | --- 12 | `accera.Target.Category.CPU` | 13 | `accera.Target.Category.GPU` | 14 | 15 | 16 |
17 | -------------------------------------------------------------------------------- /tools/viz/static/styles.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) Microsoft Corporation. All rights reserved. 3 | Licensed under the MIT License. See LICENSE in the project root for license information. 4 | */ 5 | 6 | body { 7 | margin: 0; 8 | background-color: white; 9 | font-family: "Roboto", Sans-Serif; 10 | } 11 | 12 | #logo { 13 | float: right; 14 | margin-right: 2%; 15 | } -------------------------------------------------------------------------------- /docs/Reference/classes/Nest/create_schedule.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Nest.create_schedule()` 7 | Create a default schedule for a nest. 8 | 9 | ## Returns 10 | `Schedule` 11 | 12 | ## Examples 13 | 14 | ```python 15 | schedule = nest.create_schedule() 16 | ``` 17 | 18 |
19 | -------------------------------------------------------------------------------- /docs/Reference/classes/Package/Package.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Package.Package()` 7 | A package of functions that can be built and linked with client code. 8 | 9 | ## Examples 10 | 11 | Create a package: 12 | 13 | ```python 14 | package = acc.Package() 15 | ``` 16 | 17 |
18 | -------------------------------------------------------------------------------- /tools/viz/README.md: -------------------------------------------------------------------------------- 1 | # Iteration Space Visualizer 2 | 3 | ## Install 4 | 5 | ```shell 6 | pip install -r requirements.txt 7 | ``` 8 | 9 | [Optional] To create videos: 10 | 1. Install FFMPEG for your OS: https://ffmpeg.org/download.html 11 | 2. Ensure it's on your `PATH` 12 | 13 | ## Run 14 | 15 | ```shell 16 | python viz_tool.py 17 | ``` 18 | 19 | Point your browser to the printed URL to run the web tool. -------------------------------------------------------------------------------- /accera/onnx-emitter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | add_subdirectory(test) -------------------------------------------------------------------------------- /docs/Reference/classes/Package/Mode.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Package.Mode` 7 | 8 | type | description 9 | --- | --- 10 | `accera.Package.Mode.DEBUG` | Debug mode (automatically tests logical equivalence). 11 | `accera.Package.Mode.RELEASE` | Release (maximally optimized). 12 | 13 | 14 |
15 | -------------------------------------------------------------------------------- /accera/acc-translate/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | add_subdirectory(Target) 7 | 8 | -------------------------------------------------------------------------------- /accera/acc-translate/src/Target/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | add_subdirectory(LLVMIR) 7 | -------------------------------------------------------------------------------- /accera/python/compilers/src/__init__.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | from ._version import __version__ 7 | -------------------------------------------------------------------------------- /.style.yapf: -------------------------------------------------------------------------------- 1 | [style] 2 | allow_multiline_dictionary_keys = false 3 | allow_split_before_dict_value = true 4 | based_on_style = pep8 5 | coalesce_brackets = true 6 | column_limit = 120 7 | dedent_closing_brackets = true 8 | each_dict_entry_on_separate_line = true 9 | force_multiline_dict = true 10 | indent_dictionary_value = true 11 | spaces_before_comment = 4 12 | split_before_first_argument = true 13 | split_before_logical_operator = true 14 | -------------------------------------------------------------------------------- /docs/Reference/classes/FusedSchedule/get_fusing_index.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.FusedSchedule.get_fusing_index()` 7 | Gets the fusing index of a fused schedule. 8 | 9 | ## Returns 10 | Instance of `Index` 11 | 12 | ## Examples 13 | 14 | ```python 15 | f = fused_schedule.get_fusing_index() 16 | ``` 17 | 18 |
19 | -------------------------------------------------------------------------------- /docs/Reference/classes/FusedSchedule/get_fused_indices.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.FusedSchedule.get_fused_indices()` 7 | Gets the fused indices of a fused schedule. 8 | 9 | ## Returns 10 | Tuple of `Index` 11 | 12 | ## Examples 13 | 14 | ```python 15 | i, j = fused_schedule.get_fused_indices() 16 | ``` 17 | 18 |
19 | -------------------------------------------------------------------------------- /accera/transforms/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | add_subdirectory(nest) 7 | add_subdirectory(value) 8 | -------------------------------------------------------------------------------- /docs/Reference/classes/FusedSchedule/get_unfused_indices.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.FusedSchedule.get_unfused_indices()` 7 | Gets the unfused indices of a fused schedule. 8 | 9 | ## Returns 10 | Tuple of `Index` 11 | 12 | ## Examples 13 | 14 | ```python 15 | k, l = fused_schedule.get_unfused_indices() 16 | ``` 17 | 18 |
19 | -------------------------------------------------------------------------------- /accera/ir/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | add_subdirectory(ir_tests) 7 | add_subdirectory(nest_dialect_test) 8 | -------------------------------------------------------------------------------- /accera/testing/src/CatchMain.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #define CATCH_CONFIG_MAIN 7 | #include 8 | -------------------------------------------------------------------------------- /docs/Reference/classes/Nest/get_indices.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Nest.get_indices()` 7 | Gets the iteration space dimensions for a nest. 8 | 9 | ## Returns 10 | Tuple of `Index` 11 | 12 | ## Examples 13 | 14 | Get the iteration space dimensions for a 3-dimensional nest: 15 | 16 | ```python 17 | i, j, k = nest.get_indices() 18 | ``` 19 | 20 |
21 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: docs 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | deploy: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions/setup-python@v2 12 | with: 13 | python-version: 3.x 14 | - run: | 15 | pip install mkdocs-material mkdocs-git-revision-date-plugin 16 | cp -f README.md docs/README.md 17 | mkdocs gh-deploy --force 18 | -------------------------------------------------------------------------------- /accera/python/accera/Constants.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | k_dynamic_size = -1 7 | 8 | inf = float('inf') 9 | 10 | AUTO = object() 11 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /docs/Reference/classes/Schedule/get_indices.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Schedule.get_indices()` 7 | Gets the iteration space dimensions for a schedule. 8 | 9 | ## Returns 10 | Tuple of `Index` 11 | 12 | ## Examples 13 | 14 | Get the iteration space dimensions for a 3-dimensional nest: 15 | 16 | ```python 17 | i, j, k = schedule.get_indices() 18 | ``` 19 | 20 |
21 | -------------------------------------------------------------------------------- /accera/vulkanRuntime/README.md: -------------------------------------------------------------------------------- 1 | # Vulkan Runtime Wrapper Library 2 | 3 | This library wraps calls to the Vulkan runtime and the shared libs produced can be dynamically loaded and used with the acc-gpu-runner for JIT execution. 4 | 5 | This is a port of the `VulkanRuntime` and `mlir-vulkan-wrappers` lib from the llvm-project codebase at `/mlir/tools/mlir-vulkan-runner/` 6 | 7 | ## Requirements 8 | 9 | The Vulkan SDK is required to build this library - see https://vulkan.lunarg.com/ 10 | -------------------------------------------------------------------------------- /accera/ir/include/InitializeAccera.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | namespace accera::ir 10 | { 11 | void InitializeAccera(); 12 | } 13 | -------------------------------------------------------------------------------- /docs/Reference/classes/Schedule/create_plan.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Schedule.create_plan([target])` 7 | Creates a plan for running this schedule. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `target` | The target platform. Defaults to `acc.Target.HOST` | `Target` 14 | 15 | ## Returns 16 | `Plan` 17 | 18 | ## Examples 19 | TODO 20 | 21 | 22 |
23 | -------------------------------------------------------------------------------- /docs/Reference/functions/create_parameters.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.create_parameters()` 7 | Creates placeholder parameters. 8 | 9 | ## Returns 10 | Tuple of `Parameter` 11 | 12 | ## Examples 13 | 14 | Create 3 parameters `m`, `n`, `k`. Use them to parameterize the nest shape: 15 | 16 | ```python 17 | m, n, k = acc.create_parameters() 18 | nest = acc.Nest(shape=(m, n, k)) 19 | ``` 20 | 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_small.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 256,256,256,0,0,1,1,256,256,256 3 | 256,256,256,1,0,1,1,256,256,256 4 | 256,256,256,0,1,1,1,256,256,256 5 | 256,256,256,1,1,1,1,256,256,256 6 | 512,512,512,0,0,1,1,512,512,512 7 | 512,512,512,1,0,1,1,512,512,512 8 | 512,512,512,0,1,1,1,512,512,512 9 | 512,512,512,1,1,1,1,512,512,512 10 | 1024,1024,1024,0,0,1,1,1024,1024,1024 11 | 1024,1024,1024,1,0,1,1,1024,1024,1024 12 | 1024,1024,1024,0,1,1,1,1024,1024,1024 13 | 1024,1024,1024,1,1,1,1,1024,1024,1024 -------------------------------------------------------------------------------- /docs/Reference/classes/Plan/unroll.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Plan.unroll(index)` 7 | Marks a dimension of the iteration-space for unrolling. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `index` | The index to unroll. | `Index` 14 | 15 | ## Examples 16 | 17 | Mark the `i` dimension for unrolling: 18 | 19 | ```python 20 | plan.unroll(index=i) 21 | ``` 22 | 23 | 24 |
25 | -------------------------------------------------------------------------------- /accera/python/gpu/src/__init__.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | try: 7 | from ._version import __version__ 8 | except: 9 | # CMake-driven builds do not generate _version.py yet 10 | __version__ = None 11 | -------------------------------------------------------------------------------- /accera/python/llvm/src/__init__.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | try: 7 | from ._version import __version__ 8 | except: 9 | # CMake-driven builds do not generate _version.py yet 10 | __version__ = None 11 | -------------------------------------------------------------------------------- /accera/transforms/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(LLVM_TARGET_DEFINITIONS AcceraPasses.td) 7 | mlir_tablegen(AcceraPasses.h.inc -gen-pass-decls) 8 | add_public_tablegen_target(AcceraConversionIncGen) 9 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Support 2 | 3 | ## How to file issues and get help 4 | 5 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing 6 | issues before filing new issues to avoid duplicates. For new issues, file your bug or 7 | feature request as a new Issue. 8 | 9 | For help and questions about using this project, please create an issue on GitHub and 10 | we will get back to you shortly. 11 | 12 | ## Microsoft Support Policy 13 | 14 | Support for **Accera** is limited to the resources listed above. 15 | -------------------------------------------------------------------------------- /docs/Reference/classes/Target/Runtime.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Target.Runtime` 7 | 8 | The runtime for code generation and/or compilation. 9 | 10 | type | description 11 | --- | --- 12 | `accera.Target.Runtime.CUDA` | The NVidia CUDA runtime. 13 | `accera.Target.Runtime.ROCM` | The AMD ROCm runtime. 14 | `accera.Target.Runtime.VULKAN` | The Vulkan runtime. 15 | `accera.Target.Runtime.OPENMP` | The OpenMP runtime. 16 | 17 |
18 | -------------------------------------------------------------------------------- /accera/python/gpu/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | # use a directory so that we can include generated files (such as _version.py) 7 | set(deployed_dir "src") 8 | 9 | InstallAcceraDirectory(${deployed_dir} accera-gpu "accera/gpu") -------------------------------------------------------------------------------- /accera/python/llvm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | # use a directory so that we can include generated files (such as _version.py) 7 | set(deployed_dir "src") 8 | 9 | InstallAcceraDirectory(${deployed_dir} accera-llvm "accera/llvm") -------------------------------------------------------------------------------- /tools/viz/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | #################################################################################################### 6 | set -e 7 | 8 | pip install -r requirements.txt 9 | cp -f ../../docs/assets/logos/Accera_darktext.svg static/. 10 | 11 | # python viz_tool.py [--port ] 12 | python viz_tool.py -------------------------------------------------------------------------------- /docs/Reference/classes/Nest/Nest.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Nest(shape)` 7 | Creates an affine loop nest. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `shape` | The shape of the iteration space | tuple of positive integers 14 | 15 | ## Examples 16 | 17 | Create a nest with 3 nested for-loops of sizes 16, 10, and 11: 18 | 19 | ```python 20 | nest = acc.Nest(shape=(16, 10, 11)) 21 | ``` 22 | 23 |
24 | -------------------------------------------------------------------------------- /accera/ir/include/value/ValueEnums.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include "value/ValueOpsEnums.h.inc" 13 | -------------------------------------------------------------------------------- /accera/python/compilers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | # use a directory so that we can include generated files (such as _version.py) 7 | set(deployed_dir "src") 8 | 9 | InstallAcceraDirectory(${deployed_dir} accera-compilers "accera/compilers") -------------------------------------------------------------------------------- /accera/acc-opt/test/commandline.mlir: -------------------------------------------------------------------------------- 1 | // RUN: acc-opt --show-dialects | FileCheck %s 2 | // CHECK: Registered Dialects: 3 | // CHECK: accera 4 | // CHECK-NEXT: accintr 5 | // CHECK-NEXT: accln 6 | // CHECK-NEXT: accv 7 | // CHECK-NEXT: accxp 8 | // CHECK-NEXT: affine 9 | // CHECK-NEXT: arith 10 | // CHECK-NEXT: builtin 11 | // CHECK-NEXT: cf 12 | // CHECK-NEXT: gpu 13 | // CHECK-NEXT: llvm 14 | // CHECK-NEXT: math 15 | // CHECK-NEXT: memref 16 | // CHECK-NEXT: nvvm 17 | // CHECK-NEXT: rocdl 18 | // CHECK-NEXT: scf 19 | // CHECK-NEXT: spv 20 | // CHECK-NEXT: std 21 | // CHECK-NEXT: vector 22 | -------------------------------------------------------------------------------- /CMake/Catch2Setup.cmake: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | include_guard() 7 | 8 | # Prerequisites: vcpkg install catch2 or vcpkg install catch2:x64-windows 9 | find_package(Catch2 CONFIG REQUIRED) 10 | 11 | include(Catch) 12 | include(ParseAndAddCatchTests) 13 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "setuptools_scm[toml]", 5 | "wheel", 6 | "pybind11>=2.6.0", 7 | "conan" 8 | ] 9 | 10 | build-backend = "setuptools.build_meta" 11 | 12 | [tool.pytest.ini_options] 13 | filterwarnings = [ 14 | "ignore:In future, it will be an error for 'np.bool_' scalars to be interpreted as an index:DeprecationWarning", 15 | "ignore:an integer is required:DeprecationWarning", 16 | "ignore:an integer is required:PendingDeprecationWarning", 17 | "ignore:an integer is required:FutureWarning", 18 | ] 19 | -------------------------------------------------------------------------------- /docs/Install/README.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Install from PyPI 5 | The quickest way to get up and running is to install the pre-built Python packages: 6 | 7 | * [MacOS]() 8 | * [Ubuntu]() 9 | * [Windows]() 10 | 11 | # Build and Install 12 | You can also build and install the latest version of Accera by following these instructions: 13 | 14 | * [MacOS]() 15 | * [Ubuntu]() 16 | * [Windows]() 17 | -------------------------------------------------------------------------------- /external/llvm/llvm_usage: -------------------------------------------------------------------------------- 1 | The package llvm provides CMake targets: 2 | 3 | find_package(LLVM CONFIG REQUIRED) 4 | 5 | list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") 6 | include(HandleLLVMOptions) 7 | add_definitions(${LLVM_DEFINITIONS}) 8 | 9 | target_include_directories(main PRIVATE ${LLVM_INCLUDE_DIRS}) 10 | 11 | # Find the libraries that correspond to the LLVM components that we wish to use 12 | llvm_map_components_to_libnames(llvm_libs Support Core IRReader ...) 13 | 14 | # Link against LLVM libraries 15 | target_link_libraries(main PRIVATE ${llvm_libs}) 16 | -------------------------------------------------------------------------------- /accera/ir/include/nest/LoopNestInterfaces.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | namespace accera::ir 9 | { 10 | 11 | namespace loopnest 12 | { 13 | #include "nest/LoopNestInterfaces.h.inc" 14 | } // namespace loopnest 15 | } // namespace accera::ir 16 | -------------------------------------------------------------------------------- /accera/python/accera/algorithms/__init__.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | from ..lang import * 7 | from ..lang.Array import * 8 | from ..lang.Layout import * 9 | from ..lang.LoopIndex import * 10 | from ..lang.Plan import * 11 | 12 | from .NoneCacheHeuristics import * 13 | -------------------------------------------------------------------------------- /docs/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM #################################################################################################### 3 | REM Copyright (c) Microsoft Corporation. All rights reserved. 4 | REM Licensed under the MIT License. See LICENSE in the project root for license information. 5 | REM Build script for the Accera Python package 6 | REM #################################################################################################### 7 | 8 | REM Run this from the repo root 9 | pip install mkdocs-material mkdocs-git-revision-date-plugin 10 | copy README.md docs\README.md 11 | mkdocs serve 12 | -------------------------------------------------------------------------------- /accera/onnx-emitter/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(target onnx_emitter_tests) 7 | set(dest ${CMAKE_BINARY_DIR}/onnx-emitter) 8 | 9 | configure_file(${target}.py ${dest}/${target}.py @ONLY) 10 | add_test(NAME ${target} COMMAND python ${dest}/${target}.py) -------------------------------------------------------------------------------- /accera/acc-translate/src/Target/LLVMIR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_mlir_translation_library(IntrinsicToLLVMIRTranslation 2 | IntrinsicToLLVMIRTranslation.cpp 3 | 4 | ADDITIONAL_HEADER_DIRS 5 | ${ACCERA_BIN_DIR}/accera/ir/include 6 | 7 | DEPENDS 8 | MLIRAcceraIntrinsics 9 | AcceraIntrinsicsConversionsIncGen 10 | 11 | LINK_COMPONENTS 12 | Core 13 | 14 | LINK_LIBS PUBLIC 15 | MLIRIR 16 | MLIRAcceraIntrinsics 17 | MLIRLLVMIR 18 | MLIRSupport 19 | MLIRTargetLLVMIRExport 20 | ) 21 | 22 | target_include_directories(IntrinsicToLLVMIRTranslation PUBLIC 23 | ${ACCERA_BIN_DIR}/ir/include 24 | ) 25 | -------------------------------------------------------------------------------- /accera/transforms/src/nest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | include_directories(${ACCERA_LIBRARIES_DIR}) 7 | set(LLVM_TARGET_DEFINITIONS LoopNestToValue.td) 8 | mlir_tablegen(LoopNestToValue.inc -gen-rewriters) 9 | add_public_tablegen_target(LoopNestToValueIncGen) 10 | -------------------------------------------------------------------------------- /accera/transforms/src/value/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | include_directories(${ACCERA_LIBRARIES_DIR}) 7 | set(LLVM_TARGET_DEFINITIONS ValueConversion.td) 8 | mlir_tablegen(ValueConversion.inc -gen-rewriters) 9 | add_public_tablegen_target(ValueConversionIncGen) 10 | -------------------------------------------------------------------------------- /docs/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | #################################################################################################### 6 | set -e 7 | 8 | # Run this from the repo root 9 | pip install mkdocs-material mkdocs-git-revision-date-plugin 10 | cp README.md docs/README.md 11 | 12 | # To use a different port: mkdocs serve -a localhost:8765 13 | mkdocs serve -------------------------------------------------------------------------------- /tools/benchmarkers/config.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | import os 6 | 7 | settings = { 8 | 'host': os.environ.get('ACCOUNT_HOST', '...'), 9 | 'master_key': os.environ.get('ACCOUNT_KEY', '...'), 10 | 'database_id': os.environ.get('COSMOS_DATABASE', 'perf-results'), 11 | } -------------------------------------------------------------------------------- /tools/viz/run.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM #################################################################################################### 3 | REM Copyright (c) Microsoft Corporation. All rights reserved. 4 | REM Licensed under the MIT License. See LICENSE in the project root for license information. 5 | REM Build script for the Accera Python package 6 | REM #################################################################################################### 7 | 8 | pip install -r requirements.txt 9 | copy ../../docs/assets/logos/Accera_darktext.svg static/. 10 | 11 | REM python viz_tool.py [--port ] 12 | python viz_tool.py -------------------------------------------------------------------------------- /accera/ir/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | include_directories(${ACCERA_LIBRARIES_DIR}) 7 | 8 | add_subdirectory(nest) 9 | add_subdirectory(exec) 10 | add_subdirectory(accera) 11 | add_subdirectory(value) 12 | add_subdirectory(intrinsics) 13 | 14 | add_subdirectory(argo) 15 | -------------------------------------------------------------------------------- /accera/value/include/ScalarIndex.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include "Scalar.h" 10 | 11 | namespace accera 12 | { 13 | namespace value 14 | { 15 | using ScalarIndex = Scalar; 16 | } // namespace value 17 | } // namespace accera 18 | -------------------------------------------------------------------------------- /accera/value/test/include/Functions_test.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa, Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | 14 | value::Scalar FunctionArgType_test(); 15 | 16 | } // namespace accera 17 | -------------------------------------------------------------------------------- /accera/ir/include/DialectRegistry.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | namespace mlir 10 | { 11 | class DialectRegistry; 12 | } 13 | 14 | namespace accera::ir 15 | { 16 | 17 | mlir::DialectRegistry& GetDialectRegistry(); 18 | 19 | } // namespace accera::ir 20 | -------------------------------------------------------------------------------- /accera/ir/include/intrinsics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | add_mlir_dialect(AcceraIntrinsics accintr) 7 | 8 | set(LLVM_TARGET_DEFINITIONS AcceraIntrinsics.td) 9 | mlir_tablegen(AcceraIntrinsicsConversions.inc -gen-llvmir-conversions) 10 | add_public_tablegen_target(AcceraIntrinsicsConversionsIncGen) 11 | -------------------------------------------------------------------------------- /docs/Reference/classes/Plan/vectorize.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Plan.vectorize(index)` 7 | Only available for targets that have SIMD registers and support vector instructions. Marks a dimension of the iteration-space for vectorization. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `index` | The index to vectorize. | `Index` 14 | 15 | ## Examples 16 | 17 | Mark the dimension `ii` for vectorized execution: 18 | 19 | ```python 20 | plan.vectorize(index=ii) 21 | ``` 22 | 23 |
24 | -------------------------------------------------------------------------------- /accera/value/include/FastMath.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | namespace accera 10 | { 11 | namespace value 12 | { 13 | class Scalar; 14 | 15 | Scalar FastExp(Scalar s); 16 | Scalar FastExpMlas(Scalar s); 17 | 18 | } // namespace value 19 | } // namespace accera 20 | -------------------------------------------------------------------------------- /accera/ir/include/exec/ExecutionPlanEnums.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | 9 | #include 10 | #include 11 | 12 | #include "exec/ExecutionPlanEnums.h.inc" 13 | 14 | enum class GPUIndexDimension 15 | { 16 | X, 17 | Y, 18 | Z, 19 | Invalid = -1 20 | }; -------------------------------------------------------------------------------- /docs/Reference/classes/Schedule/pad.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Schedule.pad(index, size)` 7 | Pads the beginning of a specified dimension of the iteration-space with empty (no-op) elements. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `index` | The dimension to pad | `Index` 14 | `size` | The number of elements to pad | non-negative integer 15 | 16 | ## Examples 17 | 18 | Pads the beginning of dimension `i` with 10 empty elements 19 | 20 | ```python 21 | schedule.pad(i, 10) 22 | ``` 23 | 24 |
25 | -------------------------------------------------------------------------------- /accera/ir/test/ir_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | add_executable(ir_tests ir_tests.cpp) 7 | target_link_libraries(ir_tests PRIVATE ir transforms value mlirHelpers CatchWrapper) 8 | catch_discover_tests(ir_tests TEST_SPEC 'exclude:[demo]' TEST_PREFIX 'ir_tests_') 9 | set_target_properties(ir_tests PROPERTIES FOLDER "tests") 10 | -------------------------------------------------------------------------------- /docs/update_versions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | #################################################################################################### 6 | 7 | pip install bump2version 8 | 9 | # Usage: bump2version , where is major, minor, or patch 10 | # Note: Run this from the docs folder 11 | # Note: This will override .bumpversion.cfg 12 | # TODO: tie the version with git tags 13 | 14 | bump2version patch --allow-dirty -------------------------------------------------------------------------------- /docs/Reference/classes/Package/Platform.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Package.Platform` 7 | 8 | type | description 9 | --- | --- 10 | `accera.Package.Platform.HOST` | The host computer's platform 11 | `accera.Package.Platform.WINDOWS` | The Windows platform 12 | `accera.Package.Platform.LINUX` | The Linux platform 13 | `accera.Package.Platform.MACOS` | The MacOS platform 14 | `accera.Package.Platform.ANDRIOD` | The Android platform 15 | `accera.Package.Platform.IOS` | The iOS platform 16 | `accera.Package.Platform.RASPBIAN` | The Raspbian platform 17 | 18 |
19 | -------------------------------------------------------------------------------- /docs/Tutorials/hello_matmul_gpu/tensor_input_output_cache_matmul_gpu_generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Accera Input Output Caching MatMul GPU sample: generator 3 | import accera as acc 4 | import tensor_input_double_buffer_cache_matmul_gpu_generator 5 | import matmul_utils as utils 6 | 7 | target = acc.Target(acc.Target.Model.AMD_MI100) 8 | plan, A, B, C, out_cache_idx = tensor_input_double_buffer_cache_matmul_gpu_generator.create_tensor_input_caching_matmul_plan(target) 9 | 10 | # Add output caching 11 | plan.cache(C, index=out_cache_idx, location=target.MemorySpace.MMA_FRAGMENT) 12 | 13 | utils.add_function_build_pkg(plan, A, B, C, "tensor_input_output_cache_matmul_gpu") 14 | -------------------------------------------------------------------------------- /docs/Reference/classes/Target/Architecture.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Target.Architecture` 7 | 8 | Defines the supported target architectures. 9 | 10 | type | description 11 | --- | --- 12 | `accera.Target.Architecture.HOST` | The host computer's architecture 13 | `accera.Target.Architecture.ARM` | The ARM architecture 14 | `accera.Target.Architecture.AARCH64` | The 64-bit ARM architecture 15 | `accera.Target.Architecture.X86` | The 32-bit x86 architecture 16 | `accera.Target.Architecture.X86_64` | The 64-bit x86 architecture 17 | 18 | TODO: AARCH64? 19 | 20 |
21 | -------------------------------------------------------------------------------- /docs/Reference/enumerations/Role.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Role` 7 | 8 | type | description 9 | --- | --- 10 | `accera.Role.CONST` | A constant array (immutable internally scoped) whose contents are known at compile-time. 11 | `accera.Role.INPUT` | An input array (immutable external-scope). 12 | `accera.Role.INPUT_OUTPUT` | An input/output array (mutable external-scope). 13 | `accera.Role.OUTPUT` | An output array (mutable external-scope) which is allocated at runtime. 14 | `accera.Role.TEMP` | A temporary array (mutable internal-scope). 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /docs/Tutorials/hello_matmul_gpu/tensor_zero_init_matmul_gpu_generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Accera Tensor 0-Init MatMul GPU sample: generator 3 | import accera as acc 4 | import tensor_matmul_gpu_generator 5 | import matmul_utils as utils 6 | 7 | mma_shape = acc.MMAShape.M16xN16xK4_B1 8 | target = acc.Target(acc.Target.Model.AMD_MI100) 9 | plan, A, B, C, tensor_indices = tensor_matmul_gpu_generator.create_basic_tensor_matmul_plan(target, mma_shape) 10 | 11 | # Tensorize the plan 12 | plan.tensorize(indices=tensor_indices, mma_shape=mma_shape, prologue_op=acc.MMAFragmentOp.SET, prologue_arg=0.0) 13 | 14 | utils.add_function_build_pkg(plan, A, B, C, "tensor_zero_init_matmul_gpu") 15 | -------------------------------------------------------------------------------- /accera/value/include/VectorizationInformation.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Mason Remy 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | namespace value 14 | { 15 | using VectorizationInformation = accera::ir::executionPlan::VectorizationInfo; 16 | } 17 | } // namespace accera -------------------------------------------------------------------------------- /.azure/cuda/scripts/install.dbgdeps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # 6 | # Note that the line endings in this file should be LF instead of CRLF in order to run correctly. 7 | #################################################################################################### 8 | set -x -e 9 | 10 | # dependencies for debugging only 11 | apt-get update && apt-get install --no-install-recommends \ 12 | llvm-12 \ 13 | && rm -rf /var/lib/apt/lists/* 14 | -------------------------------------------------------------------------------- /.azure/rocm/scripts/install.dbgdeps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # 6 | # Note that the line endings in this file should be LF instead of CRLF in order to run correctly. 7 | #################################################################################################### 8 | set -x -e 9 | 10 | # dependencies for debugging only 11 | apt-get update && apt-get install --no-install-recommends \ 12 | llvm-12 \ 13 | && rm -rf /var/lib/apt/lists/* 14 | -------------------------------------------------------------------------------- /accera/transforms/src/nest/LoopNestToValue.td: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #ifndef LOOPNEST_TO_VALUE 7 | #define LOOPNEST_TO_VALUE 8 | 9 | include "ir/include/nest/LoopNestOps.td" 10 | include "ir/include/value/ValueOps.td" 11 | 12 | def : Pat<(accln_PrintOp $input, $to_stderr), (accv_PrintOp $input, $to_stderr)>; 13 | 14 | #endif // LOOPNEST_TO_VALUE 15 | -------------------------------------------------------------------------------- /accera/value/src/Emittable.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "Emittable.h" 8 | 9 | namespace accera 10 | { 11 | namespace value 12 | { 13 | 14 | Emittable::Emittable() = default; 15 | 16 | Emittable::Emittable(void* data) : 17 | _data(data) {} 18 | 19 | } // namespace value 20 | } // namespace accera 21 | -------------------------------------------------------------------------------- /accera/value/test/include/Tensor_test.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | value::Scalar Tensor_test1(); 14 | value::Scalar Tensor_test2(); 15 | value::Scalar Tensor_test3(); 16 | value::Scalar Tensor_slice_test1(); 17 | } // namespace accera 18 | -------------------------------------------------------------------------------- /accera/ir/src/nest/AffineExpression.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "nest/AffineExpression.h" 8 | 9 | namespace accera::ir 10 | { 11 | namespace loopnest 12 | { 13 | bool AffineExpression::IsIdentity() const 14 | { 15 | return (_expr == nullptr); 16 | } 17 | } // namespace loopnest 18 | } // namespace accera::ir 19 | -------------------------------------------------------------------------------- /accera/transforms/include/util/DebugUtilities.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak, Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace mlir 12 | { 13 | class Pass; 14 | } 15 | 16 | namespace accera::transforms 17 | { 18 | 19 | std::unique_ptr createDumpModulePass(); 20 | 21 | } // namespace accera::transforms 22 | -------------------------------------------------------------------------------- /.azure/manylinux/scripts/install.vcpkg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # 6 | # Note that the line endings in this file should be LF instead of CRLF in order to run correctly. 7 | #################################################################################################### 8 | set -x -e 9 | 10 | /opt/vcpkg/bootstrap-vcpkg.sh 11 | /opt/vcpkg/vcpkg install catch2 tomlplusplus --overlay-ports=/opt/ports 12 | /opt/vcpkg/vcpkg install accera-llvm --overlay-ports=/opt/ports 13 | -------------------------------------------------------------------------------- /accera/ir/include/argo/ArgoTypes.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #ifndef MLIR_DIALECT_ARGO_TYPES_H_ 7 | #define MLIR_DIALECT_ARGO_TYPES_H_ 8 | 9 | #include "mlir/IR/Dialect.h" 10 | #include "mlir/IR/Types.h" 11 | 12 | namespace mlir 13 | { 14 | class MLIRContext; 15 | } // namespace mlir 16 | 17 | #include "argo/ArgoDialect.h.inc" 18 | 19 | #endif // MLIR_DIALECT_ARGO_TYPES_H_ 20 | -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_bert_assorted.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 768,1280,768,1,0,1.0,1.0,768,768,768 3 | 768,320,30522,0,0,1.0,1.0,768,30522,768 4 | 1024,80,30522,0,0,1.0,1.0,1024,30522,1024 5 | 1024,2048,30528,0,0,1.0,1.0,1024,30528,1024 6 | 1024,3072,1024,1,0,1.0,1.0,1024,1024,1024 7 | 3072,512,1024,1,0,1.0,1.0,1024,1024,3072 8 | 3072,1024,2048,0,1,1.0,1.0,3072,1024,3072 9 | 1024,2048,4096,1,0,1.0,1.0,4096,4096,1024 10 | 1024,30528,4096,0,1,1.0,1.0,1024,30528,1024 11 | 1024,30528,2048,0,1,1.0,1.0,1024,30528,1024 12 | 4096,4096,1024,0,0,1.0,1.0,4096,1024,4096 13 | 3072,3072,1024,0,0,1.0,1.0,3072,1024,3072 14 | 3072,2048,1024,0,0,1.0,1.0,3072,1024,3072 15 | 1024,4096,4096,0,1,1.0,1.0,1024,4096,1024 16 | -------------------------------------------------------------------------------- /accera/value/test/include/Vector_test.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | value::Scalar Vector_test1(); 14 | value::Scalar Vector_test2(); 15 | value::Scalar Vector_test3(); 16 | value::Scalar Vector_test4(); 17 | value::Scalar Vector_test5(); 18 | } // namespace accera 19 | -------------------------------------------------------------------------------- /docs/Reference/classes/Package/Format.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Package.Format` 7 | 8 | type | description 9 | --- | --- 10 | `accera.Package.Format.HAT_DYNAMIC` | HAT package format, dynamically linked. 11 | `accera.Package.Format.HAT_STATIC` | HAT package format, statically linked. 12 | `accera.Package.Format.MLIR_DYNAMIC` | MLIR (debugging) package format, dynamically linked. 13 | `accera.Package.Format.MLIR_STATIC` | MLIR (debugging) package format, statically linked. 14 | 15 | When cross-compiling, use either `accera.Package.Format.HAT_STATIC` or `accera.Package.Format.MLIR_STATIC`. 16 | 17 |
18 | -------------------------------------------------------------------------------- /accera/transforms/include/util/MathUtilities.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace accera::transforms 14 | { 15 | mlir::Value SaturateValue(mlir::PatternRewriter& rewriter, mlir::Value value, int64_t bitWidth, bool isSigned); 16 | } // namespace accera::transforms 17 | -------------------------------------------------------------------------------- /docs/Manual/README.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Manual 5 | 6 | * [Introduction](<00%20Introduction.md>) 7 | * [Arrays and Scalars](<01%20Arrays%20and%20Scalars.md>) 8 | * [Simple Affine Loop Nests](<02%20Simple%20Affine%20Loop%20Nests.md>) 9 | * [Schedules](<03%20Schedules.md>) 10 | * [Fusing](<04%20Fusing.md>) 11 | * [Targets](<05%20Targets.md>) 12 | * [Plans - Caching](<06%20Plans%20-%20Caching.md>) 13 | * [Plans - Vectorization and Parallelization](<07%20Plans%20-%20Operations%20and%20Optimizations.md>) 14 | * [Deferred layout of constant arrays](<08%20Deferred%20Layout%20of%20Constant%20Arrays.md>) 15 | * [Parameters](<09%20Parameters.md>) 16 | * [Packages](<10%20Packages.md>) 17 | -------------------------------------------------------------------------------- /docs/Reference/classes/Array/Layout.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Array.Layout` 7 | 8 | type | description 9 | --- | --- 10 | `accera.Array.Layout.FIRST_MAJOR` | Specifies a memory layout where the first major axis is in contiguous memory. For example, in a matrix, this corresponds to "row-major". 11 | `accera.Array.Layout.LAST_MAJOR` | Specifies a memory layout where the last major axis is in contiguous memory. For example, in a matrix, this corresponds to "column-major". 12 | `accera.Array.Layout.DEFERRED` | Defer specifying the memory layout for an `Role.CONST` array until a cache is created. 13 | 14 |
15 | -------------------------------------------------------------------------------- /docs/Tutorials/hello_matmul_gpu/tensor_alpha_scaling_matmul_gpu_generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Accera Tensor Alpha Scaling MatMul GPU sample: generator 3 | import accera as acc 4 | import tensor_matmul_gpu_generator 5 | import matmul_utils as utils 6 | 7 | mma_shape = acc.MMAShape.M16xN16xK4_B1 8 | target = acc.Target(acc.Target.Model.AMD_MI100) 9 | plan, A, B, C, tensor_indices = tensor_matmul_gpu_generator.create_basic_tensor_matmul_plan(target, mma_shape) 10 | 11 | # Tensorize the plan 12 | plan.tensorize(indices=tensor_indices, mma_shape=mma_shape, prologue_op=acc.MMAFragmentOp.SET, prologue_arg=0.0, epilogue_op=acc.MMAFragmentOp.SCALE, epilogue_arg=5.0) 13 | 14 | utils.add_function_build_pkg(plan, A, B, C, "tensor_alpha_scaling_matmul_gpu") 15 | -------------------------------------------------------------------------------- /accera/ir/include/argo/ArgoBase.td: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #ifndef ARGO_BASE 7 | #define ARGO_BASE 8 | 9 | include "mlir/IR/OpBase.td" 10 | 11 | def Argo_Dialect : Dialect { 12 | let name = "argo"; 13 | let cppNamespace = "mlir::argo"; 14 | let description = [{ 15 | The `argo` dialect includes Microsoft extension on top of MLIR's 16 | `linalg` dialect. 17 | }]; 18 | } 19 | 20 | #endif // ARGO_BASE 21 | -------------------------------------------------------------------------------- /accera/ir/include/value/ValueAttributes.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace accera::ir::value 14 | { 15 | using mlir::AffineMapAttr; 16 | class ExecutionTargetAttr; 17 | class ExecutionRuntimeAttr; 18 | } 19 | 20 | #include "value/ValueAttrs.h.inc" 21 | -------------------------------------------------------------------------------- /CMake/BuildTargetSetup.cmake: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | if(APPLE) 7 | # cf. https://discourse.cmake.org/t/how-to-determine-which-architectures-are-available-apple-m1/2401/10 8 | # on macOS "uname -m" returns the architecture (x86_64 or arm64) 9 | execute_process( 10 | COMMAND uname -m 11 | RESULT_VARIABLE result 12 | OUTPUT_VARIABLE OSX_NATIVE_ARCH 13 | OUTPUT_STRIP_TRAILING_WHITESPACE 14 | ) 15 | endif() -------------------------------------------------------------------------------- /accera/transforms/include/util/DebugFunctionPass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace mlir 11 | { 12 | class ModuleOp; 13 | 14 | template 15 | class OperationPass; 16 | 17 | } // namespace mlir 18 | 19 | namespace accera::transforms 20 | { 21 | std::unique_ptr> createEmitDebugFunctionPass(); 22 | } // namespace accera::transforms 23 | -------------------------------------------------------------------------------- /.azure/manylinux/manylinux-llvm.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | branches: 3 | include: 4 | - main 5 | paths: 6 | include: 7 | - external/llvm 8 | 9 | pool: Linux1ESPool 10 | 11 | steps: 12 | - script: | 13 | git submodule init 14 | git submodule update 15 | displayName: Pull submodules 16 | workingDirectory: "$(Build.SourcesDirectory)" 17 | 18 | - task: Docker@2 19 | displayName: Build and push to $(CONTAINER_REGISTRY) 20 | inputs: 21 | command: buildAndPush 22 | containerRegistry: $(CONTAINER_REGISTRY_SERVICE_CONNECTION) 23 | dockerfile: $(Build.SourcesDirectory)/.azure/manylinux/Dockerfile 24 | repository: accera-llvm-manylinux2014 25 | tags: | 26 | $(Build.BuildId) 27 | latest 28 | buildContext: "$(Build.SourcesDirectory)" -------------------------------------------------------------------------------- /accera/transforms/include/affine/AffineLoopNormalize.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace mlir 11 | { 12 | class Pass; 13 | class RewritePatternSet; 14 | using OwningRewritePatternList = RewritePatternSet; 15 | } // namespace mlir 16 | 17 | namespace accera::transforms::affine 18 | { 19 | std::unique_ptr createAcceraAffineLoopNormalizePass(); 20 | } // namespace accera::transforms::affine 21 | -------------------------------------------------------------------------------- /accera/transforms/include/value/ValueUnrollingPass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | // fwd decls 11 | namespace mlir 12 | { 13 | class ModuleOp; 14 | template class OperationPass; 15 | } // namespace mlir 16 | 17 | namespace accera::transforms::value 18 | { 19 | 20 | std::unique_ptr> createValueUnrollingPass(); 21 | 22 | } // namespace accera::transforms::value 23 | -------------------------------------------------------------------------------- /CMake/LLVMSetupDefault.cmake: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | include_guard() 7 | 8 | # vcpkg targets 9 | find_package(LLVM CONFIG REQUIRED) 10 | find_package(LLD CONFIG REQUIRED) 11 | find_package(MLIR CONFIG REQUIRED) 12 | 13 | message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") 14 | message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") 15 | message(STATUS "Using LLDConfig.cmake in ${LLD_CMAKE_DIR}") 16 | message(STATUS "Using MLIRConfig.cmake in ${MLIR_CMAKE_DIR}") 17 | -------------------------------------------------------------------------------- /accera/value/include/Index.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs, Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | namespace value 14 | { 15 | namespace loopnests 16 | { 17 | using Index = accera::ir::loopnest::Index; 18 | using SplitIndex = accera::ir::loopnest::SplitIndex; 19 | } // namespace loopnests 20 | } // namespace value 21 | } // namespace accera 22 | -------------------------------------------------------------------------------- /accera/value/src/ScalarDimension.cpp: -------------------------------------------------------------------------------- 1 | #include "ScalarDimension.h" 2 | 3 | namespace accera 4 | { 5 | namespace value 6 | { 7 | ScalarDimension::ScalarDimension(Role role) : 8 | Scalar{ MakeScalar(ValueType::Index, "", role) } 9 | { 10 | } 11 | 12 | ScalarDimension::ScalarDimension(const std::string& name, Role role) : 13 | Scalar{ MakeScalar(ValueType::Index, name, role) } 14 | { 15 | } 16 | 17 | ScalarDimension::ScalarDimension(Value value, const std::string& name, Role role) : 18 | Scalar{ value, name, role } 19 | { 20 | } 21 | 22 | void ScalarDimension::SetValue(Value value) 23 | { 24 | Scalar::SetValue(value); 25 | } 26 | 27 | ScalarDimension::~ScalarDimension() = default; 28 | 29 | } // namespace value 30 | } // namespace accera -------------------------------------------------------------------------------- /accera/python/accera/lang/__init__.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | from .._lang_python._lang import * 7 | 8 | NativeArray = Array 9 | 10 | from .Array import Array 11 | from .Nest import Nest 12 | from .Schedule import Schedule, FusedSchedule, fuse 13 | from .Plan import Plan 14 | from .Cache import Cache 15 | from .Function import Function 16 | from .LogicFunction import logic_function, LogicFunction 17 | from .LoopIndex import LoopIndex 18 | from .DimensionUtilities import create_dimensions -------------------------------------------------------------------------------- /accera/toml/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(ROOT_BIN_DIR ${CMAKE_BINARY_DIR}/bin) 7 | 8 | set(copy_scripts 9 | parse_toml_header.py 10 | ) 11 | 12 | set(deployed_scripts ) 13 | foreach(script ${copy_scripts}) 14 | configure_file(${script} ${ROOT_BIN_DIR}/${script} COPYONLY) 15 | set(deployed_scripts ${deployed_scripts} ${ROOT_BIN_DIR}/${script}) 16 | endforeach() 17 | 18 | # 19 | # Install toml scripts 20 | # 21 | install(PROGRAMS ${deployed_scripts} TYPE BIN) 22 | -------------------------------------------------------------------------------- /accera/ir/include/accera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(LLVM_TARGET_DEFINITIONS AcceraOps.td) 7 | mlir_tablegen(AcceraOps.h.inc -gen-op-decls) 8 | mlir_tablegen(AcceraOps.cpp.inc -gen-op-defs) 9 | mlir_tablegen(AcceraDialect.h.inc -gen-dialect-decls -dialect=accera) 10 | mlir_tablegen(AcceraDialect.cpp.inc -gen-dialect-defs -dialect=accera) 11 | add_public_tablegen_target(AcceraOpsIncGen) 12 | 13 | add_accera_ir_doc(AcceraOps -gen-dialect-doc AcceraDialect references/markdown/) 14 | -------------------------------------------------------------------------------- /accera/value/include/ExecutionOptions.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | namespace value 14 | { 15 | namespace targets 16 | { 17 | using namespace ir::targets; 18 | } // namespace targets 19 | 20 | using ExecutionTarget = targets::Target; 21 | using ExecutionRuntime = targets::Runtime; 22 | } // namespace value 23 | } // namespace accera -------------------------------------------------------------------------------- /accera/transforms/include/value/BarrierOptPass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | // fwd decls 12 | namespace mlir 13 | { 14 | class Pass; 15 | } // namespace mlir 16 | 17 | namespace accera::transforms::value 18 | { 19 | std::unique_ptr createBarrierOptPass(bool writeBarrierGraph, std::string barrierGraphFilename); 20 | std::unique_ptr createBarrierOptPass(); 21 | } // namespace accera::transforms::value 22 | -------------------------------------------------------------------------------- /docs/Tutorials/hello_matmul/hello_matmul_runner.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Include the HAT file that declares our MatMul function 5 | #include "hello_matmul.hat" 6 | 7 | #define M 128 8 | #define N 256 9 | #define K 256 10 | 11 | int main(int argc, const char** argv) 12 | { 13 | // Prepare our matrices 14 | float A[M*K]; 15 | float B[K*N]; 16 | float C[M*N]; 17 | 18 | // Fill with data 19 | std::fill_n(A, M*K, 2.0f); 20 | std::fill_n(B, K*N, 3.0f); 21 | std::fill_n(C, M*N, 0.42f); 22 | 23 | printf("Calling MatMul M=%d, K=%d, N=%d\n", M, K, N); 24 | hello_matmul_py(A, B, C); 25 | 26 | printf("Result (first few elements): "); 27 | for (int i = 0; i < 10; ++i) 28 | { 29 | printf("%f ", C[i]); 30 | } 31 | printf("\n"); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /accera/ir/include/intrinsics/AcceraIntrinsicsDialect.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include "mlir/IR/BuiltinTypes.h" 9 | #include "mlir/IR/Dialect.h" 10 | #include "mlir/IR/OpDefinition.h" 11 | #include "mlir/IR/OpImplementation.h" 12 | #include "mlir/Interfaces/InferTypeOpInterface.h" 13 | #include "mlir/Interfaces/SideEffectInterfaces.h" 14 | 15 | #include "intrinsics/AcceraIntrinsicsDialect.h.inc" 16 | 17 | #define GET_OP_CLASSES 18 | #include "intrinsics/AcceraIntrinsics.h.inc" 19 | -------------------------------------------------------------------------------- /accera/ir/test/nest_dialect_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | add_executable(nest_dialect_test LowLevelIRTests.cpp NestUtilTests.cpp NestIRTests.cpp IRTestVerification.cpp DynamicRangeTests.cpp) 7 | target_link_libraries(nest_dialect_test PRIVATE ir mlirHelpers transforms CatchWrapper) 8 | catch_discover_tests(nest_dialect_test) 9 | catch_discover_tests(nest_dialect_test TEST_SPEC 'exclude:[demo]' TEST_PREFIX 'nest_dialect_tests_') 10 | set_target_properties(nest_dialect_test PROPERTIES FOLDER "tests") 11 | -------------------------------------------------------------------------------- /accera/value/test/include/Matrix_test.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa, Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | value::Scalar Matrix_test1(); 14 | value::Scalar Matrix_test2(); 15 | value::Scalar Matrix_test3(); 16 | value::Scalar Matrix_test4(); 17 | value::Scalar Reshape_test(); 18 | value::Scalar GEMV_test(); 19 | value::Scalar MatrixReferenceTest(); 20 | value::Scalar RefMatrixReferenceTest(); 21 | } // namespace accera 22 | -------------------------------------------------------------------------------- /docs/Tutorials/cross_compilation_pi3/hello_matmul_pi3_runner.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Include the HAT file that declares our MatMul function 5 | #include "hello_matmul_pi3.hat" 6 | 7 | #define M 128 8 | #define N 256 9 | #define K 256 10 | 11 | int main(int argc, const char** argv) 12 | { 13 | // Prepare our matrices 14 | float A[M*K]; 15 | float B[K*N]; 16 | float C[M*N]; 17 | 18 | // Fill with data 19 | std::fill_n(A, M*K, 2.0f); 20 | std::fill_n(B, K*N, 3.0f); 21 | std::fill_n(C, M*N, 0.42f); 22 | 23 | printf("Calling MatMul M=%d, K=%d, N=%d\n", M, K, N); 24 | hello_matmul_py(A, B, C); 25 | 26 | printf("Result (first few elements): "); 27 | for (int i = 0; i < 10; ++i) 28 | { 29 | printf("%f ", C[i]); 30 | } 31 | printf("\n"); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /accera/runtime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(src src/Random.cpp) 7 | 8 | set(include include/Random.h) 9 | 10 | set(library_name runtime) 11 | 12 | add_library(${library_name} ${src} ${include}) 13 | target_include_directories( 14 | ${library_name} PRIVATE include) 15 | 16 | # 17 | # Install headers and library 18 | # 19 | InstallAcceraHeaders( 20 | INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include 21 | ${CMAKE_CURRENT_LIST_DIR}/include 22 | ) 23 | InstallAcceraLibrary(${library_name}) 24 | -------------------------------------------------------------------------------- /accera/transforms/include/value/RangeValueOptimizePass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | // fwd decls 12 | namespace mlir 13 | { 14 | class Pass; 15 | class RewritePatternSet; 16 | } // namespace mlir 17 | 18 | namespace accera::transforms::value 19 | { 20 | void populateRangeValueOptimizePatterns(mlir::RewritePatternSet& patterns); 21 | 22 | std::unique_ptr createRangeValueOptimizePass(); 23 | } // namespace accera::transforms::value 24 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | #################################################################################################### 4 | # Copyright (c) Microsoft Corporation. All rights reserved. 5 | # Licensed under the MIT License. See LICENSE in the project root for license information. 6 | #################################################################################################### 7 | 8 | from setuptools import setup 9 | 10 | import os 11 | import pathlib 12 | import sys 13 | 14 | SCRIPT_DIR = pathlib.Path(os.path.abspath(__file__)).parent 15 | sys.path.append(str(SCRIPT_DIR / "accera/python/setuputils")) 16 | import setuputils as utils 17 | 18 | setup(ext_modules=[utils.CMakeExtension("_lang_python")], 19 | cmdclass=dict(build_ext=utils.CMakeBuild), 20 | use_scm_version=utils.scm_version("accera/python/accera/_version.py")) 21 | -------------------------------------------------------------------------------- /accera/ir/include/LLVMEmitterTargets.h.in: -------------------------------------------------------------------------------- 1 | // Auto-generated 2 | // The contents of this file are based on the CMake variable LLVM_EMITTER_TARGETS 3 | // Specified in accera/ir/CMakeLists.txt 4 | // The generated preprocessor define is part of an X-Macro (https://en.wikipedia.org/wiki/X_Macro) 5 | // The other part of the X-Macro relies on the definition of the macro EMITTER_TARGET_ACTION(TargetName) 6 | 7 | //////////////////////////////////////////////////////////////////////////////////////////////////// 8 | // Copyright (c) Microsoft Corporation. All rights reserved. 9 | // Licensed under the MIT License. See LICENSE in the project root for license information. 10 | // Authors: Kern Handa 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// 12 | 13 | #define LLVM_EMITTER_TARGETS \ 14 | @emitter_targets_content@ 15 | -------------------------------------------------------------------------------- /accera/transforms/include/value/FunctionPointerResolutionPass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Mason Remy 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | // fwd decls 12 | namespace mlir 13 | { 14 | class ModuleOp; 15 | class Pass; 16 | template 17 | class OperationPass; 18 | } // namespace mlir 19 | 20 | namespace accera::transforms::value 21 | { 22 | 23 | std::unique_ptr> createFunctionPointerResolutionPass(); 24 | } // namespace accera::transforms::value 25 | -------------------------------------------------------------------------------- /docs/Reference/enumerations/MMAFragmentOp.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | ## `accera.MMAFragmentOp` 6 | 7 | type | description | Mathematical formula 8 | --- | --- | --- 9 | `accera.MMAFragmentOp.NONE` | No-op which does not modify the fragment data. | `f(x) = x` 10 | `accera.MMAFragmentOp.ReLU` | Rectified linear unit activation function ([details](https://en.wikipedia.org/wiki/Rectifier_(neural_networks))). | `f(x) = max(0, x)` 11 | `accera.MMAFragmentOp.ReLU_NoConditional` | Rectified linear unit activation function which does not generate divergent code. | `f(x) = x * bool(x > 0)` 12 | `accera.MMAFragmentOp.SET` | Sets the data to scalar constant, C. | `f(x) = C` 13 | `accera.MMAFragmentOp.SCALE` | Multiplies the data by a scalar constant, C. | `f(x) = C.f(x)` 14 | 15 |
16 | -------------------------------------------------------------------------------- /accera/export/AcceraConfig.cmake.in: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | # This file allows users to call find_package(Accera) and pick up our targets. 6 | 7 | @ACCERA_CONFIG_CODE@ 8 | 9 | set(LLVM_SETUP_VARIANT "@LLVM_SETUP_VARIANT@") 10 | set(ACCERA_EXPORTED_LIBS "@ACCERA_EXPORTED_LIBS@") 11 | set(ACCERA_RUNTIME_LIBS "@ACCERA_RUNTIME_LIBS@") 12 | set(ACCERA_CMAKE_DIR "@ACCERA_CONFIG_CMAKE_DIR@") 13 | set(ACCERA_INCLUDE_DIRS "@ACCERA_CONFIG_INCLUDE_DIRS@") 14 | 15 | # Provide all our library targets to users. 16 | include("@ACCERA_CONFIG_EXPORTS_FILE@") 17 | -------------------------------------------------------------------------------- /docs/Reference/classes/Nest/create_plan.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Nest.create_plan([target])` 7 | Creates a plan using the default schedule for the nest. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `target` | The target platform. Defaults to `acc.Target.HOST` | `Target` 14 | 15 | ## Returns 16 | `Plan` 17 | 18 | ## Examples 19 | 20 | Create a plan for the host computer, using the default schedule for a nest: 21 | 22 | ```python 23 | plan = nest.create_plan() 24 | ``` 25 | 26 | Create a plan for an Intel Core 7th Generation, using the default schedule for a nest: 27 | 28 | ```python 29 | corei9 = acc.Target("Intel 7900X", num_threads=44) 30 | plan = nest.create_plan(corei9) 31 | ``` 32 | 33 | 34 |
35 | -------------------------------------------------------------------------------- /accera/acc-translate/src/Target/Cpp/AMDGPU.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #ifndef DIALECT_ARGO_AMDGPU_H_ 8 | #define DIALECT_ARGO_AMDGPU_H_ 9 | 10 | #include 11 | #include 12 | 13 | namespace mlir 14 | { 15 | namespace cpp_printer 16 | { 17 | 18 | llvm::Optional GetAMDMFMAOpName(const mlir::Type& aTy, const mlir::Type& bTy, const mlir::Type& cTy, const mlir::Type& resTy); 19 | 20 | } // namespace cpp_printer 21 | } // namespace mlir 22 | 23 | #endif // DIALECT_ARGO_AMDGPU_H_ 24 | -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_rectangle_A6000.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 384,288,512,0,0,1,1,384,512,384 3 | 384,288,512,1,0,1,1,512,512,384 4 | 384,288,512,0,1,1,1,384,288,384 5 | 384,288,512,1,1,1,1,512,288,384 6 | 768,576,1024,0,0,1,1,768,1024,768 7 | 768,576,1024,1,0,1,1,1024,1024,768 8 | 768,576,1024,0,1,1,1,768,576,768 9 | 768,576,1024,1,1,1,1,1024,576,768 10 | 1536,1152,2048,0,0,1,1,1536,2048,1536 11 | 1536,1152,2048,1,0,1,1,2048,2048,1536 12 | 1536,1152,2048,0,1,1,1,1536,1152,1536 13 | 1536,1152,2048,1,1,1,1,2048,1152,1536 14 | 3072,2304,4096,0,0,1,1,3072,4096,3072 15 | 3072,2304,4096,1,0,1,1,4096,4096,3072 16 | 3072,2304,4096,0,1,1,1,3072,2304,3072 17 | 3072,2304,4096,1,1,1,1,4096,2304,3072 18 | 6144,4608,8192,0,0,1,1,6144,8192,6144 19 | 6144,4608,8192,1,0,1,1,8192,8192,6144 20 | 6144,4608,8192,0,1,1,1,6144,4608,6144 21 | 6144,4608,8192,1,1,1,1,8192,4608,6144 22 | -------------------------------------------------------------------------------- /accera/transforms/include/value/ValueSimplifyPass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa, Mason Remy 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | // fwd decls 12 | namespace mlir 13 | { 14 | class Pass; 15 | 16 | class RewritePatternSet; 17 | using RewritePatternSet = RewritePatternSet; 18 | } // namespace mlir 19 | 20 | namespace accera::transforms::value 21 | { 22 | void populateValueSimplifyPatterns(mlir::RewritePatternSet& patterns); 23 | std::unique_ptr createValueSimplifyPass(); 24 | } // namespace accera::transforms::value 25 | -------------------------------------------------------------------------------- /accera/value/include/Range.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs, Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | namespace value 14 | { 15 | namespace loopnests 16 | { 17 | /// 18 | /// A class representing the half-open interval `[begin, end)`, with an increment between points of _increment. 19 | /// 20 | using Range = accera::ir::loopnest::Range; 21 | } // namespace loopnests 22 | } // namespace value 23 | } // namespace accera 24 | -------------------------------------------------------------------------------- /accera/value/test/include/LoopNest_convolution_test.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Mason Remy 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | namespace accera 10 | { 11 | namespace value 12 | { 13 | class Scalar; 14 | } 15 | 16 | value::Scalar EfficientDirectConvolution_Test1(); 17 | value::Scalar EfficientDirectConvolution_Test2(); 18 | value::Scalar EfficientDirectConvolution_Test3(); 19 | value::Scalar EfficientDirectConvolution_Test4(); 20 | value::Scalar EfficientDirectConvolution_Test5(); 21 | value::Scalar EfficientDirectConvolution_Test6(); 22 | 23 | } // namespace accera 24 | -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_rectangle_MI100.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 640,384,512,0,0,1,1,640,512,640 3 | 640,384,512,1,0,1,1,512,512,640 4 | 640,384,512,0,1,1,1,640,384,640 5 | 640,384,512,1,1,1,1,512,384,640 6 | 1280,768,1024,0,0,1,1,1280,1024,1280 7 | 1280,768,1024,1,0,1,1,1024,1024,1280 8 | 1280,768,1024,0,1,1,1,1280,768,1280 9 | 1280,768,1024,1,1,1,1,1024,768,1280 10 | 2560,1536,2048,0,0,1,1,2560,2048,2560 11 | 2560,1536,2048,1,0,1,1,2048,2048,2560 12 | 2560,1536,2048,0,1,1,1,2560,1536,2560 13 | 2560,1536,2048,1,1,1,1,2048,1536,2560 14 | 5120,3072,4096,0,0,1,1,5120,4096,5120 15 | 5120,3072,4096,1,0,1,1,4096,4096,5120 16 | 5120,3072,4096,0,1,1,1,5120,3072,5120 17 | 5120,3072,4096,1,1,1,1,4096,3072,5120 18 | 10240,6144,8192,0,0,1,1,10240,8192,10240 19 | 10240,6144,8192,1,0,1,1,8192,8192,10240 20 | 10240,6144,8192,0,1,1,1,10240,6144,10240 21 | 10240,6144,8192,1,1,1,1,8192,6144,10240 22 | -------------------------------------------------------------------------------- /accera/value/include/IterationDomain.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs, Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | namespace value 14 | { 15 | namespace loopnests 16 | { 17 | /// 18 | /// The set of all points (IterationVectors) to be visited by a loop or loop nest. 19 | /// 20 | using IterationDomain = accera::ir::loopnest::IterationDomain; 21 | } // namespace loopnests 22 | } // namespace value 23 | } // namespace accera 24 | -------------------------------------------------------------------------------- /accera/ir/test/nest_dialect_test/nest_test_main.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #define CATCH_CONFIG_RUNNER 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | int main(int argc, char** argv) 21 | { 22 | int result = Catch::Session().run(argc, argv); 23 | return result; 24 | } 25 | -------------------------------------------------------------------------------- /accera/mlirHelpers/include/TranslateToLLVMIR.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa, Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace mlir 14 | { 15 | class MLIRContext; 16 | 17 | template 18 | class OwningOpRef; 19 | class ModuleOp; 20 | } // namespace mlir 21 | 22 | namespace accera 23 | { 24 | namespace ir 25 | { 26 | std::unique_ptr TranslateToLLVMIR(mlir::OwningOpRef& module, llvm::LLVMContext& context); 27 | } // namespace mlirHelpers 28 | } // namespace accera 29 | -------------------------------------------------------------------------------- /accera/acc-gpu-runner/acc_gpu_runner_config.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # Authors: Mason Remy 6 | # Requires: Python 3.5+ 7 | #################################################################################################### 8 | 9 | import os 10 | 11 | from build_config import BuildConfig 12 | 13 | __script_path = os.path.dirname(os.path.abspath(__file__)) 14 | bin_dir = __script_path # Assume this script is deployed into the install bin dir 15 | 16 | class RCGPURunnerConfig: 17 | rc_gpu_runner = os.path.join(bin_dir, "acc-gpu-runner") 18 | vulkan_runtime_wrapper_shared_library = os.path.join(bin_dir, "acc-vulkan-runtime-wrappers" + BuildConfig.shared_library_extension) 19 | -------------------------------------------------------------------------------- /accera/runtime/include/Random.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Mason Remy 5 | // 6 | // Library for runtime utilities 7 | //////////////////////////////////////////////////////////////////////////////////////////////////// 8 | 9 | #pragma once 10 | 11 | #if defined(__cplusplus) 12 | extern "C" { 13 | #endif // defined(__cplusplus) 14 | 15 | void ResetRandomEngine(unsigned int seed); 16 | 17 | void GetNextRandomValue(float*); 18 | void GetNextRandomIntValue(int*, int lo, int hi); 19 | void GetNextNRandomValues(float* buffer, unsigned int N); 20 | void GetNextNRandomIntValues(int* buffer, int lo, int hi, unsigned int N); 21 | 22 | #if defined(__cplusplus) 23 | } // extern "C" 24 | #endif // defined(__cplusplus) 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Support Questions 4 | title: "[Q] " 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | 13 | 14 | 15 | ## Question 16 | ### What's your question? 17 | 18 | 19 | ### Include context on what you are trying to achieve 20 | 21 | 22 | #### Context details 23 | 24 | 25 | 26 | ### Include details of what you already did to find answers 27 | -------------------------------------------------------------------------------- /accera/acc-translate/src/Target/Cpp/TranslateToCpp.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #ifndef MLIR_TARGET_CPP_EMITTER_H 8 | #define MLIR_TARGET_CPP_EMITTER_H 9 | 10 | #include "mlir/Support/LogicalResult.h" 11 | 12 | // Forward-declare LLVM classes 13 | namespace llvm 14 | { 15 | class raw_ostream; 16 | } // namespace llvm 17 | 18 | namespace mlir 19 | { 20 | class Operation; 21 | 22 | /// Convert the given model operation into C++ code. 23 | LogicalResult translateModuleToCpp(Operation* m, raw_ostream& os, int indexBitwidth); 24 | 25 | } // namespace mlir 26 | 27 | #endif // MLIR_TARGET_CPP_EMITTER_H 28 | -------------------------------------------------------------------------------- /accera/value/include/ScalarDimension.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include "Scalar.h" 9 | 10 | namespace accera 11 | { 12 | namespace value 13 | { 14 | class ScalarDimension : public Scalar 15 | { 16 | public: 17 | ScalarDimension(Role role = Role::Input); 18 | ScalarDimension(const std::string& name, Role role = Role::Input); 19 | ScalarDimension(Value value, const std::string& name = "", Role role = Role::Input); 20 | ~ScalarDimension(); 21 | 22 | virtual void SetValue(Value value) final; 23 | }; 24 | } // namespace value 25 | } // namespace accera 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '[Feature] ' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | 13 | 14 | ## What feature are you suggesting? 15 | ### Overview: 16 | 17 | 18 | ### Smaller Details: 19 | 20 | 21 | ### Nature of Request: 22 | 23 | - Addition 24 | - Change 25 | - Removal 26 | 27 | 28 | ## Why would this feature be useful? 29 | -------------------------------------------------------------------------------- /accera/transforms/include/affine/AffineSimplifications.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace mlir 11 | { 12 | class Pass; 13 | class RewritePatternSet; 14 | using OwningRewritePatternList = RewritePatternSet; 15 | } // namespace mlir 16 | 17 | namespace accera::transforms::affine 18 | { 19 | void populateAcceraAffineExprSimplificationPatterns(mlir::OwningRewritePatternList& patterns); 20 | void populateAcceraAffineLoopSimplificationPatterns(mlir::OwningRewritePatternList& patterns); 21 | std::unique_ptr createAffineSimplificationPass(); 22 | } // namespace accera::transforms::affine 23 | -------------------------------------------------------------------------------- /docs/Reference/classes/Schedule/tile.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Schedule.tile(shape)` 7 | The `tile` transformation is a convenience syntax that takes a tuple of indices and a tuple of sizes, and splits each index by the corresponding size. The indices involved in the split are then ordered such that all the outer indices precede all of their respective inner indices. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `shape` | Mapping of indices to tile sizes | dict of `Index` and non-negative integers 14 | 15 | ## Returns 16 | Tuple of `Index` representing the new inner dimensions. 17 | 18 | ## Examples 19 | 20 | Tile the `i`, `j`, and `k` dimensions by 8, 2, and 3, respectively. 21 | 22 | ```python 23 | ii, jj, kk = schedule.tile({ 24 | i: 8, 25 | j: 2, 26 | k: 3 27 | }) 28 | ``` 29 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /CMake/AddPyBind11.cmake: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | include(FetchContent) 7 | 8 | set(PYBIND_VERSION "2.10.1" CACHE STRING "Version string to use for pybind11") 9 | 10 | set(FETCHCONTENT_QUIET FALSE) 11 | 12 | FetchContent_Declare( 13 | pybind11 14 | URL https://github.com/pybind/pybind11/archive/v${PYBIND_VERSION}.tar.gz 15 | ) 16 | 17 | FetchContent_GetProperties(pybind11) 18 | 19 | set(Python3_FIND_REGISTRY LAST) 20 | find_package(Python3 COMPONENTS Interpreter Development) 21 | 22 | if(NOT pybind11_POPULATED) 23 | FetchContent_Populate(pybind11) 24 | add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}) 25 | endif() 26 | -------------------------------------------------------------------------------- /accera/acc-lsp-server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(util_name acc-lsp-server) 7 | 8 | set(util_src src/acc-lsp-server.cpp) 9 | 10 | source_group("src" FILES ${util_src}) 11 | 12 | add_executable(${util_name} ${util_src}) 13 | target_include_directories(${util_name} PRIVATE ${ACCERA_ROOT}/accera) 14 | 15 | target_link_libraries( 16 | ${util_name} 17 | PRIVATE MLIRLspServerLib 18 | utilities 19 | ir 20 | transforms 21 | value 22 | mlirHelpers 23 | ) 24 | copy_shared_libraries(${util_name}) 25 | 26 | # 27 | # Install acc-lsp-server binary 28 | # 29 | InstallAcceraRuntime(${util_name}) 30 | -------------------------------------------------------------------------------- /accera/utilities/test/src/Hash_test.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace accera 15 | { 16 | 17 | TEST_CASE("Hash") 18 | { 19 | CHECK(std::hash{}(3) == utilities::HashValue(3)); 20 | 21 | size_t seed = 0; 22 | utilities::HashCombine(seed, 3); 23 | 24 | CHECK(seed == utilities::HashValue(std::tuple{ 3 })); 25 | 26 | REQUIRE(utilities::HashValue(std::vector{ 1, 2, 3 }) != utilities::HashValue(std::vector{ 3, 2, 1 })); 27 | } 28 | 29 | } // namespace accera 30 | -------------------------------------------------------------------------------- /docs/Reference/enumerations/ScalarType.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.ScalarType` 7 | 8 | type | description 9 | --- | --- 10 | `accera.ScalarType.bool` | boolean 11 | `accera.ScalarType.float16` | 16-bit floating point number 12 | `accera.ScalarType.float32` | 32-bit floating point number 13 | `accera.ScalarType.float64` | 64-bit floating point number 14 | `accera.ScalarType.bfloat16` | 16-bit Brain floating point number 15 | `accera.ScalarType.int8` | 8-bit signed integer 16 | `accera.ScalarType.int16` | 16-bit signed integer 17 | `accera.ScalarType.int32` | 32-bit signed integer 18 | `accera.ScalarType.int64` | 64-bit signed integer 19 | `accera.ScalarType.uint8` | 8-bit unsigned integer 20 | `accera.ScalarType.uint16` | 16-bit unsigned integer 21 | `accera.ScalarType.uint32` | 32-bit unsigned integer 22 | `accera.ScalarType.uint64` | 64-bit unsigned integer 23 | 24 |
25 | -------------------------------------------------------------------------------- /accera/value/test/include/Scalar_test.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace accera 12 | { 13 | value::Scalar Scalar_test1(); 14 | value::Scalar Scalar_test2(); 15 | value::Scalar ScalarRefTest(); 16 | value::Scalar ScalarRefRefTest(); 17 | value::Scalar ScalarRefRefRefTest(); 18 | value::Scalar RefScalarRefTest(); 19 | value::Scalar RefScalarRefCtorsTest(); 20 | value::Scalar RefScalarRefRefTest(); 21 | value::Scalar RefScalarRefRefRefTest(); 22 | value::Scalar SequenceLogicalAndTest(); 23 | value::Scalar SequenceLogicalAndTestWithCopy(); 24 | } // namespace accera 25 | -------------------------------------------------------------------------------- /docs/Tutorials/optimized_matmul/optimized_matmul_runner.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Include the HAT file that declares our MatMul function 5 | #include "optimized_matmul.hat" 6 | 7 | #define M 784 8 | #define N 512 9 | #define K 128 10 | 11 | int main(int argc, const char** argv) 12 | { 13 | // Prepare our matrices (using the heap for large matrices) 14 | float* A = new float[M*K]; 15 | float* B = new float[K*N]; 16 | float* C = new float[M*N]; 17 | 18 | // Fill with data 19 | std::fill_n(A, M*K, 2.0f); 20 | std::fill_n(B, K*N, 3.0f); 21 | std::fill_n(C, M*N, 0.42f); 22 | 23 | printf("Calling MatMul M=%d, K=%d, N=%d\n", M, K, N); 24 | optimized_matmul_py(A, B, C); 25 | 26 | printf("Result (first 10 elements): "); 27 | for (int i = 0; i < 10; ++i) 28 | { 29 | printf("%f ", C[i]); 30 | } 31 | printf("\n"); 32 | 33 | delete[] A; 34 | delete[] B; 35 | delete[] C; 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /docs/Install/Installing_Accera_on_Ubuntu.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | ## Installing on Ubuntu 5 | 6 | ### Install dependencies 7 | 8 | Accera requires the following tools and libraries for building the generated code: 9 | 10 | * A C++ compiler, such as *GCC 8* 11 | * Python 3.7 or newer 12 | * OpenMP 5, if using parallelization 13 | 14 | Ubuntu 20.04 is recommended. A quick way to start is to use a new Docker container for Ubuntu 20.04: 15 | 16 | ```shell 17 | docker run -v $PWD:/code -it --entrypoint "/bin/bash" ubuntu:focal 18 | ``` 19 | 20 | Install Accera's dependencies: 21 | 22 | ```shell 23 | apt update 24 | apt-get install gcc-8 g++-8 python3 python3-pip libncurses5 25 | ``` 26 | 27 | Install the optional dependency if using parallelization: 28 | 29 | ```shell 30 | apt-get install libomp-11-dev 31 | ``` 32 | 33 | ### Install Accera 34 | 35 | The `accera` Python package can be installed from PyPI: 36 | 37 | ```shell 38 | pip install accera 39 | ``` 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/Case Studies/README.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera Case Studies 5 | 6 | Accera case studies are community-provided samples that showcase the Accera language and programming model. To contribute a case study of your own, follow [these instructions](CONTRIBUTING.md). 7 | 8 | ### MatMul Grid Search 9 | 10 | - [MatMul Grid Search](https://github.com/marina-neseem/Accera-High-Perf-DL/blob/9e0ab7646af6ced2c85dc61c7ece2d764a91644e/case_studies/matmul_gridsearch_on_avx2/README.md) 11 | 12 | ### Convolution 13 | 14 | - [NCHWc 2D Convolution Grid Search](https://github.com/marina-neseem/Accera-High-Perf-DL/blob/9e0ab7646af6ced2c85dc61c7ece2d764a91644e/case_studies/nchwc_convolution_gridsearch/README.md) 15 | 16 | - [Unrolled 2D Convolution Grid Search](https://github.com/marina-neseem/Accera-High-Perf-DL/blob/2730675d9a3779631161db6113b2566c54ab23f9/case_studies/unrolled_convolution_gridsearch/README.md) 17 | 18 | ### Three Matrix Multiplication 19 | 20 | - (Coming soon) 21 | -------------------------------------------------------------------------------- /accera/acc-opt/test/lit.site.cfg.py.in: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | import lit.llvm 7 | 8 | config.llvm_tools_dir = r"@MLIR_TOOLS_DIR@" 9 | # config.mlir_obj_root = r"@LLVM_PROJ_BUILD@" 10 | config.mlir_tools_dir = r"@MLIR_TOOLS_DIR@" 11 | config.suffixes = ['.mlir', '.cpp'] 12 | config.lit_tools_dir = config.llvm_tools_dir 13 | 14 | config.accera_tools_dir = r"@ACCERA_TOOLS_DIR@" 15 | config.accera_test_src_dir = r"@ACCERA_LIT_TEST_SRC_DIR@" 16 | config.accera_test_build_dir = r"@ACCERA_LIT_TEST_BUILD_DIR@" 17 | 18 | lit.llvm.initialize(lit_config, config) 19 | 20 | # Let the main config do the real work. 21 | lit_config.load_config(config, r"@ACCERA_LIT_TEST_SRC_DIR@/lit.cfg.py") 22 | -------------------------------------------------------------------------------- /docs/Reference/enumerations/MMASchedulingPolicy.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.MMASchedulingPolicy` 7 | 8 | type | description 9 | --- | --- 10 | `accera.MMASchedulingPolicy.PASS_ORDER` | Process pass groups ([fused passes](../../Tutorials/GPU/Tensor_MatMul_GPU.md#tuning-parameters)) sequentially, within each pass group compute all the MFMA blocks. This allocates Accmulator registers required for all the blocks, however it only allocates input (A, B) registers which are only required for the current pass group. 11 | `accera.MMASchedulingPolicy.BLOCK_ORDER` | Process MFMA blocks sequentially, for each block iterate over all the passes. This allocates Accumulator registers required for only 1 block and input (A, B) registers required for the entire pass group currently being processed. In this mode, input data for the same pass group is loaded into registers multiple times, once per block. 12 | 13 |
14 | -------------------------------------------------------------------------------- /accera/testing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(library_name testing) 7 | 8 | set(src 9 | src/testing.cpp 10 | ) 11 | set(include 12 | include/testing.h 13 | ) 14 | 15 | source_group("src" FILES ${src}) 16 | source_group("include" FILES ${include}) 17 | 18 | add_library(${library_name} ${src} ${include}) 19 | target_include_directories(${library_name} PRIVATE include ${ACCERA_LIBRARIES_DIR}) 20 | target_link_libraries(${library_name} utilities) 21 | 22 | set_property(TARGET ${library_name} PROPERTY FOLDER "accera") 23 | 24 | add_library(CatchWrapper OBJECT EXCLUDE_FROM_ALL src/CatchMain.cpp) 25 | target_link_libraries(CatchWrapper PUBLIC Catch2::Catch2WithMain) 26 | -------------------------------------------------------------------------------- /accera/transforms/src/util/DebugUtilities.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak, Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "util/DebugUtilities.h" 8 | 9 | #include 10 | #include 11 | 12 | using namespace mlir; 13 | 14 | namespace accera::transforms 15 | { 16 | struct DumpModulePass : public PassWrapper> 17 | { 18 | void runOnOperation() final 19 | { 20 | auto mod = getOperation(); 21 | mod.dump(); 22 | } 23 | }; 24 | 25 | std::unique_ptr createDumpModulePass() 26 | { 27 | return std::make_unique(); 28 | } 29 | } // namespace accera::transforms -------------------------------------------------------------------------------- /accera/value/include/Profiling.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace accera 14 | { 15 | namespace value 16 | { 17 | void EnterProfileRegion(const std::string& regionName); 18 | void ExitProfileRegion(const std::string& regionName); 19 | void PrintProfileResults(); 20 | 21 | class ProfileRegion 22 | { 23 | public: 24 | explicit ProfileRegion(const std::string& regionName); 25 | ~ProfileRegion(); 26 | 27 | private: 28 | std::string _regionName; 29 | }; 30 | } // namespace value 31 | } // namespace accera 32 | -------------------------------------------------------------------------------- /docs/Reference/classes/Scalar/Scalar.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Scalar([element_type, value])` 7 | Constructs a scalar that holds a number. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `element_type` | The element type. | [`accera.ScalarType`](<../../enumerations/ScalarType.md>), default: `accera.ScalarType.float32`. 14 | `value` | An optional value. | A number. 15 | 16 | ## Examples 17 | 18 | Construct a float32 scalar: 19 | ```python 20 | import accera as acc 21 | 22 | X = acc.Scalar() 23 | ``` 24 | 25 | Construct a float32 scalar and initialize it: 26 | ```python 27 | Pi = acc.Scalar(value=3.14) 28 | ``` 29 | 30 | Construct integer scalars and perform arithmetic operations on them: 31 | ```python 32 | X = acc.Scalar(element_type=acc.ScalarType.int32) 33 | Y = acc.Scalar(element_type=acc.ScalarType.int32) 34 | Y.value = x + 2 35 | ``` 36 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/Reference/classes/Schedule/skew.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Schedule.skew(index, reference_index [, unroll_loops_smaller_than])` 7 | Transforms a dimension with respect to a reference dimension into a parallelogram by padding with empty elements. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `index` | The dimension to skew | `Index` 14 | `reference_index` | The reference dimension | `Index` 15 | `unroll_loops_smaller_than` | Unroll loops that are smaller than this range (non-inclusive) | non-negative integer 16 | 17 | ## Examples 18 | 19 | Skew dimension `i` with respect to dimension `j`: 20 | 21 | ```python 22 | schedule.skew(i, j) 23 | ``` 24 | 25 | Skew dimension `j` with respect to dimension `i`, and unroll if the resulting loops are smaller than 3: 26 | 27 | ```python 28 | schedule.skew(j, i, unroll_loops_smaller_than=3) 29 | ``` 30 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /.azure/rocm/build_agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | #################################################################################################### 6 | set -x -e 7 | 8 | ROCMVER=5.3.0-ub20 9 | 10 | SCRIPT_DIR=$(dirname $(readlink -f "$0")) 11 | ACCERA_ROOT=${SCRIPT_DIR}/../../ 12 | CWD=$(pwd) 13 | 14 | # Running from the repository root, so that the Dockerfile can 15 | # access all repo files from its build context (e.g. requirements.txt) 16 | cd ${ACCERA_ROOT} 17 | sudo docker build . \ 18 | --build-arg ROCMVER=${ROCMVER} \ 19 | --tag acceracontainers.azurecr.io/rocm-linuxagent:${ROCMVER} \ 20 | --file .azure/rocm/Dockerfile 21 | 22 | sudo docker tag acceracontainers.azurecr.io/rocm-linuxagent:${ROCMVER} \ 23 | acceracontainers.azurecr.io/rocm-linuxagent:latest 24 | cd ${CWD} -------------------------------------------------------------------------------- /accera/acc-lsp-server/src/acc-lsp-server.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include 8 | #include 9 | 10 | #include "mlir/IR/Dialect.h" 11 | #include "mlir/IR/MLIRContext.h" 12 | #include "mlir/InitAllDialects.h" 13 | #include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h" 14 | 15 | using namespace mlir; 16 | 17 | int main(int argc, char** argv) 18 | { 19 | mlir::DialectRegistry registry; 20 | registerAllDialects(registry); 21 | accera::ir::GetDialectRegistry().appendTo(registry); 22 | accera::transforms::RegisterAllPasses(); 23 | return failed(MlirLspServerMain(argc, argv, registry)); 24 | } -------------------------------------------------------------------------------- /accera/python/accera/lang/DimensionUtilities.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | from typing import * 7 | from varname import varname 8 | 9 | from .._lang_python import Role 10 | from .._lang_python._lang import Dimension 11 | 12 | def create_dimensions(role=Role.INPUT): 13 | try: 14 | names = varname(multi_vars=True) 15 | return ( 16 | tuple([Dimension(name=n, role=role) for n in names]) 17 | if len(names) > 1 18 | else Dimension(name=names[0], role=role) 19 | ) 20 | except Exception as e: 21 | raise RuntimeError( 22 | "Caller didn't assign the return value(s) of create_dimensions() directly to any variable(s)" 23 | ) 24 | -------------------------------------------------------------------------------- /accera/python/accera/lang/LoopIndex.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | 7 | class LoopIndex: 8 | def __init__(self, nest=None, name=None): 9 | self._nest = nest 10 | self.base_index = id(self) 11 | self._name = name 12 | 13 | def __eq__(self, other): 14 | return id(self) == id(other) 15 | 16 | def __hash__(self): 17 | return id(self) 18 | 19 | def create_child_index(self): 20 | child = LoopIndex(self._nest) 21 | child.base_index = self.base_index 22 | return child 23 | 24 | @property 25 | def name(self): 26 | return self._name 27 | 28 | @name.setter 29 | def name(self, value): 30 | self._name = value 31 | -------------------------------------------------------------------------------- /.azure/cuda/build_agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | #################################################################################################### 6 | set -x -e 7 | 8 | CUDAVER=11.8.0-devel-ubuntu20.04 9 | 10 | SCRIPT_DIR=$(dirname $(readlink -f "$0")) 11 | ACCERA_ROOT=${SCRIPT_DIR}/../../ 12 | CWD=$(pwd) 13 | 14 | # Running from the repository root, so that the Dockerfile can 15 | # access all repo files from its build context (e.g. requirements.txt) 16 | cd ${ACCERA_ROOT} 17 | sudo docker build . \ 18 | --build-arg CUDAVER=${CUDAVER} \ 19 | --tag acceracontainers.azurecr.io/cuda-linuxagent:${CUDAVER} \ 20 | --file .azure/cuda/Dockerfile 21 | 22 | sudo docker tag acceracontainers.azurecr.io/cuda-linuxagent:${CUDAVER} \ 23 | acceracontainers.azurecr.io/cuda-linuxagent:latest 24 | cd ${CWD} -------------------------------------------------------------------------------- /accera/mlirHelpers/src/TranslateToLLVMIR.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #ifdef _MSC_VER 8 | #pragma warning(disable : 4146) 9 | #endif 10 | 11 | #include "TranslateToLLVMIR.h" 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef _MSC_VER 20 | #pragma warning(enable : 4146) 21 | #endif 22 | 23 | namespace accera::ir 24 | { 25 | std::unique_ptr TranslateToLLVMIR(mlir::OwningOpRef& module, llvm::LLVMContext& context) 26 | { 27 | return mlir::translateModuleToLLVMIR(*module, context); 28 | } 29 | 30 | } // namespace accera::ir 31 | -------------------------------------------------------------------------------- /tools/benchmarkers/gemm_square.csv: -------------------------------------------------------------------------------- 1 | m,n,k,transA,transB,alpha,beta,lda,ldb,ldc 2 | 256,256,256,0,0,1,1,256,256,256 3 | 256,256,256,1,0,1,1,256,256,256 4 | 256,256,256,0,1,1,1,256,256,256 5 | 256,256,256,1,1,1,1,256,256,256 6 | 512,512,512,0,0,1,1,512,512,512 7 | 512,512,512,1,0,1,1,512,512,512 8 | 512,512,512,0,1,1,1,512,512,512 9 | 512,512,512,1,1,1,1,512,512,512 10 | 1024,1024,1024,0,0,1,1,1024,1024,1024 11 | 1024,1024,1024,1,0,1,1,1024,1024,1024 12 | 1024,1024,1024,0,1,1,1,1024,1024,1024 13 | 1024,1024,1024,1,1,1,1,1024,1024,1024 14 | 2048,2048,2048,0,0,1,1,2048,2048,2048 15 | 2048,2048,2048,1,0,1,1,2048,2048,2048 16 | 2048,2048,2048,0,1,1,1,2048,2048,2048 17 | 2048,2048,2048,1,1,1,1,2048,2048,2048 18 | 4096,4096,4096,0,0,1,1,4096,4096,4096 19 | 4096,4096,4096,1,0,1,1,4096,4096,4096 20 | 4096,4096,4096,0,1,1,1,4096,4096,4096 21 | 4096,4096,4096,1,1,1,1,4096,4096,4096 22 | 8192,8192,8192,0,0,1,1,8192,8192,8192 23 | 8192,8192,8192,1,0,1,1,8192,8192,8192 24 | 8192,8192,8192,0,1,1,1,8192,8192,8192 25 | 8192,8192,8192,1,1,1,1,8192,8192,8192 26 | -------------------------------------------------------------------------------- /accera/mlirHelpers/include/ConvertToLLVM.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa, Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace accera::value 18 | { 19 | class Value; 20 | } 21 | 22 | namespace accera 23 | { 24 | namespace ir 25 | { 26 | mlir::ModuleOp ConvertToLLVM( 27 | mlir::ModuleOp module, 28 | std::function addStdPassesFn, 29 | std::function addLLVMPassesFn); 30 | 31 | } // namespace mlirHelpers 32 | } // namespace accera 33 | -------------------------------------------------------------------------------- /accera/ir/test/nest_dialect_test/Test.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | using SetupFunc = std::function; 14 | using VerifyFunc = std::function&, mlir::FuncOp&)>; 15 | 16 | void RunTest(std::string testName, SetupFunc&& setupFunc, std::string verifyName, VerifyFunc&& verifyFunc); 17 | 18 | // 19 | // RUN_TEST macro 20 | // 21 | #define RUN_TEST(Test, Verify) \ 22 | do \ 23 | { \ 24 | RunTest(#Test, (Test), #Verify, (Verify)); \ 25 | } while (0) 26 | -------------------------------------------------------------------------------- /accera/transforms/src/gpu/SerializeToHSACO.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak, Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "AcceraPasses.h" 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | class SerializeToHsacoPass : public accera::transforms::SerializeToHSACOBase 16 | { 17 | public: 18 | void runOnOperation() override 19 | { 20 | // noop 21 | } 22 | }; 23 | 24 | namespace accera::transforms 25 | { 26 | std::unique_ptr> createSerializeToHSACOPass() 27 | { 28 | return std::make_unique(); 29 | } 30 | } // namespace accera::transforms 31 | -------------------------------------------------------------------------------- /accera/ir/include/nest/LoopIndexInfo.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include "Index.h" 10 | #include "Range.h" 11 | 12 | #include 13 | 14 | #include 15 | 16 | namespace accera::ir 17 | { 18 | namespace loopnest 19 | { 20 | enum class LoopIndexState 21 | { 22 | notVisited, 23 | inProgress, 24 | done 25 | }; 26 | 27 | struct LoopIndexSymbolTableEntry 28 | { 29 | mlir::Value value; 30 | Range loopRange; 31 | LoopIndexState state; 32 | }; 33 | using LoopIndexSymbolTable = std::unordered_map; 34 | } // namespace loopnest 35 | } // namespace accera::ir 36 | -------------------------------------------------------------------------------- /accera/ir/include/value/ValueRangeOp.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | namespace accera::ir::value 9 | { 10 | 11 | using mlir::Type; 12 | using mlir::TypeStorage; 13 | 14 | /// A RangeType represents a minimal range abstraction (min, max, step). 15 | /// It is constructed by calling the accv.range op with three values index of 16 | /// index type: 17 | /// 18 | /// ```mlir 19 | /// func @foo(%arg0 : index, %arg1 : index, %arg2 : index) { 20 | /// %0 = accv.range %arg0:%arg1:%arg2 : !accv.range 21 | /// } 22 | /// ``` 23 | class RangeType : public Type::TypeBase { 24 | public: 25 | // Used for generic hooks in TypeBase. 26 | using Base::Base; 27 | }; 28 | 29 | } // accera::ir::value -------------------------------------------------------------------------------- /accera/acc-translate/src/Target/LLVMIR/IntrinsicToLLVMIRTranslation.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | namespace mlir 9 | { 10 | 11 | class DialectRegistry; 12 | class MLIRContext; 13 | 14 | } // namespace mlir 15 | 16 | namespace accera::transforms::intrinsics 17 | { 18 | 19 | /// Register the Intrinsic dialect and the translation from it to the LLVM IR 20 | /// in the given registry; 21 | void registerIntrinsicsDialectTranslation(mlir::DialectRegistry& registry); 22 | 23 | /// Register the Intrinsic dialect and the translation from it in the registry 24 | /// associated with the given context. 25 | void registerIntrinsicsDialectTranslation(mlir::MLIRContext& context); 26 | 27 | } // namespace accera::transforms::intrinsics 28 | -------------------------------------------------------------------------------- /accera/ir/include/exec/InPlaceUnrollInfo.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace accera::ir 11 | { 12 | namespace executionPlan 13 | { 14 | struct InPlaceUnrollInfo 15 | { 16 | int64_t loopUnrollFactor = 0; 17 | 18 | private: 19 | friend inline bool operator==(const InPlaceUnrollInfo& ipu1, const InPlaceUnrollInfo& ipu2) 20 | { 21 | return (ipu1.loopUnrollFactor == ipu2.loopUnrollFactor); 22 | } 23 | friend inline bool operator!=(const InPlaceUnrollInfo& ipu1, const InPlaceUnrollInfo& ipu2) 24 | { 25 | return !(ipu1 == ipu2); 26 | } 27 | }; 28 | } // namespace executionPlan 29 | } // namespace accera::ir 30 | -------------------------------------------------------------------------------- /docs/Reference/enumerations/CacheStrategy.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.CacheStrategy` 7 | 8 | type | description 9 | --- | --- 10 | `accera.CacheStrategy.BLOCKED` | Every thread copies a contiguous block of memory based on their thread index. e.g. If 100 elements are cached by 10 threads, thread 0 copies elements [0, 10), thread 1 copies elements [10, 20) and so on. 11 | `accera.CacheStrategy.STRIPED` | Every thread copies a part of their contribution in a round-robin fashion. e.g. In the previous example, thread 0 will now copy elements [0, 2), [20, 22), [40, 42), [60, 62) and [80, 82), thread 1 will copy [2, 4), [22, 24), [42, 44), [62, 64) and [82, 84) and so on. The minimum number of contiguous elements that each thread copies is governed by the vectorization parameter, which in this example is 2. 12 | 13 | The effects of different caching strategies can be noticed as performance characteristics arising out of overhead caused by bank conflicts, memory coalescing etc. 14 | 15 |
16 | -------------------------------------------------------------------------------- /CMake/CompilerCache.cmake: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | if(NOT DEFINED ENV{CMAKE_COMPILER_CACHE}) 7 | set(CMAKE_COMPILER_CACHE ON) 8 | else() 9 | set(CMAKE_COMPILER_CACHE $ENV{CMAKE_COMPILER_CACHE}) 10 | endif() 11 | option(USE_COMPILER_CACHE "Use a compiler cache (ccache) to speed up build times" ${CMAKE_COMPILER_CACHE}) 12 | 13 | if(USE_COMPILER_CACHE) 14 | find_program(CCACHE_EXECUTABLE ccache) 15 | if(CCACHE_EXECUTABLE) 16 | message(STATUS "Found cccache at ${CCACHE_EXECUTABLE}") 17 | 18 | # Support Unix Makefiles and Ninja 19 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_EXECUTABLE}") 20 | set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_EXECUTABLE}") 21 | endif() 22 | else() 23 | message(STATUS "Not using ccache") 24 | endif() 25 | -------------------------------------------------------------------------------- /accera/python/accera/lang/NativeLoopNestContext.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | from dataclasses import dataclass, field 7 | from typing import Any, Mapping 8 | 9 | 10 | @dataclass 11 | class NativeLoopNestContext: 12 | from .._lang_python._lang import _Nest, _Schedule, _ExecutionPlan 13 | 14 | function_args: list 15 | runtime_args: list 16 | nest: _Nest = None 17 | schedule: _Schedule = None 18 | plan: _ExecutionPlan = None 19 | options: Any = None 20 | 21 | # a mapping that gets updated to keep track of python objects with their native counterparts 22 | # current is used to keep track of Value and LoopIndex instances 23 | mapping: Mapping[int, Any] = field(default_factory=dict) # default_factory is needed because `dict` is a mutable 24 | -------------------------------------------------------------------------------- /docs/Tutorials/hello_matmul_gpu/tensor_sched_policy_matmul_gpu_generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Accera Multi-Pass Tensor MatMul GPU sample: generator 3 | import accera as acc 4 | import tensor_matmul_gpu_generator 5 | 6 | mma_shape = acc.MMAShape.M64xN64xK1_B4 7 | target = acc.Target(acc.Target.Model.AMD_MI100) 8 | package = acc.Package() 9 | 10 | # Pass order 11 | plan, A, B, C, tensor_indices = tensor_matmul_gpu_generator.create_basic_tensor_matmul_plan(target, mma_shape, 64, 64) 12 | plan.tensorize(indices=tensor_indices, mma_shape=mma_shape, scheduling_policy=acc.MMASchedulingPolicy.PASS_ORDER) 13 | package.add(plan, args=(A, B, C), base_name="tensor_pass_order_matmul_gpu") 14 | 15 | # Block order 16 | plan, A, B, C, tensor_indices = tensor_matmul_gpu_generator.create_basic_tensor_matmul_plan(target, mma_shape, 64, 64) 17 | plan.tensorize(indices=tensor_indices, mma_shape=mma_shape, scheduling_policy=acc.MMASchedulingPolicy.BLOCK_ORDER) 18 | package.add(plan, args=(A, B, C), base_name="tensor_block_order_matmul_gpu") 19 | 20 | package.build("tensor_sched_policy_matmul_gpu", format=acc.Package.Format.HAT_SOURCE) -------------------------------------------------------------------------------- /.azure/manylinux/scripts/install.manylinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # 6 | # Note that the line endings in this file should be LF instead of CRLF in order to run correctly. 7 | #################################################################################################### 8 | set -x -e 9 | 10 | # Install pre-requisites for building Accera 11 | yum -y install \ 12 | ninja-build \ 13 | ccache \ 14 | zip 15 | 16 | # Install Python pre-requisites for building Accera 17 | PYTHON_EXES=("/opt/python/cp37-cp37m/bin/python3.7" "/opt/python/cp38-cp38/bin/python3.8" "/opt/python/cp39-cp39/bin/python3.9" "/opt/python/cp310-cp310/bin/python3.10") 18 | 19 | for PYTHON_EXE in "${PYTHON_EXES[@]}" 20 | do 21 | ${PYTHON_EXE} -m pip install -r requirements.txt 22 | done 23 | 24 | # Choose a default Python for general use 25 | ln -s /opt/python/cp39-cp39/bin/python3.9 /usr/bin/python3 -------------------------------------------------------------------------------- /accera/acc-opt/test/ValueFuncToTarget.mlir: -------------------------------------------------------------------------------- 1 | // RUN: acc-opt --canonicalize --value-func-to-target -split-input-file %s | FileCheck %s 2 | 3 | // CHECK-LABEL: module @test_cpu_module1 4 | // CHECK-NEXT: accv.module "accera_test" 5 | // CHECK-NEXT: func @foo 6 | // CHECK-SAME: attributes {exec_target = 0 : i64} 7 | // CHECK-NEXT return 8 | module @test_cpu_module1 { 9 | "accv.module"() ( { 10 | "accv.func"() ( { 11 | accv.return 12 | }) {exec_target = 0 : i64, sym_name = "foo", type = () -> ()} : () -> () 13 | "accv.module_terminator"() : () -> () 14 | }) {sym_name = "accera_test"} : () -> () 15 | } 16 | 17 | // ----- 18 | 19 | // CHECK-LABEL: module @test_gpu_module1 20 | // CHECK-NEXT: accv.module "accera_test" 21 | // CHECK-NEXT: func @foo 22 | // CHECK-SAME: attributes {exec_target = 1 : i64} 23 | // CHECK-NEXT return 24 | module @test_gpu_module1 { 25 | "accv.module"() ( { 26 | "accv.func"() ( { 27 | accv.return 28 | }) {exec_target = 1 : i64, sym_name = "foo", type = () -> ()} : () -> () 29 | "accv.module_terminator"() : () -> () 30 | }) {sym_name = "accera_test"} : () -> () 31 | } 32 | -------------------------------------------------------------------------------- /docs/Tutorials/hello_matmul_gpu/tensor_input_double_buffer_cache_matmul_gpu_generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Accera Tensor Double Buffer Input Caching MatMul GPU sample: generator 3 | import accera as acc 4 | import tensor_input_cache_matmul_gpu_generator 5 | import matmul_utils as utils 6 | 7 | def create_tensor_input_caching_matmul_plan(target: acc.Target): 8 | # Create the tensorized plan 9 | plan, A, B, C, in_cache_idx, out_cache_idx = tensor_input_cache_matmul_gpu_generator.tensorize_cache_matul_plan(target) 10 | 11 | # Add input caching 12 | plan.cache(A, index=in_cache_idx, location=target.MemorySpace.SHARED, double_buffer=True, double_buffer_location=target.MemorySpace.PRIVATE) 13 | plan.cache(B, index=in_cache_idx, location=target.MemorySpace.SHARED, double_buffer=True, double_buffer_location=target.MemorySpace.PRIVATE) 14 | 15 | return plan, A, B, C, out_cache_idx 16 | 17 | target = acc.Target(acc.Target.Model.AMD_MI100) 18 | plan, A, B, C, _ = create_tensor_input_caching_matmul_plan(target) 19 | utils.add_function_build_pkg(plan, A, B, C, "tensor_input_double_buffer_cache_matmul_gpu") 20 | -------------------------------------------------------------------------------- /accera/value/include/ArrayOperations.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include "Array.h" 10 | #include "Scalar.h" 11 | 12 | namespace accera 13 | { 14 | namespace value 15 | { 16 | void CopyArray(Array A, Array B); 17 | void ClearArray(Array A); 18 | void FillArray(Array A, Scalar val); 19 | 20 | Scalar VectorMax(Array v); 21 | Scalar VectorSum(Array v); 22 | 23 | void ClearMatrix(Array A); 24 | void TransposeMatrix(Array A, Array B); 25 | 26 | void MatMulBasic(Array A, Array B, Array C, bool clearC = true); 27 | void MatMulSimpleTiled(Array A, Array B, Array C, bool clearC = true); 28 | void MatMulMlas(Array A, Array B, Array C, bool clearC = true); 29 | } // namespace value 30 | } // namespace accera 31 | -------------------------------------------------------------------------------- /.azure/rocm/scripts/install.builddeps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # 6 | # Note that the line endings in this file should be LF instead of CRLF in order to run correctly. 7 | #################################################################################################### 8 | set -x -e 9 | 10 | # Install Accera CI dependencies 11 | apt-get update && apt-get install --no-install-recommends \ 12 | ccache \ 13 | g++-10 \ 14 | libomp-dev \ 15 | libunwind-dev \ 16 | libvulkan-dev \ 17 | ninja-build \ 18 | pkg-config \ 19 | zip \ 20 | && rm -rf /var/lib/apt/lists/* 21 | 22 | update-alternatives --install /usr/bin/python python /usr/bin/python3 1 23 | 24 | # TODO: support different versions of python if needed 25 | python -m pip install -r requirements.txt 26 | python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/rocm5.1.1 -------------------------------------------------------------------------------- /.azure/manylinux/Dockerfile: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | # Usage: call docker build from the root of this repository 5 | # docker build -f .azure\manylinux\Dockerfile . -t registry_name/accera-llvm-manylinux2014:latest 6 | #################################################################################################### 7 | 8 | # cf: quay.io/pypa/manylinux2014_x86_64:2022-04-24-d28e73e 9 | # cf. https://quay.io/repository/pypa/manylinux2010_x86_64?tab=tags 10 | FROM acceracontainers.azurecr.io/pypa/manylinux2014_x86_64:2022-04-24-d28e73e 11 | 12 | ADD .azure/manylinux/scripts /tmp/scripts 13 | ADD requirements.txt /tmp/scripts/requirements.txt 14 | 15 | WORKDIR /tmp/scripts 16 | RUN sh /tmp/scripts/install.manylinux.sh 17 | RUN sh /tmp/scripts/install.vulkanloader.sh 18 | 19 | ADD external/vcpkg /opt/vcpkg 20 | ADD external/llvm /opt/ports 21 | WORKDIR /opt/vcpkg 22 | RUN sh /tmp/scripts/install.vcpkg.sh 23 | RUN rm -rf /tmp/scripts -------------------------------------------------------------------------------- /accera/ir/include/exec/ExecutionPlanInterfaces.td: -------------------------------------------------------------------------------- 1 | #ifndef EXECUTION_PLAN_INTERFACES 2 | #define EXECUTION_PLAN_INTERFACES 3 | 4 | include "mlir/IR/OpBase.td" 5 | 6 | // 7 | // Cache region common interface 8 | // 9 | 10 | def accxp_BeginCacheRegionOpInterface : OpInterface<"BeginCacheRegion"> { 11 | let description = [{ 12 | Interface for the cache region begin ops 13 | }]; 14 | 15 | let methods = [ 16 | InterfaceMethod<[{ 17 | Returns the corresponding end op for this cache region 18 | }], 19 | "mlir::Operation*", "getEndOp", (ins) 20 | >, 21 | InterfaceMethod<[{ 22 | Returns the ID for this cache region 23 | }], 24 | "int64_t", "getId", (ins) 25 | > 26 | ]; 27 | } 28 | 29 | def accxp_EndCacheRegionOpInterface : OpInterface<"EndCacheRegion"> { 30 | let description = [{ 31 | Interface for the cache region end ops 32 | }]; 33 | 34 | let methods = [ 35 | InterfaceMethod<[{ 36 | Returns the corresponding begin op for this cache region 37 | }], 38 | "mlir::Operation*", "getBeginOp", (ins) 39 | > 40 | ]; 41 | } 42 | 43 | 44 | #endif // EXECUTION_PLAN_INTERFACES -------------------------------------------------------------------------------- /accera/ir/src/intrinsics/AcceraIntrinsicsDialect.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ir/include/intrinsics/AcceraIntrinsicsDialect.h" 7 | 8 | #include "mlir/Dialect/LLVMIR/LLVMTypes.h" 9 | #include "mlir/IR/Builders.h" 10 | #include "mlir/IR/OpImplementation.h" 11 | #include "mlir/IR/TypeUtilities.h" 12 | #include "mlir/Interfaces/InferTypeOpInterface.h" 13 | 14 | using namespace mlir; 15 | 16 | #include "intrinsics/AcceraIntrinsicsDialect.cpp.inc" 17 | 18 | namespace accera::ir::intrinsics 19 | { 20 | 21 | void AcceraIntrinsicsDialect::initialize() 22 | { 23 | addOperations< 24 | #define GET_OP_LIST 25 | #include "intrinsics/AcceraIntrinsics.cpp.inc" 26 | >(); 27 | } 28 | 29 | } // namespace accera::ir::intrinsics 30 | 31 | #define GET_OP_CLASSES 32 | #include "intrinsics/AcceraIntrinsics.cpp.inc" 33 | -------------------------------------------------------------------------------- /docs/Reference/classes/Plan/kernelize.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Plan.kernelize(unroll_indices[, vectorize_indices])` 7 | A convenience method for a sequence of `unroll` instructions followed by a possible sequence of `vectorize` instructions. 8 | 9 | ## Arguments 10 | 11 | argument | description | type/default 12 | --- | --- | --- 13 | `unroll_indices` | The iteration-space dimensions to unroll | tuple of `accera.Index`. 14 | `vectorize_indices` | The optional iteration-space dimensions to vectorize | `accera.Index` or tuple of `accera.Index`. 15 | 16 | ## Examples 17 | 18 | Unroll `i` and `k`, and then vectorize `j`: 19 | 20 | ```python 21 | schedule.reorder(i, k, j) 22 | plan = schedule.create_plan() 23 | plan.kernelize(unroll_indices=(i, k), vectorize_indices=j) 24 | ``` 25 | 26 | Another example is to Unroll `i` and then vectorize `j` and `k`: 27 | 28 | ```python 29 | schedule.reorder(i, j, k) 30 | plan = schedule.create_plan() 31 | plan.kernelize(unroll_indices=(i,), vectorize_indices=(j, k)) 32 | ``` 33 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/Reference/classes/Schedule/split.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Schedule.split(index, size)` 7 | The `split` transformation takes a dimension `i` and a `size`, modifies `i`, and creates a new dimension `ii`. 8 | 9 | Assume that the original size of dimension `i` was *n*: The `split` transformation splits dimension `i` into *ceil(n/size)* parts of size `size`, arranges each of those parts along dimension `ii`, and stacks the *ceil(n/size)* parts along dimension `i`. 10 | 11 | If the split size does not divide the dimension size, empty elements are added such that the split size does divide the dimension size. 12 | 13 | ## Arguments 14 | 15 | argument | description | type/default 16 | --- | --- | --- 17 | `index` | The dimension to split | `Index` 18 | `size` | The split size | non-negative integer 19 | 20 | ## Returns 21 | `Index` for the new inner dimension 22 | 23 | ## Examples 24 | 25 | Split the `i` dimension by 5, creating a new dimension `ii`: 26 | 27 | ```python 28 | ii = schedule.split(j, 5) 29 | ``` 30 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /accera/transforms/include/nest/LoopNestPasses.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace mlir 11 | { 12 | class Pass; 13 | class PassManager; 14 | } // namespace mlir 15 | 16 | namespace accera::transforms 17 | { 18 | namespace loopnest 19 | { 20 | std::unique_ptr createScheduledOperationsPass(); 21 | std::unique_ptr createScheduleToValuePass(); 22 | std::unique_ptr createLoopNestOptPass(); 23 | 24 | void addLoopNestLoweringPasses(mlir::PassManager& pm); 25 | void addLoopNestStructureLoweringPasses(mlir::PassManager& pm); 26 | void addLoopNestFinalLoweringPasses(mlir::PassManager& pm); 27 | void addLoopNestCleanupLoweringPasses(mlir::PassManager& pm); 28 | } // namespace loopnest 29 | } // namespace accera::transforms 30 | -------------------------------------------------------------------------------- /accera/ir/include/TranslateToHeader.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace mlir 17 | { 18 | class MLIRContext; 19 | 20 | template 21 | class OwningOpRef; 22 | class ModuleOp; 23 | } // namespace mlir 24 | 25 | namespace accera 26 | { 27 | namespace ir 28 | { 29 | mlir::LogicalResult TranslateToHeader(mlir::ModuleOp, std::ostream& os); 30 | mlir::LogicalResult TranslateToHeader(mlir::ModuleOp, llvm::raw_ostream& os); 31 | mlir::LogicalResult TranslateToHeader(std::vector& modules, const std::string& libraryName, llvm::raw_ostream& os); 32 | } // namespace ir 33 | } // namespace accera 34 | -------------------------------------------------------------------------------- /accera/ir/src/accera/AcceraOps.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "accera/AcceraOps.h" 8 | #include "accera/AcceraDialect.cpp.inc" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | namespace accera::ir::rc 18 | { 19 | void AcceraDialect::initialize() 20 | { 21 | addOperations< 22 | #define GET_OP_LIST 23 | #include "accera/AcceraOps.cpp.inc" 24 | >(); 25 | } 26 | } // namespace accera::ir::rc 27 | 28 | using namespace llvm; 29 | using namespace mlir; 30 | using namespace accera::ir; 31 | using namespace accera::ir::rc; 32 | 33 | // TableGen'd op method definitions 34 | #define GET_OP_CLASSES 35 | #include "accera/AcceraOps.cpp.inc" 36 | -------------------------------------------------------------------------------- /accera/ir/include/exec/ParallelizationInfo.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace accera::ir 11 | { 12 | namespace executionPlan 13 | { 14 | struct ParallelizationInfo 15 | { 16 | int64_t numThreads = 4; 17 | bool isDynamicPolicy = false; 18 | // TODO: pinning 19 | 20 | private: 21 | friend inline bool operator==(const ParallelizationInfo& p1, const ParallelizationInfo& p2) 22 | { 23 | return (p1.numThreads == p2.numThreads) && (p1.isDynamicPolicy == p2.isDynamicPolicy); 24 | } 25 | friend inline bool operator!=(const ParallelizationInfo& p1, const ParallelizationInfo& p2) 26 | { 27 | return !(p1 == p2); 28 | } 29 | }; 30 | } // namespace executionPlan 31 | } // namespace accera::ir 32 | -------------------------------------------------------------------------------- /docs/Tutorials/hello_matmul/hello_matmul_generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Accera Hello MatMul sample: generator 3 | import accera as acc 4 | 5 | # Define our matrix sizes 6 | M = 128 7 | N = 256 8 | K = 256 9 | 10 | A = acc.Array(role=acc.Role.INPUT, element_type=acc.ScalarType.float32, shape=(M, K)) 11 | B = acc.Array(role=acc.Role.INPUT, element_type=acc.ScalarType.float32, shape=(K, N)) 12 | C = acc.Array(role=acc.Role.INPUT_OUTPUT, element_type=acc.ScalarType.float32, shape=(M, N)) 13 | 14 | # Define the loop nest 15 | nest = acc.Nest(shape=(M, N, K)) 16 | 17 | # Get the loop nest indices 18 | i, j, k = nest.get_indices() 19 | 20 | # Define the loop nest logic 21 | @nest.iteration_logic 22 | def _(): 23 | C[i, j] += A[i, k] * B[k, j] 24 | 25 | schedule = nest.create_schedule() 26 | # Split the k loop into blocks of 4 27 | kk = schedule.split(k, 4) 28 | 29 | plan = schedule.create_plan() 30 | # Then unroll kk 31 | plan.unroll(kk) 32 | 33 | # Create a package and add a function to the package based on the plan 34 | package = acc.Package() 35 | package.add(plan, args=(A, B, C), base_name="hello_matmul_py") 36 | 37 | # Build the HAT package 38 | package.build("hello_matmul") 39 | -------------------------------------------------------------------------------- /external/llvm/0005-Fix-issue-where-passed-in-op-printing-flags-were-ign.patch: -------------------------------------------------------------------------------- 1 | From bb702476975ebfc65d445f8da7d6064a81c09666 Mon Sep 17 00:00:00 2001 2 | From: Chuck Jacobs 3 | Date: Wed, 24 Aug 2022 04:13:49 +0000 4 | Subject: [PATCH 5/6] Merged PR 2823: Fix op-printing bug in 5 | LocationSnapshotPass 6 | 7 | This PR fixes an issue where the printing flags passed in to the LocationSnapshotPass were being ignored. 8 | --- 9 | mlir/lib/Transforms/LocationSnapshot.cpp | 2 +- 10 | 1 file changed, 1 insertion(+), 1 deletion(-) 11 | 12 | diff --git a/mlir/lib/Transforms/LocationSnapshot.cpp b/mlir/lib/Transforms/LocationSnapshot.cpp 13 | index a042d07335bb..808f2ad2a67c 100644 14 | --- a/mlir/lib/Transforms/LocationSnapshot.cpp 15 | +++ b/mlir/lib/Transforms/LocationSnapshot.cpp 16 | @@ -133,7 +133,7 @@ struct LocationSnapshotPass 17 | 18 | void runOnOperation() override { 19 | Operation *op = getOperation(); 20 | - if (failed(generateLocationsFromIR(fileName, op, OpPrintingFlags(), tag))) 21 | + if (failed(generateLocationsFromIR(fileName, op, flags, tag))) 22 | return signalPassFailure(); 23 | } 24 | 25 | -- 26 | 2.37.1 (Apple Git-137.1) 27 | 28 | -------------------------------------------------------------------------------- /accera/utilities/src/TypeName.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "TypeName.h" 8 | 9 | #include 10 | #include 11 | 12 | namespace accera 13 | { 14 | namespace utilities 15 | { 16 | std::string GetCompositeTypeName(std::string baseType, const std::vector& subtypes) 17 | { 18 | if (subtypes.size() == 0) 19 | { 20 | return baseType; 21 | } 22 | std::string result = baseType + "<"; 23 | for (size_t index = 0; index < subtypes.size(); ++index) 24 | { 25 | if (index != 0) 26 | { 27 | result += ","; 28 | } 29 | result += subtypes[index]; 30 | } 31 | result += ">"; 32 | return result; 33 | } 34 | } // namespace utilities 35 | } // namespace accera 36 | -------------------------------------------------------------------------------- /accera/ir/src/nest/OperandIndex.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Mason Remy 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "nest/OperandIndex.h" 8 | 9 | namespace accera::ir 10 | { 11 | namespace loopnest 12 | { 13 | OperandIndex::OperandIndex(int64_t index) : 14 | _idx(index) 15 | { 16 | } 17 | 18 | int64_t OperandIndex::GetIndex() const 19 | { 20 | return _idx; 21 | } 22 | 23 | std::ostream& operator<<(std::ostream& os, const OperandIndex& index) 24 | { 25 | os << index.GetIndex(); 26 | return os; 27 | } 28 | 29 | } // namespace loopnest 30 | } // namespace accera::ir 31 | 32 | using namespace accera::ir::loopnest; 33 | 34 | std::hash::result_type std::hash::operator()(const argument_type& element) const 35 | { 36 | return static_cast(std::hash()(element.GetIndex())); 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /accera/transforms/include/affine/CheckBoundsPass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | namespace mlir 12 | { 13 | class Pass; 14 | class RewritePatternSet; 15 | } // namespace mlir 16 | 17 | namespace accera::transforms::affine 18 | { 19 | 20 | // Unit attr name for controlling whether bounds checking has already been performed on an op 21 | const std::string BoundsCheckedAttrName = "accaffine.bounds_checked"; 22 | 23 | // Unit attr name for controlling whether bounds checking is done for ops within a marked op 24 | const std::string AccessBoundsCheckAttrName = "accaffine.access_bounds_check"; 25 | 26 | void populateBoundsCheckingPatterns(mlir::RewritePatternSet& patterns); 27 | 28 | // TODO : implement 29 | // std::unique_ptr createBoundsCheckingPass(); 30 | 31 | } // namespace accera::transforms::affine 32 | -------------------------------------------------------------------------------- /CMake/GetGitVersion.cmake: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | # 5 | # Inspects the latest git tag and sets a variable with the simplified version (vN.N.N) 6 | # cf. llvm/third-party/benchmark/cmake/GetGitVersion.cmake 7 | #################################################################################################### 8 | 9 | include_guard() 10 | 11 | find_package(Git QUIET) 12 | 13 | function(get_git_version var) 14 | if(GIT_EXECUTABLE) 15 | execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 16 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 17 | RESULT_VARIABLE status 18 | OUTPUT_VARIABLE GIT_DESCRIBE_VERSION 19 | ERROR_QUIET) 20 | if(status) 21 | set(GIT_DESCRIBE_VERSION "v0.0.0") 22 | endif() 23 | 24 | string(STRIP ${GIT_DESCRIBE_VERSION} GIT_VERSION) 25 | else() 26 | set(GIT_VERSION "0.0.0") 27 | endif() 28 | 29 | set(${var} ${GIT_VERSION} PARENT_SCOPE) 30 | endfunction() 31 | -------------------------------------------------------------------------------- /accera/ir/include/value/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(LLVM_TARGET_DEFINITIONS ValueOps.td) 7 | mlir_tablegen(ValueOps.h.inc -gen-op-decls) 8 | mlir_tablegen(ValueOps.cpp.inc -gen-op-defs) 9 | mlir_tablegen(ValueOpsEnums.h.inc -gen-enum-decls) 10 | mlir_tablegen(ValueOpsEnums.cpp.inc -gen-enum-defs) 11 | mlir_tablegen(ValueDialect.h.inc -gen-dialect-decls -dialect=accv) 12 | mlir_tablegen(ValueDialect.cpp.inc -gen-dialect-defs -dialect=accv) 13 | add_public_tablegen_target(ValueOpsIncGen) 14 | 15 | set(LLVM_TARGET_DEFINITIONS ValueAttrs.td) 16 | mlir_tablegen(ValueAttrs.h.inc -gen-struct-attr-decls) 17 | mlir_tablegen(ValueAttrs.cpp.inc -gen-struct-attr-defs) 18 | add_public_tablegen_target(ValueAttrsIncGen) 19 | 20 | add_accera_ir_doc(ValueOps -gen-dialect-doc ValueDialect references/markdown/) 21 | add_accera_ir_doc(ValueAttrs -gen-attr-interface-docs ValueAttributes references/markdown/) 22 | -------------------------------------------------------------------------------- /accera/value/include/MLOperations.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include "Array.h" 10 | #include "Scalar.h" 11 | 12 | namespace accera 13 | { 14 | namespace value 15 | { 16 | void SoftmaxifyRows(Array m); 17 | void SoftmaxifyRowsVectorized(Array m); 18 | 19 | void LayerNormalize(Array m, Array alpha, Array beta); 20 | void LayerNormalizeFused(Array m, Array alpha, Array beta, Array residual); 21 | void LayerNormalizeVectorized(Array m, Array alpha, Array beta); 22 | void LayerNormalizeVectorizedFused(Array m, Array alpha, Array beta, Array residual); 23 | 24 | void ReLU(Array m); 25 | 26 | void Feedforward(Array attn, Array Wff1, Array Wff2, Array ffTemp, Array output); 27 | void FusedFeedforward(Array attn, Array Wff1, Array Wff2, Array ffTemp, Array output); 28 | } // namespace value 29 | } // namespace accera 30 | -------------------------------------------------------------------------------- /accera/acc-translate/src/Target/Cpp/LLVMDialectCppPrinter.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #ifndef LLVM_DIALECT_CPP_PRINTER_H_ 8 | #define LLVM_DIALECT_CPP_PRINTER_H_ 9 | 10 | #include "CppPrinter.h" 11 | 12 | #include 13 | 14 | namespace mlir 15 | { 16 | namespace cpp_printer 17 | { 18 | 19 | struct LLVMDialectCppPrinter : public DialectCppPrinter 20 | { 21 | LLVMDialectCppPrinter(CppPrinter* printer_) : 22 | DialectCppPrinter(printer_) {} 23 | 24 | std::string getName() override { return "LLVM"; } 25 | 26 | /// print Operation from GPU Dialect 27 | LogicalResult printDialectOperation(Operation* op, bool* skipped, bool* consumed) override; 28 | LogicalResult printFenceOp(LLVM::FenceOp op); 29 | }; 30 | 31 | } // namespace cpp_printer 32 | } // namespace mlir 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /CMake/VulkanSetup.cmake: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | # 5 | # Centralized place to try to find the Vulkan SDK, installed from https://vulkan.lunarg.com/ 6 | #################################################################################################### 7 | 8 | # At first try "FindVulkan" from: 9 | # https://cmake.org/cmake/help/v3.7/module/FindVulkan.html 10 | if (NOT CMAKE_VERSION VERSION_LESS 3.7.0) 11 | find_package(Vulkan) 12 | endif() 13 | 14 | # If Vulkan is not found try a path specified by VULKAN_SDK. 15 | if (NOT Vulkan_FOUND) 16 | if ("$ENV{VULKAN_SDK}" STREQUAL "") 17 | message(WARNING "Vulkan SDK was not found with CMake intrinsics and environment variable VULKAN_SDK is not set") 18 | else() 19 | find_library(Vulkan_LIBRARY vulkan HINTS "$ENV{VULKAN_SDK}/lib" REQUIRED) 20 | if (Vulkan_LIBRARY) 21 | set(Vulkan_FOUND ON) 22 | set(Vulkan_INCLUDE_DIR "$ENV{VULKAN_SDK}/include") 23 | message(STATUS "Found Vulkan: " ${Vulkan_LIBRARY}) 24 | endif() 25 | endif() 26 | endif() 27 | -------------------------------------------------------------------------------- /docs/Reference/classes/Schedule/reorder.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Schedule.reorder(order, *args)` 7 | The `reorder` transformation sets the order of the indices in the schedule. 8 | 9 | These orders are not allowed: 10 | 1. The *outer dimension* created by a `split` transformation must always precede the corresponding *inner dimension*. 11 | 2. The *fusing dimension* created by a `fuse` operation must always precede any *unfused dimensions*. 12 | 13 | ## Arguments 14 | 15 | argument | description | type/default 16 | --- | --- | --- 17 | `order` | Either the order of indices to set or the outermost index if using variable arguments | tuple of `Index` or `Index`. 18 | `*args` | Optional variable arguments containing subsequent indices to set | variable `Index` arguments 19 | 20 | ## Examples 21 | 22 | Reorder a schedule by moving the `k` dimension to the outermost loop: 23 | 24 | ```python 25 | schedule.reorder(k, i, j) 26 | ``` 27 | 28 | Using a tuple to reorder a schedule. This overloaded form is better suited for parameters: 29 | 30 | ```python 31 | schedule.reorder(order=(k, i, j)) 32 | ``` 33 | 34 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/Reference/classes/Package/add_description.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | # Accera v1.2 Reference 5 | 6 | ## `accera.Package.add_description([author, license, other, version])` 7 | Adds descriptive metadata to the HAT package. 8 | ## Arguments 9 | 10 | argument | description | type/default 11 | --- | --- | --- 12 | `author` | Name of the individual or group that authored the package. | string 13 | `license` | The internet URL of the license used to release the package. | string 14 | `other` | User-specific descriptive metadata | dictionary 15 | `version` | The package version. | string 16 | 17 | ## Examples 18 | 19 | Adds the standard version, license, and author description fields to the package: 20 | ```python 21 | package.add_description(version​​​​​​​​​​​​​​​​="1.0", license="https://mit-license.org/", author="Microsoft Research")​​​​​​​​​​ 22 | ``` 23 | 24 | Adds arbitrary user-defined metadata to describe the package: 25 | ```python 26 | package.add_description(other={​​​​​​​​​​​​​​​​"title": "My Package Title", "source": "https://github.com/", "citations": ["https://arxiv.org/2021.12345/", "https://arxiv.org/2021.56789/"]}​​​​​​​​​​​​​​​​) 27 | ``` 28 | 29 | 30 |
31 | -------------------------------------------------------------------------------- /accera/ir/include/exec/VectorizationInfo.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace accera::ir 11 | { 12 | namespace executionPlan 13 | { 14 | struct VectorizationInfo 15 | { 16 | int64_t vectorBytes = 0; 17 | int64_t vectorUnitCount = 0; 18 | bool unrollOnly = false; 19 | 20 | private: 21 | friend inline bool operator==(const VectorizationInfo& v1, const VectorizationInfo& v2) 22 | { 23 | return (v1.vectorBytes == v2.vectorBytes) && (v1.vectorUnitCount == v2.vectorUnitCount) && (v1.unrollOnly == v2.unrollOnly); 24 | } 25 | friend inline bool operator!=(const VectorizationInfo& v1, const VectorizationInfo& v2) 26 | { 27 | return !(v1 == v2); 28 | } 29 | }; 30 | 31 | const int64_t AVX2Alignment = 32; 32 | } // namespace executionPlan 33 | } // namespace accera::ir 34 | -------------------------------------------------------------------------------- /accera/value/src/Profiling.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "Profiling.h" 8 | #include "EmitterContext.h" 9 | 10 | namespace accera 11 | { 12 | namespace value 13 | { 14 | void EnterProfileRegion(const std::string& regionName) 15 | { 16 | GetContext().EnterProfileRegion(regionName); 17 | } 18 | 19 | void ExitProfileRegion(const std::string& regionName) 20 | { 21 | GetContext().ExitProfileRegion(regionName); 22 | } 23 | 24 | void PrintProfileResults() 25 | { 26 | GetContext().PrintProfileResults(); 27 | } 28 | 29 | ProfileRegion::ProfileRegion(const std::string& regionName) : 30 | _regionName(regionName) 31 | { 32 | EnterProfileRegion(_regionName); 33 | } 34 | 35 | ProfileRegion::~ProfileRegion() 36 | { 37 | ExitProfileRegion(_regionName); 38 | } 39 | } // namespace value 40 | } // namespace accera 41 | -------------------------------------------------------------------------------- /.azure/cuda/scripts/install.azp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # 6 | # Note that the line endings in this file should be LF instead of CRLF in order to run correctly. 7 | #################################################################################################### 8 | set -x -e 9 | 10 | # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops 11 | # To make it easier for build and release pipelines to run apt-get, 12 | # configure apt to not require confirmation (assume the -y argument by default) 13 | export DEBIAN_FRONTEND=noninteractive 14 | echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes 15 | 16 | apt-get update && apt-get install --no-install-recommends \ 17 | ca-certificates \ 18 | curl \ 19 | jq \ 20 | git \ 21 | iputils-ping \ 22 | libcurl4 \ 23 | libicu66 \ 24 | libunwind8 \ 25 | netcat \ 26 | libssl1.0 \ 27 | && rm -rf /var/lib/apt/lists/* 28 | 29 | curl -LsS https://aka.ms/InstallAzureCLIDeb | bash \ 30 | && rm -rf /var/lib/apt/lists/* -------------------------------------------------------------------------------- /.azure/rocm/scripts/install.azp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # 6 | # Note that the line endings in this file should be LF instead of CRLF in order to run correctly. 7 | #################################################################################################### 8 | set -x -e 9 | 10 | # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops 11 | # To make it easier for build and release pipelines to run apt-get, 12 | # configure apt to not require confirmation (assume the -y argument by default) 13 | export DEBIAN_FRONTEND=noninteractive 14 | echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes 15 | 16 | apt-get update && apt-get install --no-install-recommends \ 17 | ca-certificates \ 18 | curl \ 19 | jq \ 20 | git \ 21 | iputils-ping \ 22 | libcurl4 \ 23 | libicu66 \ 24 | libunwind8 \ 25 | netcat \ 26 | libssl1.0 \ 27 | && rm -rf /var/lib/apt/lists/* 28 | 29 | curl -LsS https://aka.ms/InstallAzureCLIDeb | bash \ 30 | && rm -rf /var/lib/apt/lists/* -------------------------------------------------------------------------------- /accera/ir/include/argo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | include_directories(${ACCERA_LIBRARIES_DIR}) 7 | 8 | set(LLVM_TARGET_DEFINITIONS ArgoOps.td) 9 | mlir_tablegen(ArgoOps.h.inc -gen-op-decls) 10 | mlir_tablegen(ArgoOps.cpp.inc -gen-op-defs) 11 | mlir_tablegen(ArgoDialect.h.inc -gen-dialect-decls -dialect=argo) 12 | mlir_tablegen(ArgoDialect.cpp.inc -gen-dialect-defs -dialect=argo) 13 | add_public_tablegen_target(ArgoOpsIncGen) 14 | 15 | set(LLVM_TARGET_DEFINITIONS ArgoStructuredOps.td) 16 | mlir_tablegen(ArgoStructuredOps.h.inc -gen-op-decls) 17 | mlir_tablegen(ArgoStructuredOps.cpp.inc -gen-op-defs) 18 | add_public_tablegen_target(ArgoStructuredOpsIncGen) 19 | 20 | set(LLVM_TARGET_DEFINITIONS ArgoStructuredOpsInterface.td) 21 | mlir_tablegen(ArgoStructuredOpsInterfaces.h.inc -gen-op-interface-decls) 22 | mlir_tablegen(ArgoStructuredOpsInterfaces.cpp.inc -gen-op-interface-defs) 23 | add_public_tablegen_target(ArgoStructuredOpsInterfaceIncGen) 24 | -------------------------------------------------------------------------------- /docs/Install/Installing_Accera_on_MacOS.md: -------------------------------------------------------------------------------- 1 | [//]: # (Project: Accera) 2 | [//]: # (Version: v1.2) 3 | 4 | ## Installing on MacOS 5 | 6 | ### Install dependencies 7 | 8 | Accera requires the following tools and libraries for building the generated code: 9 | 10 | * A C++ compiler, such as `clang`, which is bundled in XCode 11 | * Python 3.7 or newer 12 | * OpenMP 5, if using parallelization 13 | 14 | Homebrew is a package manager that makes it easy to install the prerequisites. Homebrew can be downloaded and installed by: 15 | 16 | ```shell 17 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 18 | ``` 19 | 20 | If you already have Homebrew installed, update it to the latest version by typing: 21 | 22 | ```shell 23 | brew update 24 | ``` 25 | 26 | Install the dependencies: 27 | 28 | ```shell 29 | brew install cmake python@3.7 30 | ``` 31 | 32 | Install the optional dependency if using parallelization: 33 | 34 | ```shell 35 | brew install libomp 36 | ``` 37 | 38 | #### Clang 39 | 40 | Select the `clang` compiler from XCode: 41 | 42 | ```shell 43 | xcode-select --install 44 | ``` 45 | 46 | ### Install Accera 47 | 48 | The `accera` Python package can be installed from PyPI: 49 | 50 | ```shell 51 | pip install accera 52 | ``` 53 | 54 | 55 | -------------------------------------------------------------------------------- /accera/ir/test/nest_dialect_test/LoopNestTestVerification.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace mlir 11 | { 12 | class FuncOp; 13 | class OpBuilder; 14 | 15 | template 16 | class OwningOpRef; 17 | class ModuleOp; 18 | } 19 | 20 | // 21 | // Test function verifiers 22 | // 23 | bool VerifyGenerate(mlir::OwningOpRef& module, mlir::FuncOp& fn); 24 | bool VerifyParse(mlir::OwningOpRef& module, mlir::FuncOp& fn); 25 | bool VerifyLowerToValue(mlir::OwningOpRef& module, mlir::FuncOp& fn); 26 | bool VerifyLowerToStd(mlir::OwningOpRef& module, mlir::FuncOp& fn); 27 | bool VerifyLowerToLLVM(mlir::OwningOpRef& module, mlir::FuncOp& fnOp); 28 | bool VerifyTranslateToLLVMIR(mlir::OwningOpRef& module, mlir::FuncOp& fnOp); 29 | bool VerifyJIT(mlir::OwningOpRef& module, mlir::FuncOp& fnOp); 30 | -------------------------------------------------------------------------------- /accera/ir/include/nest/LoopNestExportedInterfaces.td: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #ifndef LOOPNEST_EXPORTED_INTERFACES 7 | #define LOOPNEST_EXPORTED_INTERFACES 8 | 9 | include "mlir/IR/OpBase.td" 10 | 11 | // 12 | // Mapping operation interface 13 | // 14 | def accln_InjectableMappingOpInterface : OpInterface<"InjectableMapping"> { 15 | let description = [{ 16 | Interface for mapping ops to be injected into a loopnest schedule 17 | }]; 18 | 19 | let methods = [ 20 | InterfaceMethod<[{ 21 | Returns the index to inject at 22 | }], 23 | "Index", "index", (ins) 24 | >, 25 | InterfaceMethod<[{ 26 | Returns the position to inject at 27 | }], 28 | "Position", "position", (ins) 29 | >, 30 | InterfaceMethod<[{ 31 | Returns the end region operation 32 | }], 33 | "Operation*", "getInjectionEndOp", (ins) 34 | >, 35 | ]; 36 | } 37 | 38 | #endif // LOOPNEST_EXPORTED_INTERFACES 39 | -------------------------------------------------------------------------------- /.azure/manylinux/scripts/install.vulkanloader.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See LICENSE in the project root for license information. 5 | # 6 | # Note that the line endings in this file should be LF instead of CRLF in order to run correctly. 7 | #################################################################################################### 8 | set -x -e 9 | 10 | SRC_PATH=`pwd` 11 | 12 | SDK_VERSION=`curl -L https://vulkan.lunarg.com/sdk/latest/linux.txt` 13 | INSTALL_PATH=/opt/vulkansdk 14 | mkdir ${INSTALL_PATH} 15 | 16 | git clone https://github.com/KhronosGroup/Vulkan-Loader.git 17 | cd Vulkan-Loader 18 | git checkout tags/sdk-${SDK_VERSION} 19 | 20 | mkdir build 21 | cd build 22 | python3 ../scripts/update_deps.py 23 | cmake -C helper.cmake -DCMAKE_BUILD_TYPE=Release \ 24 | -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} \ 25 | -DBUILD_WSI_WAYLAND_SUPPORT=OFF \ 26 | -DBUILD_TESTS=OFF \ 27 | -DBUILD_WSI_XLIB_SUPPORT=OFF .. 28 | cmake --build . --config Release --target install 29 | 30 | cp -rf ${SRC_PATH}/Vulkan-Loader/build/Vulkan-Headers/build/install/include ${INSTALL_PATH} 31 | export VULKAN_SDK=${INSTALL_PATH} -------------------------------------------------------------------------------- /accera/python/accera/__init__.py: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | try: 7 | from ._version import __version__ 8 | except: 9 | # CMake-driven builds do not generate _version.py yet 10 | __version__ = None 11 | 12 | from .Targets import Target, KNOWN_DEVICES, KNOWN_CPUS, KNOWN_GPUS 13 | from .Parameter import DelayedParameter, create_parameters, create_parameter_grid 14 | from .Constants import * 15 | from .Package import Package 16 | 17 | from .lang import * 18 | from ._lang_python import CompilerOptions, ScalarType, _GetTargetDeviceFromName, AllocateFlags, Role 19 | from ._lang_python import ( 20 | abs, max, min, ceil, floor, sqrt, exp, fast_exp, fast_exp_mlas, log, log10, log2, sin, cos, tan, sinh, cosh, tanh, logical_and, logical_or, 21 | logical_not, cast, round, remainderf, type_size_bytes 22 | ) 23 | from ._lang_python._lang import MMAShape, MMASchedulingPolicy, MMAFragmentOp, CacheStrategy 24 | 25 | # Global initialization 26 | Package._init_default_module() 27 | -------------------------------------------------------------------------------- /external/llvm/README.md: -------------------------------------------------------------------------------- 1 | # Accera LLVM vcpkg Port 2 | 3 | This vcpkg LLVM port is based on the [official LLVM port](https://github.com/microsoft/vcpkg/blob/master/ports/llvm), but only builds the projects and targets needed for Accera. 4 | 5 | ## Build instructions 6 | 7 | 1. Ensure that you have at least 20GB of disk space 8 | 9 | 2. Bootstrap vcpkg: 10 | 11 | Windows 12 | 13 | ```shell 14 | cd \external\vcpkg 15 | call bootstrap-vcpkg.bat 16 | ``` 17 | 18 | Linux / macOS: 19 | 20 | ```shell 21 | cd /external/vcpkg 22 | ./bootstrap-vcpkg.sh 23 | ``` 24 | 25 | 3. Build and install LLVM: 26 | 27 | Windows 28 | 29 | ```shell 30 | cd 31 | externa\vcpkg\vcpkg.exe install accera-llvm:x64-windows --overlay-ports=external\llvm 32 | ``` 33 | 34 | Linux / macOS: 35 | 36 | ```shell 37 | cd 38 | external/vcpkg/vcpkg install accera-llvm --overlay-ports=external/llvm 39 | ``` 40 | 41 | ## Troubleshooting 42 | 43 | To force a rebuild of a package: `external/vcpkg/vcpkg remove accera-llvm` 44 | 45 | 46 | To reset vcpkg if there are issues with caching stale versions of packages: 47 | 48 | 1. Delete the vcpkg folder 49 | 2. `git submodule deinit -f .` 50 | 3. `git submodule update --init` -------------------------------------------------------------------------------- /accera/transforms/include/gpu/AcceraVulkanPasses.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Abdul Dakkak, Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace mlir 12 | { 13 | class ModuleOp; 14 | template 15 | class OperationPass; 16 | } // namespace mlir 17 | 18 | namespace accera::transforms::vulkan 19 | { 20 | struct VulkanTimingOptions 21 | { 22 | bool printTimings = false; 23 | int64_t warmupCount = 0; 24 | int64_t runCount = 1; 25 | 26 | static const VulkanTimingOptions& getDefaultOptions() 27 | { 28 | static VulkanTimingOptions options; 29 | return options; 30 | } 31 | }; 32 | 33 | std::unique_ptr> createConvertVulkanLaunchFuncToVulkanCallsWithTimingPass(const VulkanTimingOptions& options = VulkanTimingOptions::getDefaultOptions()); 34 | std::unique_ptr> createEmitVulkanWrapperPass(); 35 | } // namespace accera::transforms::vulkan 36 | -------------------------------------------------------------------------------- /accera/transforms/include/vectorization/VectorizationPass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace mlir 11 | { 12 | class Pass; 13 | class RewritePatternSet; 14 | } // namespace mlir 15 | 16 | namespace accera::transforms::vectorization 17 | { 18 | struct VectorizationPassOptions 19 | { 20 | bool printVecOpDetails = false; 21 | }; 22 | 23 | void populateVectorizePatterns(bool printVectorizationDetails, mlir::RewritePatternSet& patterns); 24 | void populateVectorizeUnrollPatterns(bool printVectorizationDetails, mlir::RewritePatternSet& patterns); 25 | 26 | std::unique_ptr createVectorizationPass(const VectorizationPassOptions& options); 27 | std::unique_ptr createVectorizationPass(); 28 | std::unique_ptr createVectorizationUnrollPass(const VectorizationPassOptions& options); 29 | std::unique_ptr createVectorizationUnrollPass(); 30 | 31 | } // namespace accera::transforms::vectorization 32 | -------------------------------------------------------------------------------- /accera/transforms/include/value/ValueFuncToTargetPass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Kern Handa 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | // fwd decls 12 | namespace mlir 13 | { 14 | class MLIRContext; 15 | class ModuleOp; 16 | class Pass; 17 | template class OperationPass; 18 | 19 | class RewritePatternSet; 20 | } // namespace mlir 21 | 22 | namespace accera::transforms::value 23 | { 24 | 25 | void populateValueLambdaToFuncPatterns(mlir::MLIRContext* context, mlir::RewritePatternSet& patterns); 26 | void populateValueFuncToTargetPatterns(mlir::MLIRContext* context, mlir::RewritePatternSet& patterns); 27 | void populateValueLaunchFuncInlinerPatterns(mlir::MLIRContext*, mlir::RewritePatternSet&); 28 | 29 | std::unique_ptr> createValueFuncToTargetPass(const IntraPassSnapshotOptions& snapshotOptions); 30 | std::unique_ptr> createValueFuncToTargetPass(); 31 | } // namespace accera::transforms::value 32 | -------------------------------------------------------------------------------- /accera/python/gpu/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = accera-gpu 3 | author = Microsoft Research AI Compilers Team 4 | author_email = mlodev@microsoft.com 5 | summary = Accera GPU Support 6 | license = MIT License 7 | long_description = file: README.md 8 | long_description_content_type = text/markdown 9 | license_files = ../../../LICENSE 10 | platforms = Linux, Darwin, Windows 11 | classifiers = 12 | License :: OSI Approved :: MIT License 13 | Intended Audience :: Developers 14 | Intended Audience :: Science/Research 15 | Topic :: Scientific/Engineering 16 | Topic :: Scientific/Engineering :: Mathematics 17 | Topic :: Scientific/Engineering :: Artificial Intelligence 18 | Topic :: Software Development 19 | Topic :: Software Development :: Libraries 20 | Topic :: Software Development :: Libraries :: Python Modules 21 | Programming Language :: C++ 22 | Programming Language :: Python :: 3 23 | Programming Language :: Python :: 3.7 24 | Programming Language :: Python :: 3.8 25 | Programming Language :: Python :: 3.9 26 | Programming Language :: Python :: 3.10 27 | 28 | [options] 29 | python_requires = ~=3.7 30 | zip_safe = False 31 | setup_requires = 32 | setuptools>=31 33 | setuptools_scm 34 | package_dir = 35 | accera.gpu = accera\gpu 36 | 37 | [options.package_data] 38 | bin = bin/acc-translate 39 | -------------------------------------------------------------------------------- /accera/transforms/src/value/ValueConversion.td: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #ifndef ACCERA_VALUE_CONVERSION 7 | #define ACCERA_VALUE_CONVERSION 8 | 9 | include "ir/include/value/ValueOps.td" 10 | include "mlir/Dialect/StandardOps/IR/Ops.td" 11 | include "mlir/Dialect/MemRef/IR/MemRefOps.td" 12 | 13 | // These patterns are here to work around a bug with linalg.view operations that correspond to a single array element. 14 | // The issue is that a store operation (either accv.StoreOp or (standard) StoreOp) with a (single-element) accv.OffsetOp 15 | // eventually gets lowered to a store into a linalg.view, which fails when storing a single scalar value. 16 | def : Pat<(accv_GetElementOp (accv_OffsetOp $source, $args)), (LoadOp $source, $args)>; 17 | def : Pat<(accv_StoreOp $val, (accv_OffsetOp $source, $args), $indices), (MemRef_StoreOp $val, $source, $args)>; 18 | def : Pat<(MemRef_StoreOp $val, (accv_OffsetOp $source, $args), $indices), (MemRef_StoreOp $val, $source, $args)>; 19 | 20 | #endif // ACCERA_VALUE_CONVERSION 21 | -------------------------------------------------------------------------------- /accera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | #################################################################################################### 5 | 6 | set(ACCERA_LIBRARIES_DIR ${CMAKE_CURRENT_LIST_DIR}) 7 | set(ACCERA_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) 8 | include_directories(${ACCERA_LIBRARIES_DIR}) 9 | 10 | add_subdirectory(acc-opt) 11 | add_subdirectory(acc-gpu-runner) 12 | add_subdirectory(acc-lsp-server) 13 | add_subdirectory(acc-translate) 14 | add_subdirectory(accc) 15 | add_subdirectory(ir) 16 | add_subdirectory(mlirHelpers) 17 | add_subdirectory(onnx-emitter) 18 | add_subdirectory(runtime) 19 | add_subdirectory(testing) 20 | add_subdirectory(toml) 21 | add_subdirectory(transforms) 22 | add_subdirectory(utilities) 23 | add_subdirectory(value) 24 | add_subdirectory(vulkanRuntime) 25 | add_subdirectory(export) 26 | 27 | add_custom_target(accera) 28 | add_dependencies( 29 | accera 30 | ir 31 | mlirHelpers 32 | runtime 33 | transforms 34 | utilities 35 | value 36 | ) 37 | 38 | add_custom_target(tests) 39 | add_dependencies( 40 | tests 41 | nest_dialect_test 42 | testing 43 | utilities_test 44 | ) 45 | -------------------------------------------------------------------------------- /accera/ir/test/nest_dialect_test/IRTestVerification.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace mlir 11 | { 12 | class FuncOp; 13 | class OpBuilder; 14 | 15 | template 16 | class OwningOpRef; 17 | class ModuleOp; 18 | } 19 | 20 | void SetTestBuilder(mlir::OpBuilder* builder); 21 | mlir::OpBuilder& GetTestBuilder(); 22 | 23 | // 24 | // Test function verifiers 25 | // 26 | bool VerifyGenerate(mlir::OwningOpRef& module, mlir::FuncOp& fn, std::string outputFile=""); 27 | bool VerifyParse(mlir::OwningOpRef& module, mlir::FuncOp& fn, std::string outputFile=""); 28 | bool VerifyLowerToStd(mlir::OwningOpRef& module, mlir::FuncOp& fn, std::string outputFile=""); 29 | bool VerifyLowerToLLVM(mlir::OwningOpRef& module, mlir::FuncOp& fnOp, std::string outputFile=""); 30 | bool VerifyTranslateToLLVMIR(mlir::OwningOpRef& module, mlir::FuncOp& fnOp, bool optimize, std::string outputFile=""); 31 | 32 | -------------------------------------------------------------------------------- /accera/utilities/test/src/TypeName_test.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. See LICENSE in the project root for license information. 4 | // Authors: Chuck Jacobs 5 | //////////////////////////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace accera 15 | { 16 | 17 | enum SimpleEnum 18 | { 19 | A, 20 | B, 21 | C 22 | }; 23 | 24 | enum class ClassEnum 25 | { 26 | a, 27 | b, 28 | c 29 | }; 30 | 31 | TEST_CASE("TypeNames") 32 | { 33 | #define TEST_TYPE_NAMES(TYPE) \ 34 | CHECK(utilities::TypeName::GetName() == #TYPE) 35 | 36 | TEST_TYPE_NAMES(bool); 37 | TEST_TYPE_NAMES(char); 38 | TEST_TYPE_NAMES(int); 39 | TEST_TYPE_NAMES(float); 40 | TEST_TYPE_NAMES(double); 41 | 42 | using utilities::UniqueId; 43 | TEST_TYPE_NAMES(UniqueId); 44 | 45 | CHECK(utilities::TypeName::GetName() == "enum"); 46 | CHECK(utilities::TypeName::GetName() == "enum"); 47 | 48 | #undef TEST_TYPE_NAMES 49 | } 50 | 51 | } // namespace accera 52 | -------------------------------------------------------------------------------- /accera/python/compilers/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = accera-compilers 3 | author = Microsoft Research AI Compilers Team 4 | author_email = mlodev@microsoft.com 5 | summary = Accera Compilers 6 | license = MIT License 7 | long_description = file: README.md 8 | long_description_content_type = text/markdown 9 | license_files = ../../../LICENSE 10 | platforms = Linux, Darwin, Windows 11 | classifiers = 12 | License :: OSI Approved :: MIT License 13 | Intended Audience :: Developers 14 | Intended Audience :: Science/Research 15 | Topic :: Scientific/Engineering 16 | Topic :: Scientific/Engineering :: Mathematics 17 | Topic :: Scientific/Engineering :: Artificial Intelligence 18 | Topic :: Software Development 19 | Topic :: Software Development :: Libraries 20 | Topic :: Software Development :: Libraries :: Python Modules 21 | Programming Language :: C++ 22 | Programming Language :: Python :: 3 23 | Programming Language :: Python :: 3.7 24 | Programming Language :: Python :: 3.8 25 | Programming Language :: Python :: 3.9 26 | Programming Language :: Python :: 3.10 27 | 28 | [options] 29 | python_requires = ~=3.7 30 | zip_safe = False 31 | setup_requires = 32 | setuptools>=31 33 | setuptools_scm 34 | package_dir = 35 | accera.compilers = accera\compilers 36 | 37 | [options.package_data] 38 | bin = bin/*.in, bin/acc-opt 39 | -------------------------------------------------------------------------------- /.azure/cuda/Dockerfile: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. See LICENSE in the project root for license information. 4 | # Usage: call docker build from the root of this repository 5 | # docker build -f .azure/cuda/Dockerfile . -t registry_name/cuda-linuxagent:latest 6 | #################################################################################################### 7 | 8 | ARG CUDAVER=11.8.0-devel-ubuntu20.04 9 | 10 | # cf: nvidia/cuda:${CUDAVER} 11 | FROM acceracontainers.azurecr.io/nvidia/cuda:${CUDAVER} 12 | 13 | ARG CUDAVER 14 | RUN echo "CUDA Version: " ${CUDAVER} 15 | 16 | ADD .azure/cuda/scripts /tmp/scripts 17 | ADD requirements.txt /tmp/scripts/requirements.txt 18 | 19 | WORKDIR /tmp/scripts 20 | RUN sh /tmp/scripts/install.azp.sh 21 | RUN sh /tmp/scripts/install.builddeps.sh 22 | RUN sh /tmp/scripts/install.dbgdeps.sh 23 | RUN rm -rf /tmp/scripts 24 | 25 | ENV CC=gcc-10 \ 26 | CXX=g++-10 \ 27 | CMAKE_C_COMPILER=gcc-10 \ 28 | CMAKE_CXX_COMPILER=g++-10 29 | 30 | # Start the build agent 31 | # Can be 'linux-x64', 'linux-arm64', 'linux-arm', 'rhel.6-x64'. 32 | ENV TARGETARCH=linux-x64 33 | WORKDIR /azp 34 | COPY .azure/cuda/scripts/start.sh . 35 | RUN chmod +x start.sh 36 | 37 | ENTRYPOINT ["./start.sh"] --------------------------------------------------------------------------------