%global pkg_version %{name}-v%{version} %global build_dir %{_builddir}/%{pkg_version} %global install_libdir %{buildroot}%{_libdir} %global install_includedir %{buildroot}%{_includedir}/annc %global max_jobs 16 %global debug_package %{nil} Summary: %{name} is an AI compiler designed to optimize and compile ML model into high-performance executable code that can be executed on various targets. Name: ANNC Version: 0.0.2 Release: 1 # Package onnxruntime and SafeInt have MIT License. # Package onnx has Apache License 2.0. License: MIT and ASL 2.0 and Boost and BSD URL: https://gitee.com/openeuler/ANNC Source0: %{pkg_version}.tar.gz Source1: external.tar.gz.aa Source2: external.tar.gz.ab Source3: XNNPACK.tar.gz %ifarch x86_64 Patch0: x86_64_external_files.patch %endif BuildRequires: cmake >= 3.9.9 BuildRequires: make BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: bzip2 BuildRequires: python3-devel BuildRequires: python3-numpy BuildRequires: python3-setuptools BuildRequires: python3-pip BuildRequires: python3-wheel BuildRequires: libstdc++-static BuildRequires: git BuildRequires: java-11-openjdk BuildRequires: java-11-openjdk-devel BuildRequires: bazel %description %{name} is is an AI compiler designed to optimize and compile ML model into high-performance executable code that can be executed on various targets. %prep cat %{SOURCE1} %{SOURCE2} > external.tar.gz tar xf external.tar.gz -C . tar xf %{SOURCE3} -C . %ifarch x86_64 %patch 0 -p1 -d . %endif %autosetup -S git -n %{pkg_version} %build export ANNC=%{build_dir} cd %{_builddir}/XNNPACK/build CFLAGS="-fPIC" cmake .. -DXNNPACK_BUILD_BENCHMARKS=OFF \ -DXNNPACK_BUILD_TESTS=OFF \ -DXNNPACK_LIBRARY_TYPE=shared \ -DCMAKE_BUILD_TYPE=Release make -j %{max_jobs} rm -rf $ANNC/annc/service/cpu/xla/libs/libXNNPACK.so cp %{_builddir}/XNNPACK/build/libXNNPACK.so $ANNC/annc/service/cpu/xla/libs export XNNPACK_DIR="%{_builddir}/XNNPACK" CPLUS_INCLUDE_PATH+="$ANNC/annc/service/cpu/xla:" CPLUS_INCLUDE_PATH+="$ANNC/annc/service/:" CPLUS_INCLUDE_PATH+="$XNNPACK_DIR/:" CPLUS_INCLUDE_PATH+="$XNNPACK_DIR/include/:" CPLUS_INCLUDE_PATH+="$XNNPACK_DIR/src/:" CPLUS_INCLUDE_PATH+="$XNNPACK_DIR/build/pthreadpool-source/include/:" export CPLUS_INCLUDE_PATH export LD_LIBRARY_PATH=$XNNPACK_DIR:$LD_LIBRARY_PATH run_bazel_build() { bazel --output_user_root=./output \ build -c opt \ --verbose_failures \ --action_env="baila=548" \ --define tflite_with_xnnpack=false \ --jobs=%{max_jobs} \ annc/service/cpu:libannc.so # --copt="-g" \ # --copt="-DNDBUG" \ # annc/service/cpu:libannc.so } fix_action() { echo "Perfoming fix action..." external_path=$(find . -name "external" | head -n 1) if [ -n "$external_path" ]; then rm -rf $external_path/* cp -r %{_builddir}/external/* $external_path else echo "Not find external directory." fi run_bazel_build } cd %{build_dir} if run_bazel_build; then echo "Build succeeded." else echo "Build failed." fix_action fi pushd %{build_dir}/python %{__python3} setup.py bdist_wheel %install install -d %{install_includedir} install %{build_dir}/annc/service/cpu/kdnn_rewriter.h -t %{install_includedir} install %{build_dir}/install/*.patch -t %{install_includedir} install %{build_dir}/python/tensorflow/kernels/* -t %{install_includedir} install -d %{install_libdir} output_path=$(find %{build_dir} -type f -name "libannc.so") install ${output_path} -t %{install_libdir} install %{build_dir}/annc/service/cpu/xla/libs/libXNNPACK.so -t %{install_libdir} pushd %{build_dir}/python %py3_install %files %{_includedir}/annc/* %{_libdir}/* %{python3_sitelib}/* /usr/bin/annc-opt /usr/bin/annc-apply-tf %changelog * Mon May 12 2025 Chenhui Zheng - 0.0.1-1 - Type:Init - ID:NA - SUG:NA - DEC:Init ANNC repository