diff options
author | CoprDistGit <infra@openeuler.org> | 2025-08-18 07:55:38 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2025-08-18 07:55:38 +0000 |
commit | b2fd102e20240d3c2e3906bcc658defb155a0661 (patch) | |
tree | 7d2aa575e2a95777b8e23bbbd0a5e0adc7c0c61c | |
parent | 3e527b84d388f7d847d1b22c741e077d79218e38 (diff) |
automatic import of ANNC
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | ANNC.spec | 113 | ||||
-rw-r--r-- | sources | 3 | ||||
-rw-r--r-- | x86_64_external_files.patch | 150 |
4 files changed, 269 insertions, 0 deletions
@@ -0,0 +1,3 @@ +/ANNC-v0.0.1.tar.gz +/annc_external.tar.gz.aa +/annc_external.tar.gz.ab diff --git a/ANNC.spec b/ANNC.spec new file mode 100644 index 0000000..36ef014 --- /dev/null +++ b/ANNC.spec @@ -0,0 +1,113 @@ +%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 + +%define 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.1 +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/AI4C +Source0: %{pkg_version}.tar.gz +Source1: annc_external.tar.gz.aa +Source2: annc_external.tar.gz.ab +%ifarch x86_64 +Patch0: x86_64_external_files.patch +%endif + +BuildRequires: cmake >= 3.9.9 +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} > annc_external.tar.gz +tar -xzf annc_external.tar.gz -C . +%ifarch x86_64 +%patch 0 -p0 -d . +%endif + +%autosetup -S git -n %{pkg_version} + +%build + +cd %{build_dir} + +run_bazel_build() { + bazel --output_user_root=./output \ + build -c opt --copt="-DANNC_ENABLED_GRAPH_OPT" \ + --copt="-DANNC_ENABLED_OPENBLAS" \ + --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 +} + +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} + +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 <zhengchenhui1@huawei.com> - 0.0.1-1 +- Type:Init +- ID:NA +- SUG:NA +- DEC:Init ANNC repository @@ -0,0 +1,3 @@ +ab91a5dc204e17656a63f9b9b3c94728 ANNC-v0.0.1.tar.gz +a3f0ec5120fa9b65af527332299c9d46 annc_external.tar.gz.aa +f548d6ba0ad0163c0aa3df33250e97c6 annc_external.tar.gz.ab diff --git a/x86_64_external_files.patch b/x86_64_external_files.patch new file mode 100644 index 0000000..1f77ebc --- /dev/null +++ b/x86_64_external_files.patch @@ -0,0 +1,150 @@ +diff --git a/external/go_sdk/BUILD.bazel b/x86_64/external/go_sdk/BUILD.bazel +index 9cf6add..511ddbc 100644 +--- a/external/go_sdk/BUILD.bazel ++++ b/x86_64/external/go_sdk/BUILD.bazel +@@ -7,8 +7,8 @@ package(default_visibility = ["//visibility:public"]) + filegroup( + name = "libs", + srcs = glob( +- ["pkg/linux_arm64/**/*.a"], +- exclude = ["pkg/linux_arm64/**/cmd/**"], ++ ["pkg/linux_amd64/**/*.a"], ++ exclude = ["pkg/linux_amd64/**/cmd/**"], + ), + ) + +@@ -34,7 +34,7 @@ go_sdk( + name = "go_sdk", + srcs = [":srcs"], + go = "bin/go", +- goarch = "arm64", ++ goarch = "amd64", + goos = "linux", + headers = [":headers"], + libs = [":libs"], +@@ -60,7 +60,7 @@ package_list( + + declare_toolchains( + builder = ":builder", +- host = "linux_arm64", ++ host = "linux_amd64", + sdk = ":go_sdk", + ) + +diff --git a/external/go_sdk/src/internal/buildcfg/zbootstrap.go b/x86_64/external/go_sdk/src/internal/buildcfg/zbootstrap.go +index 81bd76b..560f94f 100644 +--- a/external/go_sdk/src/internal/buildcfg/zbootstrap.go ++++ b/x86_64/external/go_sdk/src/internal/buildcfg/zbootstrap.go +@@ -12,7 +12,7 @@ const defaultGOMIPS64 = `hardfloat` + const defaultGOPPC64 = `power8` + const defaultGOEXPERIMENT = `` + const defaultGO_EXTLINK_ENABLED = `` +-const defaultGO_LDSO = `/lib/ld-linux-aarch64.so.1` ++const defaultGO_LDSO = `/lib64/ld-linux-x86-64.so.2` + const version = `go1.18.4` + const defaultGOOS = runtime.GOOS + const defaultGOARCH = runtime.GOARCH +diff --git a/external/local_config_cc/BUILD b/x86_64/external/local_config_cc/BUILD +index 51949c4..89f56ce 100755 +--- a/external/local_config_cc/BUILD ++++ b/x86_64/external/local_config_cc/BUILD +@@ -47,15 +47,15 @@ filegroup( + cc_toolchain_suite( + name = "toolchain", + toolchains = { +- "aarch64|compiler": ":cc-compiler-aarch64", +- "aarch64": ":cc-compiler-aarch64", ++ "k8|compiler": ":cc-compiler-k8", ++ "k8": ":cc-compiler-k8", + "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a", + "armeabi-v7a": ":cc-compiler-armeabi-v7a", + }, + ) + + cc_toolchain( +- name = "cc-compiler-aarch64", ++ name = "cc-compiler-k8", + toolchain_identifier = "local", + toolchain_config = ":local", + all_files = ":compiler_deps", +@@ -72,7 +72,7 @@ cc_toolchain( + + cc_toolchain_config( + name = "local", +- cpu = "aarch64", ++ cpu = "k8", + compiler = "compiler", + toolchain_identifier = "local", + host_system_name = "local", +@@ -80,11 +80,11 @@ cc_toolchain_config( + target_libc = "local", + abi_version = "local", + abi_libc_version = "local", +- cxx_builtin_include_directories = ["/usr/lib/gcc/aarch64-openEuler-linux/12/include", ++ cxx_builtin_include_directories = ["/usr/lib/gcc/x86_64-openEuler-linux/12/include", + "/usr/local/include", + "/usr/include", + "/usr/include/c++/12", +- "/usr/include/c++/12/aarch64-openEuler-linux", ++ "/usr/include/c++/12/x86_64-openEuler-linux", + "/usr/include/c++/12/backward"], + tool_paths = {"ar": "/usr/bin/ar", + "ld": "/usr/bin/ld", +diff --git a/external/local_config_cc/builtin_include_directory_paths b/x86_64/external/local_config_cc/builtin_include_directory_paths +index 711ac34..50fea54 100755 +--- a/external/local_config_cc/builtin_include_directory_paths ++++ b/x86_64/external/local_config_cc/builtin_include_directory_paths +@@ -4,9 +4,9 @@ changes to it will be reflected in the action cache key. When some of these + paths change, Bazel will make sure to rerun the action, even though none of + declared action inputs or the action commandline changes. + +-/usr/lib/gcc/aarch64-openEuler-linux/12/include ++/usr/lib/gcc/x86_64-openEuler-linux/12/include + /usr/local/include + /usr/include + /usr/include/c++/12 +-/usr/include/c++/12/aarch64-openEuler-linux ++/usr/include/c++/12/x86_64-openEuler-linux + /usr/include/c++/12/backward +diff --git a/external/local_config_cc_toolchains/BUILD b/x86_64/external/local_config_cc_toolchains/BUILD +index db5234f..f9c0875 100755 +--- a/external/local_config_cc_toolchains/BUILD ++++ b/x86_64/external/local_config_cc_toolchains/BUILD +@@ -1,10 +1,10 @@ + load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS") + + toolchain( +- name = "cc-toolchain-aarch64", ++ name = "cc-toolchain-k8", + exec_compatible_with = HOST_CONSTRAINTS, + target_compatible_with = HOST_CONSTRAINTS, +- toolchain = "@local_config_cc//:cc-compiler-aarch64", ++ toolchain = "@local_config_cc//:cc-compiler-k8", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", + ) + +diff --git a/external/local_config_platform/constraints.bzl b/x86_64/external/local_config_platform/constraints.bzl +index 4b29ad7..6a7d8c3 100644 +--- a/external/local_config_platform/constraints.bzl ++++ b/x86_64/external/local_config_platform/constraints.bzl +@@ -1,6 +1,6 @@ + # DO NOT EDIT: automatically generated constraints list for local_config_platform + # Auto-detected host platform constraints. + HOST_CONSTRAINTS = [ +- '@platforms//cpu:aarch64', ++ '@platforms//cpu:x86_64', + '@platforms//os:linux', + ] +diff --git a/external/local_execution_config_platform/BUILD b/x86_64/external/local_execution_config_platform/BUILD +index b4d7fdf..7dfbc12 100755 +--- a/external/local_execution_config_platform/BUILD ++++ b/x86_64/external/local_execution_config_platform/BUILD +@@ -18,7 +18,7 @@ platform( + name = "platform", + visibility = ["//visibility:public"], + constraint_values = [ +- "@platforms//cpu:aarch64", ++ "@platforms//cpu:x86_64", + "@platforms//os:linux", + ":platform_constraint", + ], |