├── .gitignore ├── MANIFEST.in ├── test.sh ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── README_CN.md ├── README.md └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | AIPU* 2 | Compass* 3 | dist 4 | temp/ -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | global-include *.so 2 | global-include *.o 3 | global-include *.a 4 | global-include *.json 5 | recursive-include **/AIPUBuilder/_C/ * 6 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright © 2022-2025 Arm China Co. Ltd. All rights reserved. 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | echo "checking software exist..." 6 | echo "simulator" 7 | aipu_simulator_x1 -v 8 | echo "compiler" 9 | aipucc --version 10 | echo "buildtool" 11 | aipubuild --version 12 | 13 | echo "testing out of box example..." 14 | cd Compass_MiniPkg-Release-*-Linux/out-of-box-example/resnet_50 15 | ./run.sh 16 | cd - 17 | 18 | echo "done, all test passed" 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | 40 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # Compass Integration 2 | 3 | 本项目用于构建可发布的软件包,软件内容来自 `Compass_Unified_Parser` 仓库 `Compass_Optimizer` 仓库 和 `Compass_MiniPkg` 。 4 | 5 | ## 准备事项 6 | 7 | 你需要从 [github] 或者 [gitee] clone 以下 repositories 至仓库根目录。 8 | 9 | [github]: https://github.com/Arm-China 10 | [gitee]: https://gitee.com/Arm-China 11 | 12 | ```bash 13 | git clone https://github.com/Arm-China/Compass_Unified_Parser.git 14 | git clone https://github.com/Arm-China/Compass_Optimizer.git 15 | ``` 16 | 17 | 你需要下载 `minpackage` 至仓库根目录,下载步骤请参考文章 。 18 | 19 | > minpackage 是一个文件名为 Compass_MiniPkg-Release-xxxxx-Linux.tar.gz 的 tarball 文件。如果发现下载的文件名格式对不上,例如 1290841044-6422c77963ac7.tar.gz。请自行重命名为帖子中原来的文件名。 20 | 21 | ## 依赖项 22 | 23 | ### 硬件 24 | 25 | Compass Integration 项目只能在 `Linux x86_64` 上构建。 26 | 27 | ### 软件 28 | 29 | * python = 3.10 30 | * pip 31 | * setuptools 32 | * wheel 33 | 34 | 更详细的 Python 依赖请查看 ./setup.py。 35 | 36 | ## 构建 37 | 38 | ```bash 39 | ./build.sh 40 | ``` 41 | 42 | 脚本 build.sh 会在 ./dist 目录构建一个 python wheel 文件。 43 | 44 | ## 安装 45 | 46 | ```bash 47 | pip3 install dist/AIPUBuilder-*-linux_x86_64.whl 48 | # 提示: 如果没有 root 权限,请使用 `pip3 install --user` 或者 `pip3 install --target /YOUR_PATH` 命令 49 | 50 | # 如果使用了 --user 选项,不要忘了: 51 | export PATH="/home/${USER}/.local/bin":$PATH 52 | 53 | # 设置环境变量 54 | MINIPKG_PATH=`realpath ./Compass_MiniPkg-Release-*-Linux` 55 | export PATH=${MINIPKG_PATH}/simulator/bin:${PATH} 56 | export LD_LIBRARY_PATH=${MINIPKG_PATH}/simulator/lib:${LD_LIBRARY_PATH} 57 | export PATH=${MINIPKG_PATH}/tool-chain/compiler/bin:${PATH} 58 | export PATH=${MINIPKG_PATH}/tool-chain/debugger/bin:${PATH} 59 | ``` 60 | 61 | ## 测试 62 | 63 | 安装成功之后, 执行 ./test.sh 脚本可以检查所有模块是否正常工作。这个脚本仅仅测试了 aipucc, aipu_simulator 和 aipubuild 工具的可用性。如果需要使用其他独立模块 (IDE, simulator, toolchain) 的完整功能,请根据对应的文档进行配置。 64 | 例如,aipucc 依赖以下运行环境: 65 | 66 | * libpthread.so.0 67 | * libz.so.1 68 | * libtinfo.so.5 69 | * ... (完整的环境依赖见文档:minipkg/aipu-toolchain) 70 | 71 | ```bash 72 | ./test.sh 73 | ``` 74 | 75 | ## 文档 76 | 77 | 文档放在 Compass_MiniPkg 的 /doc 目录下。 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Compass Integration 2 | 3 | This project builds a distribution package from `Compass_Unified_Parser`, `Compass_Optimizer` and `Compass_MiniPkg`. 4 | 5 | ## Prepare 6 | 7 | 1. You need to clone repositories from [github] or [gitee] under this directory. 8 | 9 | [github]: https://github.com/Arm-China 10 | [gitee]: https://gitee.com/Arm-China 11 | 12 | ```bash 13 | git clone https://github.com/Arm-China/Compass_Unified_Parser.git 14 | git clone https://github.com/Arm-China/Compass_Optimizer.git 15 | ``` 16 | 17 | 2. You need to download `minpackage` from under this directory. For detailed download steps, please refer to the post. 18 | 19 | > The `minpackage` is a tarball file named Compass_MiniPkg-Release-xxxxx-Linux.tar.gz, If the downloaded file name is very different, such as 1290841044-6422c77963ac7.tar.gz, Please rename it to the original file name in the post. 20 | 21 | ## Requirements 22 | 23 | ### Hardware 24 | 25 | The Compass Integration project works on ``Linux x86_64`` only 26 | 27 | ### Software 28 | 29 | * python = 3.10 30 | * pip 31 | * setuptools 32 | * wheel 33 | 34 | > See ./setup.py for details of Python packages 35 | 36 | ## Build 37 | 38 | ```bash 39 | ./build.sh 40 | ``` 41 | 42 | The `build.sh` script will build a **python wheel file** under the ./dist directory 43 | 44 | ## Install 45 | 46 | ```bash 47 | # Delete the old version if needed 48 | pip3 uninstall AIPUBuilder 49 | 50 | # Install 51 | pip3 install dist/AIPUBuilder-*-linux_x86_64.whl 52 | # Tips: using `pip3 install --user` or `pip3 install --target /YOUR_PATH` if your don't have root premission 53 | 54 | # if using --user, don't forget: 55 | export PATH="/home/${USER}/.local/bin":$PATH 56 | 57 | # Set env 58 | MINIPKG_PATH=`realpath ./Compass_MiniPkg-Release-*-Linux` 59 | export PATH=${MINIPKG_PATH}/simulator/bin:${PATH} 60 | export LD_LIBRARY_PATH=${MINIPKG_PATH}/simulator/lib:${LD_LIBRARY_PATH} 61 | export PATH=${MINIPKG_PATH}/tool-chain/compiler/bin:${PATH} 62 | export PATH=${MINIPKG_PATH}/tool-chain/debugger/bin:${PATH} 63 | ``` 64 | 65 | ## Test 66 | 67 | After installation, run the ./test.sh script to check that all modules work. This script briefly tests usability of aipucc, aipu_simulator, aipubuild. If you need to use the full functionality of the individual modules(IDE, simulator, toolchain). Please configure it in the corresponding documentation. 68 | 69 | e.g. 70 | 71 | The following lists libraries that are required for the aipucc: 72 | 73 | * libpthread.so.0 74 | * libz.so.1 75 | * libtinfo.so.5 76 | * ... (see full requirements in document of minipkg/aipu-toolchain) 77 | 78 | ```bash 79 | ./test.sh 80 | ``` 81 | 82 | ## Document 83 | 84 | See the documentation in the /doc directory in Compass_MiniPkg 85 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # Copyright © 2022-2025 Arm China Co. Ltd. All rights reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import AIPUBuilder 5 | import os 6 | import re 7 | 8 | from configparser import ConfigParser 9 | from setuptools import setup, find_packages 10 | from distutils.core import setup 11 | from distutils.extension import Extension 12 | from wheel.bdist_wheel import bdist_wheel as _bdist_wheel 13 | 14 | # Mark us as not a pure python package (we have platform specific C/C++ code) 15 | 16 | 17 | class bdist_wheel(_bdist_wheel): 18 | def finalize_options(self): 19 | _bdist_wheel.finalize_options(self) 20 | self.root_is_pure = False 21 | 22 | 23 | __VERSION__ = AIPUBuilder.__VERSION__ 24 | # env from Jenkins 25 | __job_name__ = os.getenv("JOB_NAME") 26 | __build_number__ = os.getenv("BUILD_NUMBER") 27 | # env from build.sh 28 | __min_pkg_path__ = os.getenv("MINIPKG_PATH") 29 | 30 | assert __min_pkg_path__, "Cannot find mini package path (MINIPKG_PATH) in env" 31 | 32 | # __min_pkg_path__ e.g: 33 | # Compass_MiniPkg-Release-x.x.x-Linux 34 | # Compass_MiniPkg-Debug-x.x.x-Linux 35 | 36 | if __build_number__ is not None and len(__build_number__) != 0: 37 | # for internal release 38 | if "Debug" in __min_pkg_path__: 39 | __build_number__ = "dev" + __build_number__ 40 | 41 | if __VERSION__.count('.') < 2: # 1.0 -> 1.0.xxx123 42 | __VERSION__ = __VERSION__ + "." + str(__build_number__) 43 | 44 | if "opensource" in __job_name__.lower(): 45 | __VERSION__ = __VERSION__ + "+opensource" 46 | 47 | # replace build_number 48 | version_files = [ 49 | "AIPUBuilder/__init__.py", 50 | "AIPUBuilder/Parser/__init__.py", 51 | "AIPUBuilder/Optimizer/version.py" 52 | ] 53 | for version_file in version_files: 54 | version_file = os.path.join(__min_pkg_path__, "AIPUBuilder", 55 | "python", "src", version_file) 56 | with open(version_file) as f: 57 | c = f.read() 58 | c = re.sub("__build_number__\s*=.+", 59 | "__build_number__='"+__build_number__+"'", c) 60 | if len(c) != 0: 61 | with open(version_file, "w") as f: 62 | f.write(c) 63 | 64 | 65 | entry_points = { 66 | 'console_scripts': [] 67 | } 68 | 69 | for entry_points_file in ["entry_points_parser.ini", "entry_points_opt.ini", "entry_points_minipkg.ini"]: 70 | config = ConfigParser() 71 | config.read(__min_pkg_path__ + '/AIPUBuilder/python/src/' + entry_points_file) 72 | for k, v in config['console_scripts'].items(): 73 | entry_points['console_scripts'].append(f"{k} = {v}") 74 | 75 | 76 | setup( 77 | name="AIPUBuilder", 78 | version=__VERSION__, 79 | description="A Graph Builder for AIPU", 80 | author='Neo WANG', 81 | packages=find_packages(__min_pkg_path__ + '/AIPUBuilder/python/src'), 82 | package_dir={'': __min_pkg_path__ + '/AIPUBuilder/python/src'}, 83 | include_package_data=True, # goto MANIFEST.in 84 | install_requires=[ 85 | "clang", 86 | "cloudpickle", 87 | "decorator", 88 | "editdistance", 89 | "future", 90 | "matplotlib", 91 | "networkx", 92 | "onnx>=1.11", 93 | "onnxoptimizer", 94 | "onnxsim", 95 | "pyfma", 96 | "psutil", 97 | "PyYAML", 98 | "scipy", 99 | "sympy", 100 | "synr", 101 | "tensorflow>=2.6", 102 | "torch>=1.11", 103 | "torchvision", 104 | "tornado", 105 | "tqdm" 106 | ], 107 | cmdclass={'bdist_wheel': bdist_wheel}, 108 | entry_points=entry_points, # goto entry_points.ini 109 | classifiers=[ 110 | 'Programming Language :: Python :: 3', 111 | 'Programming Language :: Python :: Implementation :: CPython', 112 | ], 113 | ) 114 | --------------------------------------------------------------------------------