Merged
【PR】: feat:pyACL开源 #4635
Y_KevenAdd on Sep 1
【PR】: feat:pyACL开源 #4635
Merged
Y_KevenAdd on Sep 1
Total: 93 files changed+20897-1
@@ -27,7 +27,7 @@ repos:
27 - id: oat-check27 - id: oat-check
28 name: OAT Compliance Check28 name: OAT Compliance Check
29 entry: bash scripts/oat_check.sh29 entry: bash scripts/oat_check.sh
30- exclude: '^(\.pre-commit-config\.yaml|README\.md|\.devcontainer/Dockerfile|Third_Party_Open_Source_Software_List\.yaml)$'30+ exclude: '^(\.pre-commit-config\.yaml|README\.md|\.devcontainer/Dockerfile|Third_Party_Open_Source_Software_List\.yaml|.*help\.info)$'
31 language: system31 language: system
32 pass_filenames: true32 pass_filenames: true
33 types: [file]33 types: [file]
@@ -0,0 +1,113 @@
1+# -----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# -----------------------------------------------------------------------------------------------------------
10+ 
11+# CMake 最低版本号要求
12+cmake_minimum_required (VERSION 3.13.5)
13+ 
14+#项目名称
15+project(acl)
16+ 
17+#全局变量
18+set(ACL_LIB "${PROJECT_SOURCE_DIR}/dependency/lib64")
19+set(CMAKE_VERBOSE_MAKEFILE ON)
20+ 
21+# 安全规范编译命令
22+add_compile_options(-fvisibility=hidden)
23+add_compile_options("-fPIE")
24+add_compile_options("-std=c++11")
25+add_compile_options("-fPIC")
26+add_compile_options("-fstack-protector-all")
27+add_compile_options("-Wall")
28+add_compile_options("-Wextra")
29+add_compile_options("-Wfloat-equal")
30+add_compile_options("-fno-common")
31+add_compile_options("-D_FORTIFY_SOURCE=2")
32+add_compile_options("-fno-strict-aliasing")
33+add_compile_options("-O2")
34+add_compile_options("-Weffc++")
35+add_compile_options("-Wtrampolines")
36+add_compile_options("-Wformat=2")
37+add_compile_options("-Wdate-time")
38+add_compile_options("-Wswitch-default")
39+add_compile_options("-Wshadow")
40+add_compile_options("-Wconversion")
41+add_compile_options("-Wcast-qual")
42+add_compile_options("-Wcast-align")
43+add_compile_options("-Wvla")
44+add_compile_options("-Wunused")
45+add_compile_options("-Wundef")
46+add_compile_options("-fstrong-eval-order")
47+add_compile_options("-pipe")
48+ 
49+add_link_options("-Wl,-z,now")
50+add_link_options("-Wl,-z,relro")
51+add_link_options("-Wl,-z,noexecstack")
52+add_link_options("-pie")
53+add_link_options("-s")
54+set(CMAKE_SKIP_RPATH TRUE)
55+set(CMAKE_CXX_FLAGS "-Wno-builtin-macro-redefined -U__FILE__ -D__FILE__='\"$(notdir $(abspath $<))\"'")
56+ 
57+#依赖编译选项
58+add_definitions(-DENABLE_DVPP_INTERFACE)
59+add_definitions(-DASCEND_CI_LIMITED_PY37)
60+ 
61+set(OS_TYPE $ENV{ARCH})
62+ 
63+#头文件目录包含
64+#include_directories(${PROJECT_SOURCE_DIR}/opensource/python/python3/include/python3.8/)
65+if (OS_TYPE MATCHES "sw_64")
66+ include_directories(/usr/include/python3.7m)
67+ include_directories(/usr/include/python3.7m/numpy)
68+else()
69+ include_directories(/usr/local/include/)
70+ include_directories(/lib/python3.9/site-packages/numpy/core/include/)
71+ include_directories(/opt/buildtools/python-3.9.11/lib/python3.9/site-packages/numpy/core/include/)
72+ include_directories(/lib/python3.10/site-packages/numpy/core/include/)
73+ include_directories(/opt/buildtools/python-3.10.2/lib/python3.10/site-packages/numpy/core/include/)
74+ include_directories(/opt/buildtools/python-3.11.4/include/python3.11/)
75+ include_directories(/opt/buildtools/python-3.11.4/lib/python3.11/site-packages/numpy/core/include)
76+endif()
77+ 
78+include_directories(${PROJECT_SOURCE_DIR}/dependency/include/)
79+include_directories(${PROJECT_SOURCE_DIR}/dependency/include/acl/)
80+include_directories(${PROJECT_SOURCE_DIR}/pyACL)
81+include_directories(${PROJECT_SOURCE_DIR}/pyACL/rt/)
82+include_directories(${PROJECT_SOURCE_DIR}/pyACL/mdl/)
83+include_directories(${PROJECT_SOURCE_DIR}/pyACL/media/)
84+include_directories(${PROJECT_SOURCE_DIR}/pyACL/op/)
85+include_directories(${PROJECT_SOURCE_DIR}/pyACL/blas/)
86+include_directories(${PROJECT_SOURCE_DIR}/pyACL/util/)
87+include_directories(${PROJECT_SOURCE_DIR}/pyACL/prof/)
88+include_directories(${PROJECT_SOURCE_DIR}/pyACL/himpi/)
89+include_directories(${PROJECT_SOURCE_DIR}/pyACL/fv/)
90+# 动态链接库
91+link_directories(${ACL_LIB})
92+ 
93+#添加src子目录
94+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL APP_SOURCES)
95+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/rt/ APP_SOURCES)
96+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/mdl/ APP_SOURCES)
97+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/media/ APP_SOURCES)
98+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/op/ APP_SOURCES)
99+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/blas/ APP_SOURCES)
100+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/util/ APP_SOURCES)
101+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/prof/ APP_SOURCES)
102+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/himpi/ APP_SOURCES)
103+aux_source_directory(${PROJECT_SOURCE_DIR}/pyACL/fv/ APP_SOURCES)
104+ 
105+#将源文件排序,从而保证BEP一致
106+list(SORT APP_SOURCES)
107+ 
108+# 生成动态库或共享库
109+add_library(acl SHARED ${APP_SOURCES})
110+ 
111+#去掉lib前缀,指定链接库
112+set_target_properties(acl PROPERTIES PREFIX "")
113+target_link_libraries(acl ascendcl acl_dvpp acl_cblas acl_dvpp_mpi acl_retr)
@@ -0,0 +1,66 @@
1+# ACL
2+ 
3+## 介绍
4+ 
5+The Python API for ACL(Ascend Computing Language).
6+ 
7+AscendCL(Ascend Computing Language)是一套用于在昇腾平台上开发深度神经网络应用的C语言API库,提供运行资源管理、内存管理、模型加载与执行、算子加载与执行、媒体数据处理等API,能够实现利用昇腾硬件计算资源、在昇腾CANN平台上进行深度学习推理计算、图形图像预处理、单算子加速计算等能力。简单来说,就是统一的API框架,实现对所有资源的调用。计算资源层是昇腾AI处理的硬件算力基础,主要完成神经网络的矩阵相关计算、完成控制算子/标量/向量等通用计算和执行控制功能、完成图像和视频数据的预处理,为深度神经网络计算提供了执行上的保障。
8+ 
9+pyACL(Python Ascend Computing Language)就是在AscendCL的基础上使用CPython封装得到的Python API库,使用户可以通过Python语言进行昇腾AI处理器的运行管理、资源管理等。
10+ 
11+## 文件目录组织结构
12+ 
13+```text
14+python
15+├── build
16+│ ├── bep //
17+│ └── build.sh //调用该脚本来完成编译acl.so、生成run包
18+├── ci //CI构建的依赖项配置
19+├── script //run包的安装、卸载脚本、help、patch等
20+|── output //run包构建后最终的存放目录
21+└── pyACL //CPython封装ACL源码
22+```
23+ 
24+## 构建
25+ 
26+### 在CI环境下
27+ 
28+```bash
29+cd build
30+cmake ..
31+make
32+```
33+ 
34+### 在非CI环境下
35+ 
36+由于环境不同需要重新配置CMakeLisits文件
37+ 
38+将ACL_LIB由"${PROJECT_SOURCE_DIR}/dependency/lib64"替换为环境上CANN包的路径,如:
39+ 
40+```cmake
41+set(ACL_LIB "/usr/local/Ascend/ascend-toolkit/latest/lib64/")
42+```
43+ 
44+通过include_directories设置环境上的CANN包路径,如:
45+ 
46+```cmake
47+include_directories(/usr/local/Ascend/ascend-toolkit/latest/include/)
48+```
49+ 
50+通过include_directories设置环境上的python软件路径,如:
51+ 
52+```cmake
53+include_directories(/usr/local/python3.9.0/include/python3.9/)
54+include_directories(/usr/local/python3.9.0/lib/python3.9/site-packages/numpy/core/include/)
55+```
56+ 
57+## 使用说明
58+ 
59+pyACL集成在cann-toolkit中 <br>
60+运行依赖:同版本的driver包和runtime组件 <br>
61+ 
62+## 开发指导
63+ 
64+CPython封装指导:https://docs.python.org/release/3.7.5/extending/extending.html# <br>
65+CPython数据解析:https://docs.python.org/release/3.7.5/c-api/arg.html#other-objects <br>
66+CPython异常类型:https://docs.python.org/3/library/exceptions.html#RuntimeError <br>
@@ -0,0 +1,66 @@
1+# ACL
2+ 
3+## Introduction
4+ 
5+The Python API for ACL (Ascend Computing Language).
6+ 
7+AscendCL (Ascend Computing Language) is a C language API library for developing deep neural network applications on the Ascend platform. It provides APIs for runtime resource management, memory management, model loading and execution, operator loading and execution, and media data processing. It enables you to leverage the computing resources of Ascend hardware to perform deep learning inference on the Ascend CANN platform, graphics/image pre-processing, and accelerated computation of individual operators. In short, it is a unified API framework for invoking all resources. The computing resource layer is the hardware foundation for Ascend AI processing. It mainly performs matrix-related computations of neural networks, general computations and execution control for control operators/scalars/vectors, and pre-processing of image and video data, providing execution guarantees for deep neural network computation.
8+ 
9+pyACL (Python Ascend Computing Language) is a Python API library built on top of AscendCL using CPython wrapping, allowing users to manage the runtime and resources of Ascend AI processors through the Python language.
10+ 
11+## Directory Structure
12+ 
13+```text
14+python
15+├── build
16+│ ├── bep //
17+│ └── build.sh //Run this script to compile acl.so and generate the run package
18+├── ci //Dependency configuration for CI build
19+├── script //Installation, uninstallation, help, patch, and other scripts for the run package
20+|── output //Final storage directory after the run package is built
21+└── pyACL //CPython-wrapped ACL source code
22+```
23+ 
24+## Build
25+ 
26+### In a CI environment
27+ 
28+```bash
29+cd build
30+cmake ..
31+make
32+```
33+ 
34+### In a non-CI environment
35+ 
36+Due to environment differences, the CMakeLists file needs to be reconfigured.
37+ 
38+Replace the value of ACL_LIB "${PROJECT_SOURCE_DIR}/dependency/lib64" with the path of the CANN package in your environment, for example:
39+ 
40+```cmake
41+set(ACL_LIB "/usr/local/Ascend/ascend-toolkit/latest/lib64/")
42+```
43+ 
44+Set the CANN package path in your environment via include_directories, for example:
45+ 
46+```cmake
47+include_directories(/usr/local/Ascend/ascend-toolkit/latest/include/)
48+```
49+ 
50+Set the Python software path in your environment via include_directories, for example:
51+ 
52+```cmake
53+include_directories(/usr/local/python3.9.0/include/python3.9/)
54+include_directories(/usr/local/python3.9.0/lib/python3.9/site-packages/numpy/core/include/)
55+```
56+ 
57+## Usage
58+ 
59+pyACL is integrated in cann-toolkit <br>
60+Runtime dependencies: driver package and runtime component of the same version <br>
61+ 
62+## Development Guide
63+ 
64+CPython wrapping guide: https://docs.python.org/release/3.7.5/extending/extending.html# <br>
65+CPython argument parsing: https://docs.python.org/release/3.7.5/c-api/arg.html#other-objects <br>
66+CPython exception types: https://docs.python.org/3/library/exceptions.html#RuntimeError <br>
@@ -0,0 +1,104 @@
1+[timestamp]
2+bep_timestamp=2020-03-19,10:42:14
3+second=2020-03-19,10:32:14
4+third=2020-03-19,10:22:14
5+################################################################################
6+# --- You can specify the value of keyword in section user_define_data.
7+# --- If not set, bep script will use the default value. e.g. BEP_HOSTNAME = buildhost,BEP_INODE = 1.
8+# --- You can unset BEP_HOSTNAME to get the real hostname.
9+################################################################################
10+ 
11+[user_define_data]
12+BEP_HOSTNAME=buildhost
13+BEP_UID=
14+BEP_GID=
15+BEP_INODE=1
16+BEP_DEV_ID=
17+BEP_R_DEV_ID=
18+ 
19+[trace_define_data]
20+# init bepkit trace sqlite3 datebase when exec source ./bep_env.sh -s.
21+#BEP_TRACE_ENABLE=yes
22+# bepkit trace mode: fast/compile/build/full, default: build
23+#BEP_TRACE_MODE=build
24+#BEP_TRACE_OUTPUT="/tmp/bepkit/bepkit_trace.db"
25+#BEP_TRACE_WHITELIST=
26+#BEP_TRACE_BUILDLIST=
27+#BEP_TRACE_BUILD_TOOLNAME=
28+#BEP_TRACE_OUTPUT_TOOLNAME=
29+ 
30+ 
31+################################################################################
32+# --- bep_time_blacklist have priority over whitelist.
33+################################################################################
34+[bep_time_blacklist]
35+#BEP_TIMELIST=aarch64-linux-gnu-ar adduser ant ar arm-linux-gnueabi-ranlib bash bzip2 cc1 cc1plus chpasswd cpio gpg guile gzip hpmimage java lzma mkfs.cramfs mkfs.ext2 mkfs.jffs2 mkimage makepatch mksquashfs passwd powerpc-wrs-linux-gnu-ar powerpc-wrs-linux-gnu-ranlib ranlib rpmbuild strip tar useradd xz zip perl python python3 python3.7 python3.7.5 dd du
36+#BEP_CGTLIST=aarch64-linux-gnu-ar aarch64-linux-gnu-ld aarch64-linux-gnu-objcopy aarch64-linux-gnu-objdump bash date file gpg gzip hpmimage ld mkfs.cramfs mkfs.jffs2 mkimage postmap rpmdb sh tar zip perl python python3 python3.7 python3.7.5 dd du
37+#BEP_FILE_TIME_LIST=aarch64-linux-gnu-ar aarch64-linux-gnu-gcc aarch64-linux-gnu-ld aarch64-linux-gnu-objcopy aarch64-linux-gnu-objdump ar arm-linux-gnueabi-g++ arm-linux-gnueabi-gcc as awk bash cat cc1 cc1plus chmod cp cpio file grep gzip hpmimage java ld lzma mkfs.cramfs mkfs.jffs2 mkimage postmap python2.7 python3.7 rpmbuild rpmdb sh strip tar zip perl python python3 python3.7 python3.7.5 dd du
38+ 
39+################################################################################
40+# --- the program of whitelist will cause compile block or break.
41+################################################################################
42+[whitelist]
43+BEP_WHITELIST=be cvs git git-merge gpg-agent ls make ntpdate perl python2.7.real rsync sed svn test zip python python3 python3.8 python3.8.5
44+ 
45+################################################################################
46+# --- BEP_PRO_TIMES_LIST is equal to BEP_TIMESLIST in 1.1.x version
47+# --- BEP_DIRLIST is used to handle differences in file order, which equals to BEP_BLACKLIST in 1.1.X version
48+# --- BEP_DIRONCELIST is used to reinforce BEP_DIRLIST, it will only traverse once in this list
49+# --- BEP_RANDOMLIST is set for random source, including rand(), random(), /dev/random and /dev/urandom.
50+################################################################################
51+[blacklist]
52+BEP_GTDLIST=EMAP_Tool aarch64-linux-gnu-ar aarch64-linux-gnu-cpp aarch64-linux-gnu-ld aarch64-linux-gnu-objcopy aarch64-linux-gnu-objdump arm-linux-gnueabi-gcc bash cc1 createbin date doxygen file g++ gpg gs gzip hpmimage iscsi-name label_bin ld mips-wrs-linux-gcc mkfs.cramfs mkfs.ext2 mkfs.jffs2 mkimage node postmap rpmdb sh tar zip perl python python3 python3.7 python3.7.5
53+BEP_PRO_TIMES_LIST=gs
54+BEP_DIRLIST=ar depmod fdupes gpg gtk-update-icon-cache make miniperl miniruby mksquashfs mksquashfs64 perl php python python2 python3 rcc tar texi2html zip ls gmake qmake dmake pmake emake cmake remake find
55+BEP_NFTWLIST=jevents
56+BEP_INOLIST=gs postmap rpmdb gzip cpio
57+BEP_UIDLIST=EMAP_Tool ar gzip tar zip mkfs.ext2
58+BEP_DEVIDLIST=stat tar gzip rpmbuild cpio
59+BEP_RANDOMLIST=chpasswd g++ gcc gpg guile iscsi-name java mksquashfs mksquashfs64 passwd perl postmap rpmdb tar zip ld
60+BEP_NAMELIST=configure emacs hostname perl python python3 rpmbuild uname
61+BEP_DIRSIZELIST=du
62+BEP_FILESIZELIST=stat
63+ 
64+[hash_seed]
65+PERL_HASH_SEED=0
66+PYTHONHASHSEED=0
67+ 
68+[timezone]
69+TZ=Asia/Shanghai
70+SOURCE_DATE_EPOCH=yes
71+ 
72+################################################################################
73+# --- LC_ALL. This variable overrides the value of LANG and any other LC_ variable specifying a locale category.
74+# --- disabel LC_ALL and set LC_CTYPE to "en_US-UTF-8" will support chinese env.
75+################################################################################
76+[locale]
77+LC_ALL=C
78+#LC_CTYPE="en_US-UTF-8"
79+#LC_NUMERIC="C"
80+#LC_TIME="C"
81+#LC_COLLATE="C"
82+#LC_MONETARY="C"
83+#LC_MESSAGES="C"
84+#LC_PAPER="C"
85+#LC_NAME="C"
86+#LC_ADDRESS="C"
87+#LC_TELEPHONE="C"
88+#LC_MEASUREMENT="C"
89+#LC_IDENTIFICATION="C"
90+ 
91+[sysinfo]
92+BEP_SYSINFOLIST=
93+BEP_SYSINFO_UPTIME=
94+BEP_SYSINFO_LOADS=
95+BEP_SYSINFO_TOTALRAM=
96+BEP_SYSINFO_FREERAM=
97+BEP_SYSINFO_SHAREDRAM=
98+BEP_SYSINFO_BUFFERRAM=
99+BEP_SYSINFO_TOTALSWAP=
100+BEP_SYSINFO_FREESWAP=
101+BEP_SYSINFO_PROCS=
102+BEP_SYSINFO_TOTALHIGH=
103+BEP_SYSINFO_FREEHIGH=
104+BEP_SYSINFO_MEN_UNIT=
@@ -0,0 +1,174 @@
1+#!/bin/bash
2+# -----------------------------------------------------------------------------------------------------------
3+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
4+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5+# CANN Open Software License Agreement Version 2.0 (the "License").
6+# Please refer to the License for details. You may not use this file except in compliance with the License.
7+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9+# See LICENSE in the root of the software repository for the full text of the License.
10+# -----------------------------------------------------------------------------------------------------------
11+ 
12+set -e
13+source /etc/profile
14+CUR_DIR=$(dirname $(readlink -f $0))
15+TOP_DIR=$(readlink -f $CUR_DIR/../)
16+INSTALL_DIR=$TOP_DIR/platform/Tuscany/build_pyacl
17+ 
18+SO_DIR=$TOP_DIR/temp/python/site-packages/
19+SCRIPT_DIR=$TOP_DIR/temp/script
20+GCC_VERSION=$(gcc --version | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/')
21+OS_NAME=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
22+ 
23+BASE_PACKAGE_VERSION=$(echo ${1} | cut -d "=" -f 2)
24+CANN_TYPE=$(echo ${2} | cut -d "=" -f 2)
25+PACKAGE_VERSION=$(echo ${3} | cut -d "=" -f 2)
26+JEMALLOC_SOURCE_DIR=$TOP_DIR/opensource
27+ 
28+if [ x"${BASE_PACKAGE_VERSION}" = "x" ]; then
29+ exit 1
30+fi
31+# 非补丁包基线版本和包版本需一致
32+if [ "$CANN_TYPE" != Patch ] && [ "$BASE_PACKAGE_VERSION" != "$PACKAGE_VERSION" ]; then
33+ echo "BASE_PACKAGE_VERSION and PACKAGE_VERSION are not equal"
34+ exit 1
35+fi
36+ 
37+function bep_env_init() {
38+ # bep消除二进制
39+ local bep_env_config=$CUR_DIR/bep/bep_env.conf
40+ # 检查BepKit预置环境
41+ local bep_sh=$(which bep_env.sh)
42+ echo "has bep sh :${bep_sh}"
43+ # 执行bep脚本
44+ if [ ! -d "${SECBEPKIT_HOME}" ] && [ ! -f "$bep_sh" ]; then
45+ echo "BepKit is uninstalled, Please install the tool and configure the env var \$SECBEPKIT_HOME"
46+ else
47+ source ${SECBEPKIT_HOME}/bep_env.sh -s $bep_env_config
48+ if [ $? -ne 0 ]; then
49+ echo "build bep failed!"
50+ exit 1
51+ else
52+ echo "build bep success."
53+ fi
54+ fi
55+}
56+ 
57+function get_os_name() {
58+ awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"'
59+}
60+ 
61+function get_os_version() {
62+ local os_name=$(get_os_name)
63+ declare -A os_version=(["ubuntu"]="$(awk -F= '/^VERSION_ID=/{print $2}' /etc/os-release | tr -d '"')" ["centos"]="7.6" ["euleros"]="2.8" ["debian"]="9.9" ["uos"]="20")
64+ for key in "${!os_version[@]}"; do
65+ if [ "$key" == "$os_name" ]; then
66+ echo "${os_version[$key]}"
67+ return 0
68+ fi
69+ done
70+ exit 1
71+}
72+ 
73+function clean() {
74+ [ -n "${path_build}" ] && rm -rf $path_build
75+}
76+ 
77+function build_jemalloc() {
78+ local jemalloc_build_path=$path_build/jemalloc_build
79+ if [ ! -d "$jemalloc_build_path" ]; then
80+ mkdir -p "$jemalloc_build_path"
81+ fi
82+ 
83+ mv "$JEMALLOC_SOURCE_DIR/jemalloc" "$jemalloc_build_path/"
84+ pushd "$jemalloc_build_path/jemalloc"
85+ LDFLAGS="-Wl,-z,relro,-z,now,-s" CFLAGS="-fstack-protector-all" ./autogen.sh
86+ make
87+ if [ $? -ne 0 ]; then
88+ exit 1
89+ fi
90+ cp "./lib/libjemalloc.so.2" "./libjemalloc.so"
91+ mv "./libjemalloc.so" "$SO_DIR"
92+ popd
93+}
94+ 
95+bep_env_init
96+ 
97+OS_NAME=$(get_os_name)
98+OS_VERSION=$(get_os_version)
99+ 
100+x86_flag=n
101+export ARCH=$(arch)
102+ 
103+chmod 750 $TOP_DIR/script/*.sh
104+ 
105+chmod 750 $TOP_DIR/platform/Tuscany/*.run
106+ 
107+if [ $( uname -a | grep -c -i "x86_64" ) -ne 0 ]; then
108+ x86_flag=y
109+ echo "it is system of x86_64"
110+elif [ $( uname -a | grep -c -i "aarch64" ) -ne 0 ]; then
111+ echo "it is system of aarch64"
112+else
113+ echo "it is system of sw_64"
114+fi
115+ 
116+$TOP_DIR/platform/Tuscany/cann-npu-runtime_*-$ARCH.run --full --install-path=$INSTALL_DIR -q
117+$TOP_DIR/platform/Tuscany/cann-acl-extend_*-$ARCH.run --full --install-path=$INSTALL_DIR -q
118+$TOP_DIR/platform/Tuscany/cann-dvpp_*-$ARCH.run --full --install-path=$INSTALL_DIR -q
119+$TOP_DIR/platform/Tuscany/cann-ge-executor_*-$ARCH.run --full --install-path=$INSTALL_DIR -q
120+ 
121+mkdir -p $TOP_DIR/dependency/lib64
122+cp -af $INSTALL_DIR/cann/*-linux/lib64/*.so $TOP_DIR/dependency/lib64
123+cp -af $INSTALL_DIR/cann/*-linux/include $TOP_DIR/dependency
124+ 
125+chmod +w $TOP_DIR/dependency/include/acl
126+chmod +w $TOP_DIR/dependency/include/acl/acl_base_rt.h
127+sed -i 's/#define ACL_DEPRECATED __attribute__((deprecated))/#define ACL_DEPRECATED/g' $TOP_DIR/dependency/include/acl/acl_base_rt.h
128+sed -i "s/#define ACL_DEPRECATED_MESSAGE(message) __attribute__((deprecated(message)))/#define ACL_DEPRECATED_MESSAGE(message)/g" $TOP_DIR/dependency/include/acl/acl_base_rt.h
129+path_build=$CUR_DIR/temp
130+mkdir -p $path_build
131+cd $path_build
132+cmake ../..
133+make
134+if [ $? -ne 0 ]; then
135+ exit 1
136+fi
137+mkdir -p $SO_DIR
138+mkdir -p $SCRIPT_DIR
139+chmod 444 *.so
140+mv *.so $SO_DIR
141+ 
142+# 将jemalloc打包功能借助pyacl子包实现
143+build_jemalloc
144+ 
145+chmod 750 $TOP_DIR/opensource/makeself/*.sh
146+sed -i "s/^BASE_PACKAGE_VERSION=.*/BASE_PACKAGE_VERSION=\"$BASE_PACKAGE_VERSION\"/" $TOP_DIR/script/install.sh
147+sed -i "s/^PACKAGE_VERSION=.*/PACKAGE_VERSION=\"${PACKAGE_VERSION}\"/" $TOP_DIR/script/install.sh
148+if [ "$CANN_TYPE" = Patch ]; then
149+ sed -i "s/^CANN_TYPE=.*/CANN_TYPE=\"patch\"/" $TOP_DIR/script/install.sh
150+ sed -i "s/^BASE_PACKAGE_VERSION=.*/BASE_PACKAGE_VERSION=\"$BASE_PACKAGE_VERSION\"/" $TOP_DIR/script/spc_rollback.sh
151+ sed -i "s/^BASE_PACKAGE_VERSION=.*/BASE_PACKAGE_VERSION=\"$BASE_PACKAGE_VERSION\"/" $TOP_DIR/script/spc_uninstall.sh
152+ mkdir -p $SCRIPT_DIR/pyACL
153+ cp -af $TOP_DIR/script/install.sh $SCRIPT_DIR/
154+ cp -af $TOP_DIR/script/spc_rollback.sh $SCRIPT_DIR/pyACL/rollback.sh
155+ cp -af $TOP_DIR/script/spc_uninstall.sh $SCRIPT_DIR/pyACL/uninstall.sh
156+ cp -af $TOP_DIR/script/spc_rollback_precheck.sh $SCRIPT_DIR/pyACL/rollback_precheck.sh
157+ cp -af $TOP_DIR/script/total_rollback.sh $SCRIPT_DIR/rollback.sh
158+ cp -af $TOP_DIR/script/total_uninstall.sh $SCRIPT_DIR/uninstall.sh
159+ cp -af $TOP_DIR/script/spc_help.info $SCRIPT_DIR/help.info
160+ $TOP_DIR/opensource/makeself/makeself.sh --header $TOP_DIR/opensource/makeself/makeself-header.sh --help-header $SCRIPT_DIR/help.info --pigz --complevel 4 --nomd5 --sha256 --chown $TOP_DIR/temp pyACL_${PACKAGE_VERSION}_linux-$ARCH.run pyACL_spc ./script/install.sh
161+else
162+ cp -af $TOP_DIR/script/install.sh $SCRIPT_DIR
163+ cp -af $TOP_DIR/script/uninstall.sh $SCRIPT_DIR
164+ cp -af $TOP_DIR/script/cann_uninstall.sh $SCRIPT_DIR
165+ cp -af $TOP_DIR/script/help.info $SCRIPT_DIR
166+ $TOP_DIR/opensource/makeself/makeself.sh --header $TOP_DIR/opensource/makeself/makeself-header.sh --help-header $SCRIPT_DIR/help.info --pigz --complevel 4 --nomd5 --sha256 --chown $TOP_DIR/temp pyACL_${PACKAGE_VERSION}_linux-$ARCH.run pyACL ./script/install.sh
167+fi
168+ 
169+rm -f $TOP_DIR/output/.gitkeep
170+ 
171+mkdir -p $TOP_DIR/output/$ARCH-$OS_NAME$OS_VERSION
172+mv *.run $TOP_DIR/output/$ARCH-$OS_NAME$OS_VERSION
173+ 
174+clean
@@ -0,0 +1,78 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<!-- Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ CANN Open Software License Agreement Version 2.0 (the "License").
5+ Please refer to the License for details. You may not use this file except in compliance with the License.
6+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ See LICENSE in the root of the software repository for the full text of the License.
9+-->
10+<project>
11+ <artifact>
12+ <versionType>Component</versionType>
13+ <repoType>Generic</repoType>
14+ <id>
15+ <offering>CANN</offering>
16+ <componentName>ACL</componentName>
17+ <componentVersion>20.10.0.B010</componentVersion>
18+ </id>
19+ <isClear>N</isClear>
20+ <copies>
21+ <copy>
22+ <source>output/</source>
23+ <dest />
24+ </copy>
25+ </copies>
26+ </artifact>
27+ <dependencies>
28+ <!-- Platform -->
29+ <dependency>
30+ <versionType>Component</versionType>
31+ <repoType>Generic</repoType>
32+ <id>
33+ <offering>CANN</offering>
34+ <componentName>Tuscany-ASL</componentName>
35+ <componentVersion>1.75.B020</componentVersion>
36+ </id>
37+ <according>Y</according>
38+ <copies>
39+ <copy>
40+ <source>x86_64-centos7.6/cann-npu-runtime_*_linux-x86_64.run</source>
41+ <source>x86_64-centos7.6/cann-acl-extend_*_linux-x86_64.run</source>
42+ <source>x86_64-centos7.6/cann-dvpp_*_linux-x86_64.run</source>
43+ <source>x86_64-centos7.6/cann-ge-executor_*_linux-x86_64.run</source>
44+ <dest>platform/Tuscany</dest>
45+ </copy>
46+ </copies>
47+ </dependency>
48+ <!-- 3rd-party -->
49+ <!--<dependency>
50+ <versionType>3rd-party</versionType>
51+ <repoType>Generic</repoType>
52+ <id>
53+ <artifactName>Python-3.7.5.tgz</artifactName>
54+ <pdmCode>05833PUQ</pdmCode>
55+ </id>
56+ <copies>
57+ <copy>
58+ <source>/*</source>
59+ <dest>opensource/python</dest>
60+ </copy>
61+ </copies>
62+ </dependency>
63+ <dependency>
64+ <versionType>3rd-party</versionType>
65+ <repoType>Generic</repoType>
66+ <id>
67+ <artifactName>numpy-1.18.2.zip</artifactName>
68+ <pdmCode>05834AJL</pdmCode>
69+ </id>
70+ <copies>
71+ <copy>
72+ <source>/*</source>
73+ <dest>opensource/numpy</dest>
74+ </copy>
75+ </copies>
76+ </dependency>-->
77+ </dependencies>
78+</project>
@@ -0,0 +1,297 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "blas.h"
12+#include "acl/acl.h"
13+#include "acl/ops/acl_cblas.h"
14+ 
15+PyObject* WrapAclblasGemvEx(PyObject* /* self */, PyObject* args)
16+{
17+ aclTransType transA = ACL_TRANS_N;
18+ int m = 0;
19+ int n = 0;
20+ void* alpha = nullptr;
21+ void* a = nullptr;
22+ int lda = 0;
23+ aclDataType dataTypeA = ACL_DT_UNDEFINED;
24+ void* x = nullptr;
25+ int incx = 0;
26+ aclDataType dataTypeX = ACL_DT_UNDEFINED;
27+ void* beta = nullptr;
28+ void* y = nullptr;
29+ int incy = 0;
30+ aclDataType dataTypeY = ACL_DT_UNDEFINED;
31+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
32+ aclrtStream stream = nullptr;
33+ 
34+ CHECK_NULL(
35+ PyArg_ParseTuple(
36+ args, "iiikkiikiikkiiik", &transA, &m, &n, &alpha, &a, &lda, &dataTypeA, &x, &incx, &dataTypeX, &beta, &y,
37+ &incy, &dataTypeY, &type, &stream),
38+ "acl.blas.gemv_ex args parse failed");
39+ 
40+ aclError ret = aclblasGemvEx(
41+ transA, m, n, alpha, a, lda, dataTypeA, x, incy, dataTypeX, beta, y, incy, dataTypeY, type, stream);
42+ return Py_BuildValue("i", ret);
43+}
44+ 
45+PyObject* WrapAclblasCreateHandleForGemvEx(PyObject* /* self */, PyObject* args)
46+{
47+ int m = 0;
48+ int n = 0;
49+ aclTransType transA = ACL_TRANS_N;
50+ aclDataType dataTypeA = ACL_DT_UNDEFINED;
51+ aclDataType dataTypeX = ACL_DT_UNDEFINED;
52+ aclDataType dataTypeY = ACL_DT_UNDEFINED;
53+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
54+ aclopHandle* handle = nullptr;
55+ 
56+ CHECK_NULL(
57+ PyArg_ParseTuple(args, "iiiiiii", &transA, &m, &n, &dataTypeA, &dataTypeX, &dataTypeY, &type),
58+ "acl.blas.create_handle_for_gemv_ex args parse failed");
59+ 
60+ aclError ret = aclblasCreateHandleForGemvEx(transA, m, n, dataTypeA, dataTypeX, dataTypeY, type, &handle);
61+ return Py_BuildValue("ki", reinterpret_cast<uintptr_t>(handle), ret);
62+}
63+ 
64+PyObject* WrapAclblasHgemv(PyObject* /* self */, PyObject* args)
65+{
66+ int m = 0;
67+ int n = 0;
68+ aclTransType transA = ACL_TRANS_N;
69+ aclFloat16* alpha = nullptr;
70+ aclFloat16* a = nullptr;
71+ int lda = 0;
72+ aclFloat16* x = nullptr;
73+ int incx = 0;
74+ aclFloat16* beta = nullptr;
75+ aclFloat16* y = nullptr;
76+ int incy = 0;
77+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
78+ aclrtStream stream = nullptr;
79+ 
80+ CHECK_NULL(
81+ PyArg_ParseTuple(
82+ args, "iiikkikikkiik", &transA, &m, &n, &alpha, &a, &lda, &x, &incx, &beta, &y, &incy, &type, &stream),
83+ "acl.blas.hgemv args parse failed");
84+ 
85+ aclError ret = aclblasHgemv(transA, m, n, alpha, a, lda, x, incx, beta, y, incy, type, stream);
86+ return Py_BuildValue("i", ret);
87+}
88+ 
89+PyObject* WrapAclblasCreateHandleForHgemv(PyObject* /* self */, PyObject* args)
90+{
91+ int m = 0;
92+ int n = 0;
93+ aclTransType transA = ACL_TRANS_N;
94+ aclopHandle* handle = nullptr;
95+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
96+ 
97+ CHECK_NULL(
98+ PyArg_ParseTuple(args, "iiii", &transA, &m, &n, &type), "acl.blas.create_handle_for_hgemv args parse failed");
99+ 
100+ aclError ret = aclblasCreateHandleForHgemv(transA, m, n, type, &handle);
101+ return Py_BuildValue("ki", reinterpret_cast<uintptr_t>(handle), ret);
102+}
103+ 
104+PyObject* WrapAclblasS8gemv(PyObject* /* self */, PyObject* args)
105+{
106+ aclTransType transA = ACL_TRANS_N;
107+ int m = 0;
108+ int n = 0;
109+ int32_t* alpha = nullptr;
110+ int8_t* a = nullptr;
111+ int lda = 0;
112+ int8_t* x = nullptr;
113+ int incx = 0;
114+ int32_t* beta = nullptr;
115+ int32_t* y = nullptr;
116+ int incy = 0;
117+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
118+ aclrtStream stream = nullptr;
119+ 
120+ CHECK_NULL(
121+ PyArg_ParseTuple(
122+ args, "iiikkikikkiik", &transA, &m, &n, &alpha, &a, &lda, &x, &incx, &beta, &y, &incy, &type, &stream),
123+ "acl.blas.s8gemv args parse failed");
124+ 
125+ aclError ret = aclblasS8gemv(transA, m, n, alpha, a, lda, x, incx, beta, y, incy, type, stream);
126+ return Py_BuildValue("i", ret);
127+}
128+ 
129+PyObject* WrapAclblasCreateHandleForS8gemv(PyObject* /* self */, PyObject* args)
130+{
131+ int m = 0;
132+ int n = 0;
133+ aclTransType transA = ACL_TRANS_N;
134+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
135+ aclopHandle* handle = nullptr;
136+ CHECK_NULL(
137+ PyArg_ParseTuple(args, "iiii", &transA, &m, &n, &type), "acl.blas.create_handle_for_s8gemv args parse failed");
138+ 
139+ aclError ret = aclblasCreateHandleForS8gemv(transA, m, n, type, &handle);
140+ return Py_BuildValue("ki", reinterpret_cast<uintptr_t>(handle), ret);
141+}
142+ 
143+PyObject* WrapAclblasGemmEx(PyObject* /* self */, PyObject* args)
144+{
145+ aclTransType transA = ACL_TRANS_N;
146+ aclTransType transB = ACL_TRANS_N;
147+ aclTransType transC = ACL_TRANS_N;
148+ int m = 0;
149+ int n = 0;
150+ int k = 0;
151+ void* alpha = nullptr;
152+ void* matrixA = nullptr;
153+ int lda = 0;
154+ aclDataType dataTypeA = ACL_DT_UNDEFINED;
155+ void* matrixB = nullptr;
156+ int ldb = 0;
157+ aclDataType dataTypeB = ACL_DT_UNDEFINED;
158+ void* beta = nullptr;
159+ void* matrixC = nullptr;
160+ int ldc = 0;
161+ aclDataType dataTypeC = ACL_DT_UNDEFINED;
162+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
163+ aclrtStream stream = nullptr;
164+ 
165+ CHECK_NULL(
166+ PyArg_ParseTuple(
167+ args, "iiiiiikkiikiikkiiik", &transA, &transB, &transC, &m, &n, &k, &alpha, &matrixA, &lda, &dataTypeA,
168+ &matrixB, &ldb, &dataTypeB, &beta, &matrixC, &ldc, &dataTypeC, &type, &stream),
169+ "acl.blas.gemm_ex args parse failed");
170+ 
171+ aclError ret = aclblasGemmEx(
172+ transA, transB, transC, m, n, k, alpha, matrixA, lda, dataTypeA, matrixB, ldb, dataTypeB, beta, matrixC, ldc,
173+ dataTypeC, type, stream);
174+ return Py_BuildValue("i", ret);
175+}
176+ 
177+PyObject* WrapAclblasCreateHandleForGemmEx(PyObject* /* self */, PyObject* args)
178+{
179+ aclTransType transA = ACL_TRANS_N;
180+ aclTransType transB = ACL_TRANS_N;
181+ aclTransType transC = ACL_TRANS_N;
182+ int m = 0;
183+ int n = 0;
184+ int k = 0;
185+ aclDataType dataTypeA = ACL_DT_UNDEFINED;
186+ aclDataType dataTypeB = ACL_DT_UNDEFINED;
187+ aclDataType dataTypeC = ACL_DT_UNDEFINED;
188+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
189+ aclopHandle* handle = nullptr;
190+ 
191+ CHECK_NULL(
192+ PyArg_ParseTuple(
193+ args, "iiiiiiiiii", &transA, &transB, &transC, &m, &n, &k, &dataTypeA, &dataTypeB, &dataTypeC, &type),
194+ "acl.blas.create_handle_for_gemm_ex args parse failed");
195+ 
196+ aclError ret =
197+ aclblasCreateHandleForGemmEx(transA, transB, transC, m, n, k, dataTypeA, dataTypeB, dataTypeC, type, &handle);
198+ return Py_BuildValue("ki", reinterpret_cast<uintptr_t>(handle), ret);
199+}
200+ 
201+PyObject* WrapAclblasHgemm(PyObject* /* self */, PyObject* args)
202+{
203+ aclTransType transA = ACL_TRANS_N;
204+ aclTransType transB = ACL_TRANS_N;
205+ aclTransType transC = ACL_TRANS_N;
206+ int m = 0;
207+ int n = 0;
208+ int k = 0;
209+ aclFloat16* alpha = nullptr;
210+ aclFloat16* matrixA = nullptr;
211+ int lda = 0;
212+ aclFloat16* matrixB = nullptr;
213+ int ldb = 0;
214+ aclFloat16* beta = nullptr;
215+ aclFloat16* matrixC = nullptr;
216+ int ldc = 0;
217+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
218+ aclrtStream stream = nullptr;
219+ 
220+ CHECK_NULL(
221+ PyArg_ParseTuple(
222+ args, "iiiiiikkikikkiik", &transA, &transB, &transC, &m, &n, &k, &alpha, &matrixA, &lda, &matrixB, &ldb,
223+ &beta, &matrixC, &ldc, &type, &stream),
224+ "acl.blas.hgemm args parse failed");
225+ 
226+ aclError ret = aclblasHgemm(
227+ transA, transB, transC, m, n, k, alpha, matrixA, lda, matrixB, ldb, beta, matrixC, ldc, type, stream);
228+ return Py_BuildValue("i", ret);
229+}
230+ 
231+PyObject* WrapAclblasCreateHandleForHgemm(PyObject* /* self */, PyObject* args)
232+{
233+ aclTransType transA = ACL_TRANS_N;
234+ aclTransType transB = ACL_TRANS_N;
235+ aclTransType transC = ACL_TRANS_N;
236+ int m = 0;
237+ int n = 0;
238+ int k = 0;
239+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
240+ aclopHandle* handle = nullptr;
241+ 
242+ CHECK_NULL(
243+ PyArg_ParseTuple(args, "iiiiiii", &transA, &transB, &transC, &m, &n, &k, &type),
244+ "acl.blas.create_handle_for_hgemm args parse failed");
245+ 
246+ aclError ret = aclblasCreateHandleForHgemm(transA, transB, transC, m, n, k, type, &handle);
247+ return Py_BuildValue("ki", reinterpret_cast<uintptr_t>(handle), ret);
248+}
249+ 
250+PyObject* WrapAclblasS8gemm(PyObject* /* self */, PyObject* args)
251+{
252+ aclTransType transA = ACL_TRANS_N;
253+ aclTransType transB = ACL_TRANS_N;
254+ aclTransType transC = ACL_TRANS_N;
255+ int m = 0;
256+ int n = 0;
257+ int k = 0;
258+ int32_t* alpha = nullptr;
259+ int8_t* matrixA = nullptr;
260+ int lda = 0;
261+ int8_t* matrixB = nullptr;
262+ int ldb = 0;
263+ int32_t* beta = nullptr;
264+ int32_t* matrixC = nullptr;
265+ int ldc = 0;
266+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
267+ aclrtStream stream = nullptr;
268+ 
269+ CHECK_NULL(
270+ PyArg_ParseTuple(
271+ args, "iiiiiikkikikkiik", &transA, &transB, &transC, &m, &n, &k, &alpha, &matrixA, &lda, &matrixB, &ldb,
272+ &beta, &matrixC, &ldc, &type, &stream),
273+ "acl.blas.s8gemm args parse failed");
274+ 
275+ aclError ret = aclblasS8gemm(
276+ transA, transB, transC, m, n, k, alpha, matrixA, lda, matrixB, ldb, beta, matrixC, ldc, type, stream);
277+ return Py_BuildValue("i", ret);
278+}
279+ 
280+PyObject* WrapAclblasCreateHandleForS8gemm(PyObject* /* self */, PyObject* args)
281+{
282+ aclTransType transA = ACL_TRANS_N;
283+ aclTransType transB = ACL_TRANS_N;
284+ aclTransType transC = ACL_TRANS_N;
285+ int m = 0;
286+ int n = 0;
287+ int k = 0;
288+ aclComputeType type = ACL_COMPUTE_HIGH_PRECISION;
289+ aclopHandle* handle = nullptr;
290+ 
291+ CHECK_NULL(
292+ PyArg_ParseTuple(args, "iiiiiii", &transA, &transB, &transC, &m, &n, &k, &type),
293+ "acl.blas.create_handle_for_s8gemm args parse failed");
294+ 
295+ aclError ret = aclblasCreateHandleForS8gemm(transA, transB, transC, m, n, k, type, &handle);
296+ return Py_BuildValue("ki", reinterpret_cast<uintptr_t>(handle), ret);
297+}
@@ -0,0 +1,30 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_BLAS_FUNCS_H
12+#define WORD_BLAS_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+PyObject* WrapAclblasGemvEx(PyObject* self, PyObject* args);
18+PyObject* WrapAclblasCreateHandleForGemvEx(PyObject* self, PyObject* args);
19+PyObject* WrapAclblasHgemv(PyObject* self, PyObject* args);
20+PyObject* WrapAclblasCreateHandleForHgemv(PyObject* self, PyObject* args);
21+PyObject* WrapAclblasS8gemv(PyObject* self, PyObject* args);
22+PyObject* WrapAclblasCreateHandleForS8gemv(PyObject* self, PyObject* args);
23+PyObject* WrapAclblasGemmEx(PyObject* self, PyObject* args);
24+PyObject* WrapAclblasCreateHandleForGemmEx(PyObject* self, PyObject* args);
25+PyObject* WrapAclblasHgemm(PyObject* self, PyObject* args);
26+PyObject* WrapAclblasCreateHandleForHgemm(PyObject* self, PyObject* args);
27+PyObject* WrapAclblasS8gemm(PyObject* self, PyObject* args);
28+PyObject* WrapAclblasCreateHandleForS8gemm(PyObject* self, PyObject* args);
29+ 
30+#endif // WORD_BLAS_FUNCS_H
@@ -0,0 +1,37 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "blas.h"
12+ 
13+namespace {
14+PyMethodDef g_methodsBlas[] = {
15+ {"gemv_ex", WrapAclblasGemvEx, METH_VARARGS, "execute matrix-vector multiplication"},
16+ {"create_handle_for_gemv_ex", WrapAclblasCreateHandleForGemvEx, METH_VARARGS,
17+ "create execute matrix-vector multiplication handle"},
18+ {"hgemv", WrapAclblasHgemv, METH_VARARGS,
19+ "execute matrix-vector multiplication with input data and output type is float16"},
20+ {"create_handle_for_hgemv", WrapAclblasCreateHandleForHgemv, METH_VARARGS,
21+ "create execute matrix-vector multiplication handle of input data is float16"},
22+ {"s8gemv", WrapAclblasS8gemv, METH_VARARGS, "execute matrix-vector multiplication with input data is int8_t"},
23+ {"create_handle_for_s8gemv", WrapAclblasCreateHandleForS8gemv, METH_VARARGS,
24+ "create execute matrix-vector multiplication handle of input data is int8_t"},
25+ {"gemm_ex", WrapAclblasGemmEx, METH_VARARGS, "execute matrix-matrix multiplication"},
26+ {"create_handle_for_gemm_ex", WrapAclblasCreateHandleForGemmEx, METH_VARARGS,
27+ "create execute matrix-matrix multiplication handle"},
28+ {"hgemm", WrapAclblasHgemm, METH_VARARGS, "execute matrix-matrix input and output data type is float16"},
29+ {"create_handle_for_hgemm", WrapAclblasCreateHandleForHgemm, METH_VARARGS,
30+ "create execute matrix-matrix multiplication handle input and output data type is float16"},
31+ {"s8gemm", WrapAclblasS8gemm, METH_VARARGS, "execute matrix-matrix input data type is int8_t"},
32+ {"create_handle_for_s8gemm", WrapAclblasCreateHandleForS8gemm, METH_VARARGS,
33+ "create execute matrix-matrix multiplication handle input type is int8_t"},
34+ {nullptr, nullptr, 0, nullptr}};
35+}
36+ 
37+PyMethodDef* GetBlasMethods() { return g_methodsBlas; }
@@ -0,0 +1,18 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_PYBLAS_METHODS_CONTENT_H
12+#define WORD_PYBLAS_METHODS_CONTENT_H
13+ 
14+#include <Python.h>
15+ 
16+PyMethodDef* GetBlasMethods();
17+ 
18+#endif // WORD_PYBLAS_METHODS_CONTENT_H
@@ -0,0 +1,253 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include <acl/ops/acl_fv.h>
12+#include <acl/acl.h>
13+#include "fv_retrieval.h"
14+ 
15+PyObject* WrapAclfvCreateInitPara(PyObject* /* self */, PyObject* args)
16+{
17+ uint64_t fsNum = 0;
18+ CHECK_NULL(PyArg_ParseTuple(args, "K", &fsNum), "acl.fv.create_init_para args parse failed!");
19+ 
20+ aclfvInitPara* initPara = aclfvCreateInitPara(fsNum);
21+ return Py_BuildValue("k", reinterpret_cast<uintptr_t>(initPara));
22+}
23+ 
24+PyObject* WrapAclfvDestroyInitPara(PyObject* /* self */, PyObject* args)
25+{
26+ aclfvInitPara* initPara = nullptr;
27+ 
28+ CHECK_NULL(PyArg_ParseTuple(args, "k", &initPara), "acl.fv.destroy_init_para args parse failed!");
29+ 
30+ aclError ret = aclfvDestroyInitPara(initPara);
31+ return Py_BuildValue("i", ret);
32+}
33+ 
34+PyObject* WrapAclfvSet1NTopNum(PyObject* /* self */, PyObject* args)
35+{
36+ aclfvInitPara* initPara = nullptr;
37+ uint32_t maxTopNumFor1N = 0;
38+ CHECK_NULL(PyArg_ParseTuple(args, "kI", &initPara, &maxTopNumFor1N), "acl.fv.set_1n_top_num args parse failed!");
39+ 
40+ aclError ret = aclfvSet1NTopNum(initPara, maxTopNumFor1N);
41+ return Py_BuildValue("i", ret);
42+}
43+ 
44+PyObject* WrapAclfvSetNMTopNum(PyObject* /* self */, PyObject* args)
45+{
46+ aclfvInitPara* initPara = nullptr;
47+ uint32_t maxTopNumForNM = 0;
48+ CHECK_NULL(PyArg_ParseTuple(args, "kI", &initPara, &maxTopNumForNM), "acl.fv.set_nm_top_num args parse failed!");
49+ 
50+ aclError ret = aclfvSetNMTopNum(initPara, maxTopNumForNM);
51+ return Py_BuildValue("i", ret);
52+}
53+ 
54+PyObject* WrapAclfvInit(PyObject* /* self */, PyObject* args)
55+{
56+ aclfvInitPara* initPara = nullptr;
57+ 
58+ CHECK_NULL(PyArg_ParseTuple(args, "k", &initPara), "acl.fv.init args parse failed!");
59+ 
60+ aclError ret = aclfvInit(initPara);
61+ return Py_BuildValue("i", ret);
62+}
63+ 
64+PyObject* WrapAclfvRelease(PyObject* /* self */, PyObject* /* args */)
65+{
66+ aclError ret = aclfvRelease();
67+ return Py_BuildValue("i", ret);
68+}
69+ 
70+PyObject* WrapAclfvCreateFeatureInfo(PyObject* /* self */, PyObject* args)
71+{
72+ uint32_t id0 = 0;
73+ uint32_t id1 = 0;
74+ uint32_t offset = 0;
75+ uint32_t fLen = 0;
76+ uint32_t fCnt = 0;
77+ uint8_t* fData = nullptr;
78+ uint32_t fDataLen = 0;
79+ 
80+ CHECK_NULL(
81+ PyArg_ParseTuple(args, "IIIIIkI", &id0, &id1, &offset, &fLen, &fCnt, &fData, &fDataLen),
82+ "acl.fv.create_feature_info args parse failed!");
83+ 
84+ aclfvFeatureInfo* feature = aclfvCreateFeatureInfo(id0, id1, offset, fLen, fCnt, fData, fDataLen);
85+ return Py_BuildValue("k", reinterpret_cast<uintptr_t>(feature));
86+}
87+ 
88+PyObject* WrapAclfvDestroyFeatureInfo(PyObject* /* self */, PyObject* args)
89+{
90+ aclfvFeatureInfo* feature = nullptr;
91+ 
92+ CHECK_NULL(PyArg_ParseTuple(args, "k", &feature), "acl.fv.destroy_feature_info args parse failed!");
93+ 
94+ aclError ret = aclfvDestroyFeatureInfo(feature);
95+ return Py_BuildValue("i", ret);
96+}
97+ 
98+PyObject* WrapAclfvCreateRepoRange(PyObject* /* self */, PyObject* args)
99+{
100+ uint32_t id0min = 0;
101+ uint32_t id0max = 0;
102+ uint32_t id1min = 0;
103+ uint32_t id1max = 0;
104+ 
105+ CHECK_NULL(
106+ PyArg_ParseTuple(args, "IIII", &id0min, &id0max, &id1min, &id1max),
107+ "acl.fv.create_repo_range args parse failed!");
108+ 
109+ aclfvRepoRange* reporange = aclfvCreateRepoRange(id0min, id0max, id1min, id1max);
110+ return Py_BuildValue("k", reinterpret_cast<uintptr_t>(reporange));
111+}
112+ 
113+PyObject* WrapAclfvDestroyRepoRange(PyObject* /* self */, PyObject* args)
114+{
115+ aclfvRepoRange* reporange = nullptr;
116+ 
117+ CHECK_NULL(PyArg_ParseTuple(args, "k", &reporange), "acl.fv.destroy_repo_range args parse failed!");
118+ 
119+ aclError ret = aclfvDestroyRepoRange(reporange);
120+ return Py_BuildValue("i", ret);
121+}
122+ 
123+PyObject* WrapAclfvRepoAdd(PyObject* /* self */, PyObject* args)
124+{
125+ aclfvSearchType type = SEARCH_1_N;
126+ aclfvFeatureInfo* featureInfo = nullptr;
127+ 
128+ CHECK_NULL(PyArg_ParseTuple(args, "Ik", &type, &featureInfo), "acl.fv.repo_add args parse failed!");
129+ 
130+ aclError ret = aclfvRepoAdd(type, featureInfo);
131+ return Py_BuildValue("i", ret);
132+}
133+ 
134+PyObject* WrapAclfvRepoDel(PyObject* /* self */, PyObject* args)
135+{
136+ aclfvSearchType type = SEARCH_1_N;
137+ aclfvRepoRange* reporange = nullptr;
138+ 
139+ CHECK_NULL(PyArg_ParseTuple(args, "Ik", &type, &reporange), "acl.fv.repo_del args parse failed!");
140+ 
141+ aclError ret = aclfvRepoDel(type, reporange);
142+ return Py_BuildValue("i", ret);
143+}
144+ 
145+PyObject* WrapAclfvDel(PyObject* /* self */, PyObject* args)
146+{
147+ aclfvFeatureInfo* featureInfo = nullptr;
148+ 
149+ CHECK_NULL(PyArg_ParseTuple(args, "k", &featureInfo), "acl.fv.delete args parse failed!");
150+ 
151+ aclError ret = aclfvDel(featureInfo);
152+ return Py_BuildValue("i", ret);
153+}
154+ 
155+PyObject* WrapAclfvModify(PyObject* /* self */, PyObject* args)
156+{
157+ aclfvFeatureInfo* feature = nullptr;
158+ 
159+ CHECK_NULL(PyArg_ParseTuple(args, "k", &feature), "acl.fv.modify args parse failed!");
160+ 
161+ aclError ret = aclfvModify(feature);
162+ 
163+ return Py_BuildValue("i", ret);
164+}
165+ 
166+PyObject* WrapAclfvCreateQueryTable(PyObject* /* self */, PyObject* args)
167+{
168+ uint32_t querycnt = 0;
169+ uint32_t tablelen = 0;
170+ uint8_t* tabledata = nullptr;
171+ uint32_t tabledatalen = 0;
172+ 
173+ CHECK_NULL(
174+ PyArg_ParseTuple(args, "IIkI", &querycnt, &tablelen, &tabledata, &tabledatalen),
175+ "acl.fv.create_query_table args parse failed!");
176+ 
177+ aclfvQueryTable* querytable = aclfvCreateQueryTable(querycnt, tablelen, tabledata, tabledatalen);
178+ return Py_BuildValue("k", querytable);
179+}
180+ 
181+PyObject* WrapAclfvDestroyQueryTable(PyObject* /* self */, PyObject* args)
182+{
183+ aclfvQueryTable* querytable = nullptr;
184+ 
185+ CHECK_NULL(PyArg_ParseTuple(args, "k", &querytable), "acl.fv.destroy_query_table args parse failed!");
186+ 
187+ aclError ret = aclfvDestroyQueryTable(querytable);
188+ return Py_BuildValue("i", ret);
189+}
190+ 
191+PyObject* WrapAclfvCreateSearchInput(PyObject* /* self */, PyObject* args)
192+{
193+ aclfvQueryTable* queryTable = nullptr;
194+ aclfvRepoRange* repoRange = nullptr;
195+ uint32_t topk = 0;
196+ 
197+ CHECK_NULL(
198+ PyArg_ParseTuple(args, "kkI", &queryTable, &repoRange, &topk), "acl.fv.create_search_input args parse failed!");
199+ 
200+ aclfvSearchInput* rt = aclfvCreateSearchInput(queryTable, repoRange, topk);
201+ return Py_BuildValue("k", rt);
202+}
203+ 
204+PyObject* WrapAclfvDestroySearchInput(PyObject* /* self */, PyObject* args)
205+{
206+ aclfvSearchInput* searchInput = nullptr;
207+ 
208+ CHECK_NULL(PyArg_ParseTuple(args, "k", &searchInput), "acl.fv.destroy_search_input args parse failed!");
209+ 
210+ aclError ret = aclfvDestroySearchInput(searchInput);
211+ return Py_BuildValue("i", ret);
212+}
213+ 
214+PyObject* WrapAclfvCreateSearchResult(PyObject* /* self */, PyObject* args)
215+{
216+ uint32_t qcnt = 0;
217+ uint32_t* rtnum = nullptr;
218+ uint32_t rtdatalen = 0;
219+ uint32_t* id0 = nullptr;
220+ uint32_t* id1 = nullptr;
221+ uint32_t* rtoffset = nullptr;
222+ float* rtdist = nullptr;
223+ uint32_t datalen = 0;
224+ 
225+ CHECK_NULL(
226+ PyArg_ParseTuple(args, "IkIkkkkI", &qcnt, &rtnum, &rtdatalen, &id0, &id1, &rtoffset, &rtdist, &datalen),
227+ "acl.fv.create_search_result args parse failed!");
228+ 
229+ aclfvSearchResult* rt = aclfvCreateSearchResult(qcnt, rtnum, rtdatalen, id0, id1, rtoffset, rtdist, datalen);
230+ return Py_BuildValue("k", rt);
231+}
232+ 
233+PyObject* WrapAclfvDestroySearchResult(PyObject* /* self */, PyObject* args)
234+{
235+ aclfvSearchResult* rt = nullptr;
236+ 
237+ CHECK_NULL(PyArg_ParseTuple(args, "k", &rt), "acl.fv.destroy_search_result args parse failed!");
238+ 
239+ aclError ret = aclfvDestroySearchResult(rt);
240+ return Py_BuildValue("i", ret);
241+}
242+ 
243+PyObject* WrapAclfvSearch(PyObject* /* self */, PyObject* args)
244+{
245+ aclfvSearchType type = SEARCH_1_N;
246+ aclfvSearchInput* searchinput = nullptr;
247+ aclfvSearchResult* searchrst = nullptr;
248+ 
249+ CHECK_NULL(PyArg_ParseTuple(args, "Ikk", &type, &searchinput, &searchrst), "acl.fv.search args parse failed!");
250+ 
251+ aclError ret = aclfvSearch(type, searchinput, searchrst);
252+ return Py_BuildValue("i", ret);
253+}
@@ -0,0 +1,38 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_FV_RETRIEVAL_FUNCS_H
12+#define WORD_FV_RETRIEVAL_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+PyObject* WrapAclfvCreateInitPara(PyObject* self, PyObject* args);
18+PyObject* WrapAclfvDestroyInitPara(PyObject* self, PyObject* args);
19+PyObject* WrapAclfvSet1NTopNum(PyObject* self, PyObject* args);
20+PyObject* WrapAclfvSetNMTopNum(PyObject* self, PyObject* args);
21+PyObject* WrapAclfvInit(PyObject* self, PyObject* args);
22+PyObject* WrapAclfvRelease(PyObject* self, PyObject* args);
23+PyObject* WrapAclfvCreateFeatureInfo(PyObject* self, PyObject* args);
24+PyObject* WrapAclfvDestroyFeatureInfo(PyObject* self, PyObject* args);
25+PyObject* WrapAclfvCreateRepoRange(PyObject* self, PyObject* args);
26+PyObject* WrapAclfvDestroyRepoRange(PyObject* self, PyObject* args);
27+PyObject* WrapAclfvRepoAdd(PyObject* self, PyObject* args);
28+PyObject* WrapAclfvRepoDel(PyObject* self, PyObject* args);
29+PyObject* WrapAclfvDel(PyObject* self, PyObject* args);
30+PyObject* WrapAclfvModify(PyObject* self, PyObject* args);
31+PyObject* WrapAclfvCreateQueryTable(PyObject* self, PyObject* args);
32+PyObject* WrapAclfvDestroyQueryTable(PyObject* self, PyObject* args);
33+PyObject* WrapAclfvCreateSearchInput(PyObject* self, PyObject* args);
34+PyObject* WrapAclfvDestroySearchInput(PyObject* self, PyObject* args);
35+PyObject* WrapAclfvCreateSearchResult(PyObject* self, PyObject* args);
36+PyObject* WrapAclfvDestroySearchResult(PyObject* self, PyObject* args);
37+PyObject* WrapAclfvSearch(PyObject* self, PyObject* args);
38+#endif // WORD_FV_RETRIEVAL_FUNCS_H
@@ -0,0 +1,40 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "fv_retrieval.h"
12+ 
13+namespace {
14+PyMethodDef g_methodsFv[] = {
15+ {"create_init_para", WrapAclfvCreateInitPara, METH_VARARGS, "create init_para of feature retrieval module "},
16+ {"destory_init_para", WrapAclfvDestroyInitPara, METH_VARARGS, "destroy init_para of feature retrieval module "},
17+ {"destroy_init_para", WrapAclfvDestroyInitPara, METH_VARARGS, "destroy init_para of feature retrieval module "},
18+ {"set_1n_top_num", WrapAclfvSet1NTopNum, METH_VARARGS, "set top num of 1:N module "},
19+ {"set_nm_top_num", WrapAclfvSetNMTopNum, METH_VARARGS, "set top num of N:M module "},
20+ {"init", WrapAclfvInit, METH_VARARGS, "initialize the feature retrieval module "},
21+ {"release", WrapAclfvRelease, METH_VARARGS, "release the feature retrieval module "},
22+ {"repo_add", WrapAclfvRepoAdd, METH_VARARGS, "add Features to the base repository "},
23+ {"repo_del", WrapAclfvRepoDel, METH_VARARGS, "delete Features to the base repository "},
24+ {"create_feature_info", WrapAclfvCreateFeatureInfo, METH_VARARGS, "create the feature info "},
25+ {"destroy_feature_info", WrapAclfvDestroyFeatureInfo, METH_VARARGS, "destroy the feature info "},
26+ {"create_repo_range", WrapAclfvCreateRepoRange, METH_VARARGS, "create range to the base repository "},
27+ {"destroy_repo_range", WrapAclfvDestroyRepoRange, METH_VARARGS, "destroy range of the base repository "},
28+ {"delete", WrapAclfvDel, METH_VARARGS, "delete the feature retrieval module"},
29+ {"modify", WrapAclfvModify, METH_VARARGS, "modify the feature retrieval module"},
30+ {"create_query_table", WrapAclfvCreateQueryTable, METH_VARARGS, "create query table of retrieval module "},
31+ {"destroy_query_table", WrapAclfvDestroyQueryTable, METH_VARARGS, "destroy query table of retrieval module "},
32+ {"create_search_input", WrapAclfvCreateSearchInput, METH_VARARGS, "create search input of retrieval module "},
33+ {"destroy_search_input", WrapAclfvDestroySearchInput, METH_VARARGS, "destroy search input of retrieval module "},
34+ {"create_search_result", WrapAclfvCreateSearchResult, METH_VARARGS, "create search result of retrieval module "},
35+ {"destroy_search_result", WrapAclfvDestroySearchResult, METH_VARARGS, "destory search result of retrieval module "},
36+ {"search", WrapAclfvSearch, METH_VARARGS, "search info of retrieval module"},
37+ {nullptr, nullptr, 0, nullptr}};
38+}
39+ 
40+PyMethodDef* GetFvMethods() { return g_methodsFv; }
@@ -0,0 +1,18 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_PYFV_METHODS_CONTENT_H
12+#define WORD_PYFV_METHODS_CONTENT_H
13+ 
14+#include <Python.h>
15+ 
16+PyMethodDef* GetFvMethods();
17+ 
18+#endif // WORD_PYFV_METHODS_CONTENT_H
@@ -0,0 +1,287 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "himpi_common.h"
12+#include "acl/dvpp/hi_dvpp_sys.h"
13+ 
14+PyObject* WrapHiMpiSysInit(PyObject* /* self */, PyObject* /* args */)
15+{
16+ hi_s32 ret = hi_mpi_sys_init();
17+ return Py_BuildValue("I", ret);
18+}
19+ 
20+PyObject* WrapHiMpiSysExit(PyObject* /* self */, PyObject* /* args */)
21+{
22+ hi_s32 ret = hi_mpi_sys_exit();
23+ return Py_BuildValue("I", ret);
24+}
25+ 
26+PyObject* WrapHiMpiDvppMalloc(PyObject* /* self */, PyObject* args)
27+{
28+ hi_s32 devId = 0;
29+ hi_u64 size = 0;
30+ hi_void* devPtr = nullptr;
31+ 
32+ CHECK_NULL(PyArg_ParseTuple(args, "ik", &devId, &size), "acl.himpi.dvpp_malloc args parse failed!");
33+ 
34+ hi_s32 ret = hi_mpi_dvpp_malloc(devId, &devPtr, size);
35+ return Py_BuildValue("kI", devPtr, ret);
36+}
37+ 
38+PyObject* WrapHiMpiDvppFree(PyObject* /* self */, PyObject* args)
39+{
40+ hi_void* devPtr = nullptr;
41+ 
42+ CHECK_NULL(PyArg_ParseTuple(args, "k", &devPtr), "acl.himpi.dvpp_free args parse failed!");
43+ 
44+ hi_s32 ret = hi_mpi_dvpp_free(devPtr);
45+ return Py_BuildValue("I", ret);
46+}
47+ 
48+PyObject* WrapHiMpiDvppGetVersion(PyObject* /* self */, PyObject* /* args */)
49+{
50+ hi_s32 majorVersion = 0;
51+ hi_s32 minorVersion = 0;
52+ hi_s32 patchVersion = 0;
53+ 
54+ hi_s32 ret = hi_mpi_dvpp_get_version(&majorVersion, &minorVersion, &patchVersion);
55+ return Py_BuildValue("iiiI", majorVersion, minorVersion, patchVersion, ret);
56+}
57+ 
58+PyObject* WrapHiMpiSysCreateEpoll(PyObject* /* self */, PyObject* args)
59+{
60+ hi_s32 size = 0;
61+ hi_s32 epollFd = 0;
62+ 
63+ CHECK_NULL(PyArg_ParseTuple(args, "i", &size), "acl.himpi.sys_create_epoll args parse failed!");
64+ 
65+ hi_s32 ret = hi_mpi_sys_create_epoll(size, &epollFd);
66+ return Py_BuildValue("iI", epollFd, ret);
67+}
68+ 
69+static bool GetDvppEpollEventFromPydict(PyObject* pyDict, hi_dvpp_epoll_event& event)
70+{
71+ CHECK_STRUCT_DICT(pyDict, "the hi_dvpp_epoll_event argument is not dict");
72+ CHECK_BOOL(GetValueFromPyDict(pyDict, "events", event.events));
73+ CHECK_BOOL(GetValueFromPyDict(pyDict, "data", event.data));
74+ 
75+ return true;
76+}
77+ 
78+PyObject* WrapHiMpiSysCtlEpoll(PyObject* /* self */, PyObject* args)
79+{
80+ hi_s32 epollFd = 0;
81+ hi_s32 operation = 0;
82+ hi_s32 fd = 0;
83+ PyObject* pyEvent = nullptr;
84+ 
85+ CHECK_NULL(
86+ PyArg_ParseTuple(args, "iiiO", &epollFd, &operation, &fd, &pyEvent),
87+ "acl.himpi.sys_ctl_epoll args parse failed!");
88+ 
89+ hi_dvpp_epoll_event event{};
90+ CHECK_NULL(GetDvppEpollEventFromPydict(pyEvent, event));
91+ 
92+ hi_s32 ret = hi_mpi_sys_ctl_epoll(epollFd, operation, fd, &event);
93+ return Py_BuildValue("I", ret);
94+}
95+ 
96+static PyObject* GetPydictFromDvppEpollEvent(hi_dvpp_epoll_event& event)
97+{
98+ PyObject* pyDict = PyDict_New();
99+ CHECK_NULL(SetItemToDict(pyDict, "events", Py_BuildValue("I", event.events)));
100+ CHECK_NULL(SetItemToDict(pyDict, "data", Py_BuildValue("k", event.data)));
101+ 
102+ return pyDict;
103+}
104+ 
105+PyObject* WrapHiMpiSysWaitEpoll(PyObject* /* self */, PyObject* args)
106+{
107+ hi_s32 epollFd = 0;
108+ hi_s32 maxEvents = 0;
109+ hi_s32 timeout = 0;
110+ hi_s32 eventNum = 0;
111+ 
112+ CHECK_NULL(
113+ PyArg_ParseTuple(args, "iii", &epollFd, &maxEvents, &timeout), "acl.himpi.sys_wait_epoll args parse failed!");
114+ 
115+ const hi_s32 minLimit = 0;
116+ const hi_s32 maxLimit = 4096;
117+ CHECK_NULL(maxEvents <= maxLimit && maxEvents >= minLimit, "invalid num of maxEvents");
118+ std::vector<hi_dvpp_epoll_event> events(maxEvents + 1, hi_dvpp_epoll_event{});
119+ hi_s32 ret = hi_mpi_sys_wait_epoll(epollFd, events.data(), maxEvents, timeout, &eventNum);
120+ PyObject* pyEvents = GetPyListFromStructArray(events.data(), maxEvents, GetPydictFromDvppEpollEvent);
121+ CHECK_NULL(pyEvents != nullptr);
122+ PyObject* obj = Py_BuildValue("OiI", pyEvents, eventNum, ret);
123+ Py_XDECREF(pyEvents);
124+ return obj;
125+}
126+ 
127+PyObject* WrapHiMpiSysCloseEpoll(PyObject* /* self */, PyObject* args)
128+{
129+ hi_s32 epollFd = 0;
130+ 
131+ CHECK_NULL(PyArg_ParseTuple(args, "i", &epollFd), "acl.himpi.sys_close_epoll args parse failed!");
132+ 
133+ hi_s32 ret = hi_mpi_sys_close_epoll(epollFd);
134+ return Py_BuildValue("I", ret);
135+}
136+ 
137+static bool GetCoefficientFromPydict(PyObject* pyDict, hi_coefficient& param)
138+{
139+ CHECK_STRUCT_DICT(pyDict, "the hi_coefficient argument is not dict");
140+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r0_c0", param.csc_matrix_r0_c0));
141+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r0_c1", param.csc_matrix_r0_c1));
142+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r0_c2", param.csc_matrix_r0_c2));
143+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r1_c0", param.csc_matrix_r1_c0));
144+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r1_c1", param.csc_matrix_r1_c1));
145+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r1_c2", param.csc_matrix_r1_c2));
146+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r2_c0", param.csc_matrix_r2_c0));
147+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r2_c1", param.csc_matrix_r2_c1));
148+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_matrix_r2_c2", param.csc_matrix_r2_c2));
149+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_bias_r0", param.csc_bias_r0));
150+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_bias_r1", param.csc_bias_r1));
151+ CHECK_BOOL(GetValueFromPyDict(pyDict, "csc_bias_r2", param.csc_bias_r2));
152+ 
153+ return true;
154+}
155+ 
156+static bool GetCscCoefficientFromPydict(PyObject* pyDict, hi_csc_coefficient& param)
157+{
158+ CHECK_STRUCT_DICT(pyDict, "the hi_csc_coefficient argument is not dict");
159+ 
160+ PyObject* pyYuv = PyDict_GetItemString(pyDict, "yuv_to_rgb_coefficient");
161+ CHECK_BOOL(GetCoefficientFromPydict(pyYuv, param.yuv_to_rgb_coefficient));
162+ 
163+ PyObject* pyRgb = PyDict_GetItemString(pyDict, "rgb_to_yuv_coefficient");
164+ CHECK_BOOL(GetCoefficientFromPydict(pyRgb, param.rgb_to_yuv_coefficient));
165+ 
166+ return true;
167+}
168+ 
169+PyObject* WrapHiMpiSysSetChnCscMatrix(PyObject* /* self */, PyObject* args)
170+{
171+ hi_mod_id mode = HI_ID_CMPI;
172+ hi_s32 chn = 0;
173+ hi_csc_matrix cscMatrix = HI_CSC_MATRIX_BT601_WIDE;
174+ PyObject* pyCoefficient = nullptr;
175+ 
176+ CHECK_NULL(
177+ PyArg_ParseTuple(args, "iiiO", &mode, &chn, &cscMatrix, &pyCoefficient),
178+ "acl.himpi.sys_set_chn_csc_matrix args parse failed!");
179+ 
180+ hi_csc_coefficient cscCoefficient{};
181+ CHECK_NULL(GetCscCoefficientFromPydict(pyCoefficient, cscCoefficient));
182+ 
183+ hi_s32 ret = hi_mpi_sys_set_chn_csc_matrix(mode, chn, cscMatrix, &cscCoefficient);
184+ return Py_BuildValue("I", ret);
185+}
186+ 
187+static PyObject* GetPydictFromCoefficient(hi_coefficient param)
188+{
189+ PyObject* pyDict = PyDict_New();
190+ 
191+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r0_c0", Py_BuildValue("d", param.csc_matrix_r0_c0)));
192+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r0_c1", Py_BuildValue("d", param.csc_matrix_r0_c1)));
193+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r0_c2", Py_BuildValue("d", param.csc_matrix_r0_c2)));
194+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r1_c0", Py_BuildValue("d", param.csc_matrix_r1_c0)));
195+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r1_c1", Py_BuildValue("d", param.csc_matrix_r1_c1)));
196+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r1_c2", Py_BuildValue("d", param.csc_matrix_r1_c2)));
197+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r2_c0", Py_BuildValue("d", param.csc_matrix_r2_c0)));
198+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r2_c1", Py_BuildValue("d", param.csc_matrix_r2_c1)));
199+ CHECK_NULL(SetItemToDict(pyDict, "csc_matrix_r2_c2", Py_BuildValue("d", param.csc_matrix_r2_c2)));
200+ CHECK_NULL(SetItemToDict(pyDict, "csc_bias_r0", Py_BuildValue("d", param.csc_bias_r0)));
201+ CHECK_NULL(SetItemToDict(pyDict, "csc_bias_r1", Py_BuildValue("d", param.csc_bias_r1)));
202+ CHECK_NULL(SetItemToDict(pyDict, "csc_bias_r2", Py_BuildValue("d", param.csc_bias_r2)));
203+ 
204+ return pyDict;
205+}
206+ 
207+static PyObject* GetPydictFromCscCoefficient(hi_csc_coefficient event)
208+{
209+ PyObject* pyDict = PyDict_New();
210+ 
211+ CHECK_NULL(SetItemToDict(pyDict, "yuv_to_rgb_coefficient", GetPydictFromCoefficient(event.yuv_to_rgb_coefficient)));
212+ CHECK_NULL(SetItemToDict(pyDict, "rgb_to_yuv_coefficient", GetPydictFromCoefficient(event.rgb_to_yuv_coefficient)));
213+ 
214+ return pyDict;
215+}
216+ 
217+PyObject* WrapHiMpiSysGetChnCscMatrix(PyObject* /* self */, PyObject* args)
218+{
219+ hi_mod_id mode = HI_ID_CMPI;
220+ hi_s32 chn = 0;
221+ hi_csc_matrix cscMatrix = HI_CSC_MATRIX_BT601_WIDE;
222+ hi_csc_coefficient cscCoefficient{};
223+ 
224+ CHECK_NULL(PyArg_ParseTuple(args, "ii", &mode, &chn), "acl.himpi.sys_get_chn_csc_matrix args parse failed!");
225+ 
226+ hi_s32 ret = hi_mpi_sys_get_chn_csc_matrix(mode, chn, &cscMatrix, &cscCoefficient);
227+ PyObject* pyDict = GetPydictFromCscCoefficient(cscCoefficient);
228+ CHECK_NULL(pyDict != nullptr);
229+ PyObject* obj = Py_BuildValue("iOI", cscMatrix, pyDict, ret);
230+ Py_XDECREF(pyDict);
231+ return obj;
232+}
233+ 
234+static PyObject* GetPydictFromImgAlignInfo(hi_img_align_info& info)
235+{
236+ PyObject* pyDict = PyDict_New();
237+ const int size = 2;
238+ 
239+ CHECK_NULL(SetItemToDict(pyDict, "width_stride", Py_BuildValue("I", info.width_stride)));
240+ CHECK_NULL(SetItemToDict(pyDict, "height_stride", Py_BuildValue("I", info.height_stride)));
241+ CHECK_NULL(SetItemToDict(pyDict, "img_buf_size", Py_BuildValue("k", info.img_buf_size)));
242+ CHECK_NULL(SetItemToDict(pyDict, "reserved", GetPyListFromArray(info.reserved, size)));
243+ 
244+ return pyDict;
245+}
246+ 
247+static bool GetImgBaseInfoFromPydict(PyObject* pyDict, hi_img_base_info& info)
248+{
249+ CHECK_STRUCT_DICT(pyDict, "the hi_img_base_info argument is not dict");
250+ CHECK_BOOL(MemsetStructArgu(info));
251+ 
252+ CHECK_BOOL(GetValueFromPyDict(pyDict, "width", info.width));
253+ CHECK_BOOL(GetValueFromPyDict(pyDict, "height", info.height));
254+ CHECK_BOOL(GetEnumValueFromPyDict(pyDict, "pixel_format", info.pixel_format));
255+ 
256+ hi_u32 length = sizeof(info.reserved) / sizeof(info.reserved[0]);
257+ PyObject* pyReserved = PyDict_GetItemString(pyDict, "reserved");
258+ CHECK_BOOL(ConvertPyListToLongArray(pyReserved, length, info.reserved));
259+ return true;
260+}
261+ 
262+PyObject* WrapHiMpiSysGetImageAlignInfo(PyObject* /* self */, PyObject* args)
263+{
264+ PyObject* pyModuleType = nullptr;
265+ hi_u32 modeNum = 0;
266+ PyObject* pyImgBaseInfo = nullptr;
267+ hi_img_align_info imgAlignInfo{};
268+ 
269+ CHECK_NULL(
270+ PyArg_ParseTuple(args, "OiO", &pyModuleType, &modeNum, &pyImgBaseInfo),
271+ "acl.himpi.sys_get_image_align_info args parse failed!");
272+ 
273+ CHECK_NULL(PyList_Check(pyModuleType), "hi_module_type argument is not list");
274+ hi_u32 len = static_cast<hi_u32>(PyList_Size(pyModuleType));
275+ CHECK_NULL(len == modeNum, "the length of mode_type is not equal with mod_num!");
276+ std::vector<hi_module_type> modules(len + 1);
277+ CHECK_NULL(ConvertPyListToLongArray(pyModuleType, len, modules.data()));
278+ 
279+ hi_img_base_info imgBaseInfo{};
280+ CHECK_NULL(GetImgBaseInfoFromPydict(pyImgBaseInfo, imgBaseInfo));
281+ hi_s32 ret = hi_mpi_sys_get_image_align_info(modules.data(), modeNum, &imgBaseInfo, &imgAlignInfo);
282+ PyObject* pyDict = GetPydictFromImgAlignInfo(imgAlignInfo);
283+ CHECK_NULL(pyDict != nullptr);
284+ PyObject* obj = Py_BuildValue("OI", pyDict, ret);
285+ Py_XDECREF(pyDict);
286+ return obj;
287+}
@@ -0,0 +1,30 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_HIMPI_COMMON_FUNCS_H
12+#define WORD_HIMPI_COMMON_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+// 公共接口
18+PyObject* WrapHiMpiSysInit(PyObject* self, PyObject* args);
19+PyObject* WrapHiMpiSysExit(PyObject* self, PyObject* args);
20+PyObject* WrapHiMpiDvppMalloc(PyObject* self, PyObject* args);
21+PyObject* WrapHiMpiDvppFree(PyObject* self, PyObject* args);
22+PyObject* WrapHiMpiDvppGetVersion(PyObject* self, PyObject* args);
23+PyObject* WrapHiMpiSysCreateEpoll(PyObject* self, PyObject* args);
24+PyObject* WrapHiMpiSysCtlEpoll(PyObject* self, PyObject* args);
25+PyObject* WrapHiMpiSysWaitEpoll(PyObject* self, PyObject* args);
26+PyObject* WrapHiMpiSysCloseEpoll(PyObject* self, PyObject* args);
27+PyObject* WrapHiMpiSysSetChnCscMatrix(PyObject* self, PyObject* args);
28+PyObject* WrapHiMpiSysGetChnCscMatrix(PyObject* self, PyObject* args);
29+PyObject* WrapHiMpiSysGetImageAlignInfo(PyObject* self, PyObject* args);
30+#endif // WORD_HIMPI_COMMON_FUNCS_H
@@ -0,0 +1,164 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "himpi_pngd.h"
12+#include "acl/dvpp/hi_dvpp_pngd.h"
13+ 
14+static bool GetPngdChnAttrFromPydict(PyObject* pyDict, hi_pngd_chn_attr& attr)
15+{
16+ CHECK_STRUCT_DICT(pyDict, "the hi_pngd_chn_attr argument is not dict");
17+ CHECK_BOOL(MemsetStructArgu(attr));
18+ CHECK_BOOL(GetValueFromPyDict(pyDict, "stream_que_cnt", attr.stream_que_cnt));
19+ CHECK_BOOL(GetValueFromPyDict(pyDict, "reserved", attr.reserved, sizeof(attr.reserved) / sizeof(hi_u64)));
20+ 
21+ return true;
22+}
23+ 
24+PyObject* WrapHiMpiPngdCreateChn(PyObject* /* self */, PyObject* args)
25+{
26+ hi_pngd_chn chn = 0;
27+ PyObject* pyDict = nullptr;
28+ 
29+ CHECK_NULL(PyArg_ParseTuple(args, "iO", &chn, &pyDict), "acl.himpi.pngd_create_chn args parse failed!");
30+ 
31+ hi_pngd_chn_attr attr{};
32+ CHECK_NULL(GetPngdChnAttrFromPydict(pyDict, attr));
33+ 
34+ hi_s32 ret = hi_mpi_pngd_create_chn(chn, &attr);
35+ return Py_BuildValue("I", ret);
36+}
37+ 
38+PyObject* WrapHiMpiPngdDestroyChn(PyObject* /* self */, PyObject* args)
39+{
40+ hi_pngd_chn chn = 0;
41+ 
42+ CHECK_NULL(PyArg_ParseTuple(args, "i", &chn), "acl.himpi.pngd_destroy_chn args parse failed!");
43+ 
44+ hi_s32 ret = hi_mpi_pngd_destroy_chn(chn);
45+ return Py_BuildValue("I", ret);
46+}
47+ 
48+static bool GetPicInfoFromPydict(PyObject* pyDict, hi_pic_info& attr)
49+{
50+ CHECK_STRUCT_DICT(pyDict, "the hi_pic_info argument is not dict");
51+ CHECK_BOOL(GetValueFromPyDict(pyDict, "picture_address", attr.picture_address));
52+ CHECK_BOOL(GetValueFromPyDict(pyDict, "picture_buffer_size", attr.picture_buffer_size));
53+ CHECK_BOOL(GetValueFromPyDict(pyDict, "picture_width", attr.picture_width));
54+ CHECK_BOOL(GetValueFromPyDict(pyDict, "picture_height", attr.picture_height));
55+ CHECK_BOOL(GetValueFromPyDict(pyDict, "picture_width_stride", attr.picture_width_stride));
56+ CHECK_BOOL(GetValueFromPyDict(pyDict, "picture_height_stride", attr.picture_height_stride));
57+ CHECK_BOOL(GetEnumValueFromPyDict(pyDict, "picture_format", attr.picture_format));
58+ 
59+ return true;
60+}
61+ 
62+PyObject* WrapHiMpiPngdSendStream(PyObject* /* self */, PyObject* args)
63+{
64+ hi_pngd_chn chn = 0;
65+ PyObject* pyStream = nullptr;
66+ PyObject* pyPicInfo = nullptr;
67+ hi_s32 milliSec = 0;
68+ 
69+ CHECK_NULL(
70+ PyArg_ParseTuple(args, "iOOi", &chn, &pyStream, &pyPicInfo, &milliSec),
71+ "acl.himpi.pngd_send_stream args parse failed!");
72+ 
73+ hi_img_stream stream{};
74+ CHECK_NULL(GetImgStreamFromPydict(pyStream, stream));
75+ 
76+ hi_pic_info picInfo{};
77+ CHECK_NULL(GetPicInfoFromPydict(pyPicInfo, picInfo));
78+ 
79+ hi_s32 ret = hi_mpi_pngd_send_stream(chn, &stream, &picInfo, milliSec);
80+ return Py_BuildValue("I", ret);
81+}
82+ 
83+static PyObject* GetPydictFromPicInfo(hi_pic_info& info)
84+{
85+ PyObject* pyDict = PyDict_New();
86+ CHECK_NULL(SetItemToDict(pyDict, "picture_address", Py_BuildValue("k", info.picture_address)));
87+ CHECK_NULL(SetItemToDict(pyDict, "picture_buffer_size", Py_BuildValue("I", info.picture_buffer_size)));
88+ CHECK_NULL(SetItemToDict(pyDict, "picture_width", Py_BuildValue("I", info.picture_width)));
89+ CHECK_NULL(SetItemToDict(pyDict, "picture_height", Py_BuildValue("I", info.picture_height)));
90+ CHECK_NULL(SetItemToDict(pyDict, "picture_width_stride", Py_BuildValue("I", info.picture_width_stride)));
91+ CHECK_NULL(SetItemToDict(pyDict, "picture_height_stride", Py_BuildValue("I", info.picture_height_stride)));
92+ CHECK_NULL(SetItemToDict(pyDict, "picture_format", Py_BuildValue("i", info.picture_format)));
93+ 
94+ return pyDict;
95+}
96+ 
97+static PyObject* GetPydictFromImgStream(hi_img_stream& info)
98+{
99+ PyObject* pyDict = PyDict_New();
100+ CHECK_NULL(SetItemToDict(pyDict, "type", Py_BuildValue("i", info.type)));
101+ CHECK_NULL(SetItemToDict(pyDict, "addr", Py_BuildValue("k", info.addr)));
102+ CHECK_NULL(SetItemToDict(pyDict, "len", Py_BuildValue("I", info.len)));
103+ CHECK_NULL(SetItemToDict(pyDict, "pts", Py_BuildValue("K", info.pts)));
104+ CHECK_NULL(
105+ SetItemToDict(pyDict, "reserved", GetPyListFromArray(info.reserved, sizeof(info.reserved) / sizeof(hi_s32))));
106+ 
107+ return pyDict;
108+}
109+ 
110+PyObject* WrapHiMpiPngdGetImageData(PyObject* /* self */, PyObject* args)
111+{
112+ hi_pngd_chn chn = 0;
113+ hi_pic_info picInfo;
114+ hi_s32 milliSec = 0;
115+ 
116+ CHECK_NULL(PyArg_ParseTuple(args, "ii", &chn, &milliSec), "acl.himpi.pngd_get_image_data args parse failed!");
117+ 
118+ hi_img_stream stream{};
119+ hi_s32 ret = hi_mpi_pngd_get_image_data(chn, &picInfo, &stream, milliSec);
120+ 
121+ PyObject* pyPicInfo = GetPydictFromPicInfo(picInfo);
122+ CHECK_NULL(pyPicInfo != nullptr);
123+ PyObject* pyStream = GetPydictFromImgStream(stream);
124+ CHECK_NULL(pyStream != nullptr);
125+ PyObject* obj = Py_BuildValue("OOI", pyPicInfo, pyStream, ret);
126+ Py_XDECREF(pyPicInfo);
127+ Py_XDECREF(pyStream);
128+ 
129+ return obj;
130+}
131+ 
132+static PyObject* GetPydictFromImgInfo(hi_img_info& info)
133+{
134+ PyObject* pyDict = PyDict_New();
135+ CHECK_NULL(SetItemToDict(pyDict, "width", Py_BuildValue("I", info.width)));
136+ CHECK_NULL(SetItemToDict(pyDict, "height", Py_BuildValue("I", info.height)));
137+ CHECK_NULL(SetItemToDict(pyDict, "width_stride", Py_BuildValue("I", info.width_stride)));
138+ CHECK_NULL(SetItemToDict(pyDict, "height_stride", Py_BuildValue("I", info.height_stride)));
139+ CHECK_NULL(SetItemToDict(pyDict, "img_buf_size", Py_BuildValue("I", info.img_buf_size)));
140+ CHECK_NULL(SetItemToDict(pyDict, "pixel_format", Py_BuildValue("I", info.pixel_format)));
141+ CHECK_NULL(
142+ SetItemToDict(pyDict, "reserved", GetPyListFromArray(info.reserved, sizeof(info.reserved) / sizeof(hi_u32))));
143+ 
144+ return pyDict;
145+}
146+ 
147+PyObject* WrapHiMpiPngGetImageInfo(PyObject* /* self */, PyObject* args)
148+{
149+ PyObject* pyStream = nullptr;
150+ 
151+ CHECK_NULL(PyArg_ParseTuple(args, "O", &pyStream), "acl.himpi.png_get_image_info args parse failed!");
152+ 
153+ hi_img_stream stream{};
154+ CHECK_NULL(GetImgStreamFromPydict(pyStream, stream));
155+ 
156+ hi_img_info imgInfo{};
157+ hi_s32 ret = hi_mpi_png_get_image_info(&stream, &imgInfo);
158+ PyObject* pyImgInfo = GetPydictFromImgInfo(imgInfo);
159+ CHECK_NULL(pyImgInfo != nullptr);
160+ PyObject* obj = Py_BuildValue("OI", pyImgInfo, ret);
161+ Py_XDECREF(pyImgInfo);
162+ 
163+ return obj;
164+}
@@ -0,0 +1,24 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_HIMPI_PNGD_FUNCS_H
12+#define WORD_HIMPI_PNGD_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+// pngd图像解码
18+PyObject* WrapHiMpiPngdCreateChn(PyObject* self, PyObject* args);
19+PyObject* WrapHiMpiPngdDestroyChn(PyObject* self, PyObject* args);
20+PyObject* WrapHiMpiPngdSendStream(PyObject* self, PyObject* args);
21+PyObject* WrapHiMpiPngdGetImageData(PyObject* self, PyObject* args);
22+PyObject* WrapHiMpiPngGetImageInfo(PyObject* self, PyObject* args);
23+ 
24+#endif // WORD_HIMPI_PNGD_FUNCS_H
@@ -0,0 +1,42 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_HIMPI_VDEC_FUNCS_H
12+#define WORD_HIMPI_VDEC_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+// 视频、图像解码
18+PyObject* WrapHiMpiVdecCreateChn(PyObject* self, PyObject* args);
19+PyObject* WrapHiMpiVdecDestroyChn(PyObject* self, PyObject* args);
20+PyObject* WrapHiMpiVdecGetChnAttr(PyObject* self, PyObject* args);
21+PyObject* WrapHiMpiVdecSetChnAttr(PyObject* self, PyObject* args);
22+PyObject* WrapHiMpiVdecStartRecvStream(PyObject* self, PyObject* args);
23+PyObject* WrapHiMpiVdecStopRecvStream(PyObject* self, PyObject* args);
24+PyObject* WrapHiMpiVdecQueryStatus(PyObject* self, PyObject* args);
25+PyObject* WrapHiMpiVdecResetChn(PyObject* self, PyObject* args);
26+PyObject* WrapHiMpiVdecSetChnParam(PyObject* self, PyObject* args);
27+PyObject* WrapHiMpiVdecGetChnParam(PyObject* self, PyObject* args);
28+PyObject* WrapHiMpiVdecSetProtocolParam(PyObject* self, PyObject* args);
29+PyObject* WrapHiMpiVdecGetProtocolParam(PyObject* self, PyObject* args);
30+PyObject* WrapHiMpiVdecSendStream(PyObject* self, PyObject* args);
31+PyObject* WrapHiMpiVdecGetFrame(PyObject* self, PyObject* args);
32+PyObject* WrapHiMpiVdecReleaseFrame(PyObject* self, PyObject* args);
33+PyObject* WrapHiMpiVdecGetFd(PyObject* self, PyObject* args);
34+PyObject* WrapHiMpiVdecCloseFd(PyObject* self, PyObject* args);
35+PyObject* WrapHiMpiVdecGetPicBufSize(PyObject* self, PyObject* args);
36+PyObject* WrapHiMpiVdecGetTmvBufSize(PyObject* self, PyObject* args);
37+PyObject* WrapHiMpiDvppGetImageInfo(PyObject* self, PyObject* args);
38+PyObject* WrapHiMpiVdecSetJpegdPrecisionMode(PyObject* self, PyObject* args);
39+PyObject* WrapHiMpiVdecGetJpegdOutputInfo(PyObject* self, PyObject* args);
40+PyObject* WrapHiMpiVdecSetDisplayMode(PyObject* self, PyObject* args);
41+PyObject* WrapHiMpiVdecGetDisplayMode(PyObject* self, PyObject* args);
42+#endif // WORD_HIMPI_VDEC_FUNCS_H
@@ -0,0 +1,202 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_HIMPI_VENC_FUNCS_H
12+#define WORD_HIMPI_VENC_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+// 视频、图像解码
18+PyObject* WrapHiMpiVencCreateChn(PyObject* self, PyObject* args);
19+PyObject* WrapHiMpiVencDestroyChn(PyObject* self, PyObject* args);
20+PyObject* WrapHiMpiVencStartChn(PyObject* self, PyObject* args);
21+PyObject* WrapHiMpiVencStopChn(PyObject* self, PyObject* args);
22+PyObject* WrapHiMpiVencQueryStatus(PyObject* self, PyObject* args);
23+PyObject* WrapHiMpiVencGetStream(PyObject* self, PyObject* args);
24+PyObject* WrapHiMpiVencReleaseStream(PyObject* self, PyObject* args);
25+PyObject* WrapHiMpiVencSendFrame(PyObject* self, PyObject* args);
26+PyObject* WrapHiMpiVencSendFrameEx(PyObject* self, PyObject* args);
27+PyObject* WrapHiMpiVencSetModParam(PyObject* self, PyObject* args);
28+PyObject* WrapHiMpiVencGetModParam(PyObject* self, PyObject* args);
29+PyObject* WrapHiMpiVencRequestIdr(PyObject* self, PyObject* args);
30+PyObject* WrapHiMpiVencGetFd(PyObject* self, PyObject* args);
31+PyObject* WrapHiMpiVencCloseFd(PyObject* self, PyObject* args);
32+PyObject* WrapHiMpiVencSetJpegParam(PyObject* self, PyObject* args);
33+PyObject* WrapHiMpiVencGetJpegParam(PyObject* self, PyObject* args);
34+PyObject* WrapHiMpiVencSetChnParam(PyObject* self, PyObject* args);
35+PyObject* WrapHiMpiVencGetChnParam(PyObject* self, PyObject* args);
36+PyObject* WrapHiMpiVencGetChnAttr(PyObject* self, PyObject* args);
37+PyObject* WrapHiMpiVencSetChnAttr(PyObject* self, PyObject* args);
38+ 
39+PyObject* WrapHiMpiVencSetSceneMode(PyObject* self, PyObject* args);
40+PyObject* WrapHiMpiVencGetSceneMode(PyObject* self, PyObject* args);
41+ 
42+PyObject* WrapHiMpiVencSetRcParam(PyObject* self, PyObject* args);
43+PyObject* WrapHiMpiVencGetRcParam(PyObject* self, PyObject* args);
44+PyObject* WrapHiMpiVencSetJpegHuffmanParam(PyObject* self, PyObject* args);
45+PyObject* WrapHiMpiVencGetJpegHuffmanParam(PyObject* self, PyObject* args);
46+PyObject* WrapHiMpiVencCompactJpegTables(PyObject* self, PyObject* args);
47+PyObject* WrapHiMpiVencSendJpegeFrame(PyObject* self, PyObject* args);
48+PyObject* WrapHiMpiVencGetJpegePredictedSize(PyObject* self, PyObject* args);
49+ 
50+PyObject* WrapHiMpiVencSetCuPred(PyObject* self, PyObject* args);
51+PyObject* WrapHiMpiVencGetCuPred(PyObject* self, PyObject* args);
52+ 
53+PyObject* WrapHiMpiVencSetH264Vui(PyObject* self, PyObject* args);
54+PyObject* WrapHiMpiVencGetH264Vui(PyObject* self, PyObject* args);
55+PyObject* WrapHiMpiVencSetH265Vui(PyObject* self, PyObject* args);
56+PyObject* WrapHiMpiVencGetH265Vui(PyObject* self, PyObject* args);
57+ 
58+PyObject* WrapHiMpiVencSetIntraRefresh(PyObject* self, PyObject* args);
59+PyObject* WrapHiMpiVencGetIntraRefresh(PyObject* self, PyObject* args);
60+ 
61+PyObject* WrapHiMpiVencSetRefParam(PyObject* self, PyObject* args);
62+PyObject* WrapHiMpiVencGetRefParam(PyObject* self, PyObject* args);
63+ 
64+PyObject* WrapHiMpiVencSetRoiAttr(PyObject* self, PyObject* args);
65+PyObject* WrapHiMpiVencGetRoiAttr(PyObject* self, PyObject* args);
66+ 
67+PyObject* WrapHiMpiVencSetSliceSplit(PyObject* self, PyObject* args);
68+PyObject* WrapHiMpiVencGetSliceSplit(PyObject* self, PyObject* args);
69+ 
70+PyObject* WrapHiMpiVencGetQpmapStride(PyObject* self, PyObject* args);
71+PyObject* WrapHiMpiVencGetQpmapSize(PyObject* self, PyObject* args);
72+ 
73+PyObject* WrapHiMpiVencSetStreamcopyParam(PyObject* self, PyObject* args);
74+PyObject* WrapHiMpiVencGetStreamcopyParam(PyObject* self, PyObject* args);
75+ 
76+template <typename T>
77+bool GetVencH26ModParamFromPydict(PyObject* pyDict, T& param)
78+{
79+ if ((pyDict) == nullptr) {
80+ return true;
81+ } else if (PyDict_Check(pyDict) == false) {
82+ PyErr_SetString(PyExc_TypeError, "the venc h25 mod param is not dict");
83+ return false;
84+ }
85+ 
86+ GetValueFromPyDict(pyDict, "one_stream_buf", param.one_stream_buf);
87+ GetValueFromPyDict(pyDict, "mini_buf_mode", param.mini_buf_mode);
88+ GetValueFromPyDict(pyDict, "low_power_mode", param.low_power_mode);
89+ GetEnumValueFromPyDict(pyDict, "vb_src", param.vb_src);
90+ GetEnumValueFromPyDict(pyDict, "qp_hist_en", param.qp_hist_en);
91+ GetValueFromPyDict(pyDict, "max_user_data_len", param.max_user_data_len);
92+ 
93+ return true;
94+}
95+ 
96+template <typename T>
97+bool GetVencCbrFromPydict(PyObject* pyDict, T& attr)
98+{
99+ if (pyDict == nullptr || PyDict_Check(pyDict) == 0) {
100+ PyErr_SetString(PyExc_TypeError, "the venc cbr argument is not dict");
101+ return false;
102+ }
103+ 
104+ GetValueFromPyDict(pyDict, "gop", attr.gop);
105+ GetValueFromPyDict(pyDict, "stats_time", attr.stats_time);
106+ GetValueFromPyDict(pyDict, "src_frame_rate", attr.src_frame_rate);
107+ GetValueFromPyDict(pyDict, "dst_frame_rate", attr.dst_frame_rate);
108+ GetValueFromPyDict(pyDict, "bit_rate", attr.bit_rate);
109+ 
110+ return true;
111+}
112+ 
113+template <typename T>
114+bool GetVencVbrFromPydict(PyObject* pyDict, T& attr)
115+{
116+ if (pyDict == nullptr || PyDict_Check(pyDict) == 0) {
117+ PyErr_SetString(PyExc_TypeError, "the venc vbr argument is not dict");
118+ return false;
119+ }
120+ 
121+ GetValueFromPyDict(pyDict, "gop", attr.gop);
122+ GetValueFromPyDict(pyDict, "stats_time", attr.stats_time);
123+ GetValueFromPyDict(pyDict, "src_frame_rate", attr.src_frame_rate);
124+ GetValueFromPyDict(pyDict, "dst_frame_rate", attr.dst_frame_rate);
125+ GetValueFromPyDict(pyDict, "max_bit_rate", attr.max_bit_rate);
126+ 
127+ return true;
128+}
129+ 
130+template <typename T>
131+bool GetVencAVbrFromPydict(PyObject* pyDict, T& attr)
132+{
133+ if (pyDict == nullptr || PyDict_Check(pyDict) == 0) {
134+ PyErr_SetString(PyExc_TypeError, "the venc avbr argument is not dict");
135+ return false;
136+ }
137+ 
138+ GetValueFromPyDict(pyDict, "gop", attr.gop);
139+ GetValueFromPyDict(pyDict, "stats_time", attr.stats_time);
140+ GetValueFromPyDict(pyDict, "src_frame_rate", attr.src_frame_rate);
141+ GetValueFromPyDict(pyDict, "dst_frame_rate", attr.dst_frame_rate);
142+ GetValueFromPyDict(pyDict, "max_bit_rate", attr.max_bit_rate);
143+ 
144+ return true;
145+}
146+ 
147+template <typename T>
148+bool GetVencQVbrFromPydict(PyObject* pyDict, T& attr)
149+{
150+ if (pyDict == nullptr || PyDict_Check(pyDict) == 0) {
151+ PyErr_SetString(PyExc_TypeError, "the venc qvbr argument is not dict");
152+ return false;
153+ }
154+ 
155+ GetValueFromPyDict(pyDict, "gop", attr.gop);
156+ GetValueFromPyDict(pyDict, "stats_time", attr.stats_time);
157+ GetValueFromPyDict(pyDict, "src_frame_rate", attr.src_frame_rate);
158+ GetValueFromPyDict(pyDict, "dst_frame_rate", attr.dst_frame_rate);
159+ GetValueFromPyDict(pyDict, "target_bit_rate", attr.target_bit_rate);
160+ 
161+ return true;
162+}
163+ 
164+template <typename T>
165+bool GetVencCVbrFromPydict(PyObject* pyDict, T& attr)
166+{
167+ if (pyDict == nullptr || PyDict_Check(pyDict) == 0) {
168+ PyErr_SetString(PyExc_TypeError, "the venc cvbr argument is not dict");
169+ return false;
170+ }
171+ 
172+ GetValueFromPyDict(pyDict, "gop", attr.gop);
173+ GetValueFromPyDict(pyDict, "stats_time", attr.stats_time);
174+ GetValueFromPyDict(pyDict, "src_frame_rate", attr.src_frame_rate);
175+ GetValueFromPyDict(pyDict, "dst_frame_rate", attr.dst_frame_rate);
176+ GetValueFromPyDict(pyDict, "max_bit_rate", attr.max_bit_rate);
177+ GetValueFromPyDict(pyDict, "short_term_stats_time", attr.short_term_stats_time);
178+ GetValueFromPyDict(pyDict, "long_term_stats_time", attr.long_term_stats_time);
179+ GetValueFromPyDict(pyDict, "long_term_max_bit_rate", attr.long_term_max_bit_rate);
180+ GetValueFromPyDict(pyDict, "long_term_min_bit_rate", attr.long_term_min_bit_rate);
181+ 
182+ return true;
183+}
184+ 
185+template <typename T>
186+bool GetVencFixqpFromPydict(PyObject* pyDict, T& attr)
187+{
188+ if (pyDict == nullptr || PyDict_Check(pyDict) == 0) {
189+ PyErr_SetString(PyExc_TypeError, "the venc fixqp argument is not dict");
190+ return false;
191+ }
192+ 
193+ GetValueFromPyDict(pyDict, "gop", attr.gop);
194+ GetValueFromPyDict(pyDict, "src_frame_rate", attr.src_frame_rate);
195+ GetValueFromPyDict(pyDict, "dst_frame_rate", attr.dst_frame_rate);
196+ GetValueFromPyDict(pyDict, "i_qp", attr.i_qp);
197+ GetValueFromPyDict(pyDict, "p_qp", attr.p_qp);
198+ GetValueFromPyDict(pyDict, "b_qp", attr.b_qp);
199+ 
200+ return true;
201+}
202+#endif // WORD_HIMPI_VENC_FUNCS_H
@@ -0,0 +1,60 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_HIMPI_VPC_FUNCS_H
12+#define WORD_HIMPI_VPC_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+// 视频、图像解码
18+PyObject* WrapHiMpiVpcCreateChn(PyObject* self, PyObject* args);
19+PyObject* WrapHiMpiVpcDestroyChn(PyObject* self, PyObject* args);
20+PyObject* WrapHiMpiVpcResize(PyObject* self, PyObject* args);
21+PyObject* WrapHiMpiVpcCrop(PyObject* self, PyObject* args);
22+PyObject* WrapHiMpiVpcCropResize(PyObject* self, PyObject* args);
23+PyObject* WrapHiMpiVpcCropResizePaste(PyObject* self, PyObject* args);
24+PyObject* WrapHiMpiVpcConvertColor(PyObject* self, PyObject* args);
25+PyObject* WrapHiMpiVpcConvertColorV2(PyObject* self, PyObject* args);
26+PyObject* WrapHiMpiVpcConvertColorToYuv420(PyObject* self, PyObject* args);
27+PyObject* WrapHiMpiVpcCopyMakeBorder(PyObject* self, PyObject* args);
28+PyObject* WrapHiMpiVpcPyrdown(PyObject* self, PyObject* args);
29+PyObject* WrapHiMpiVpcCalcHist(PyObject* self, PyObject* args);
30+PyObject* WrapHiMpiVpcCalcHistV2(PyObject* self, PyObject* args);
31+PyObject* WrapHiMpiVpcEqualizeHist(PyObject* self, PyObject* args);
32+PyObject* WrapHiMpiVpcGetProcessResult(PyObject* self, PyObject* args);
33+PyObject* WrapHiMpiVpcSysCreateChn(PyObject* self, PyObject* args);
34+PyObject* WrapHiMpiVpcCropResizeMakeBorder(PyObject* self, PyObject* args);
35+PyObject* WrapHiMpiVpcBatchCropResizePaste(PyObject* self, PyObject* args);
36+PyObject* WrapHiMpiVpcBatchCropResizeMakeBorder(PyObject* self, PyObject* args);
37+PyObject* WrapHiMpiVpcCropResizeResizePaste(PyObject* self, PyObject* args);
38+PyObject* WrapHiMpiVpcDilate(PyObject* self, PyObject* args);
39+PyObject* WrapHiMpiVpcDrawCover(PyObject* self, PyObject* args);
40+PyObject* WrapHiMpiVpcDrawLine(PyObject* self, PyObject* args);
41+PyObject* WrapHiMpiVpcDrawMosaic(PyObject* self, PyObject* args);
42+PyObject* WrapHiMpiVpcDrawOsd(PyObject* self, PyObject* args);
43+PyObject* WrapHiMpiVpcErode(PyObject* self, PyObject* args);
44+PyObject* WrapHiMpiVpcFilter2d(PyObject* self, PyObject* args);
45+PyObject* WrapHiMpiVpcFlip(PyObject* self, PyObject* args);
46+PyObject* WrapHiMpiVpcGetAffineLut(PyObject* self, PyObject* args);
47+PyObject* WrapHiMpiVpcGetLutMemSize(PyObject* self, PyObject* args);
48+PyObject* WrapHiMpiVpcGetAffineTransform(PyObject* self, PyObject* args);
49+PyObject* WrapHiMpiVpcGetPerspectiveLut(PyObject* self, PyObject* args);
50+PyObject* WrapHiMpiVpcGetRemapLut(PyObject* self, PyObject* args);
51+PyObject* WrapHiMpiVpcGetRotationMatrix(PyObject* self, PyObject* args);
52+PyObject* WrapHiMpiVpcLutRemap(PyObject* self, PyObject* args);
53+PyObject* WrapHiMpiVpcSetChnWorkspace(PyObject* self, PyObject* args);
54+PyObject* WrapHiMpiVpcMedianBlur(PyObject* self, PyObject* args);
55+PyObject* WrapHiMpiVpcRotate(PyObject* self, PyObject* args);
56+PyObject* WrapHiMpiVpcWarpAffine(PyObject* self, PyObject* args);
57+PyObject* WrapHiMpiVpcBlur(PyObject* self, PyObject* args);
58+PyObject* WrapHiMpiVpcGaussianBlur(PyObject* self, PyObject* args);
59+PyObject* WrapHiMpiVpcSetChnOptAttr(PyObject* self, PyObject* args);
60+#endif // WORD_HIMPI_VPC_FUNCS_H
@@ -0,0 +1,164 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "himpi_common.h"
12+#include "himpi_vdec.h"
13+#include "himpi_venc.h"
14+#include "himpi_vpc.h"
15+#include "himpi_pngd.h"
16+ 
17+namespace {
18+PyMethodDef g_methodsHimpi[] = {
19+ // 公共模块接口
20+ {"sys_init", WrapHiMpiSysInit, METH_VARARGS, "sys init"},
21+ {"sys_exit", WrapHiMpiSysExit, METH_VARARGS, "sys exit"},
22+ {"dvpp_malloc", WrapHiMpiDvppMalloc, METH_VARARGS, "dvpp malloc"},
23+ {"dvpp_free", WrapHiMpiDvppFree, METH_VARARGS, "dvpp free"},
24+ {"dvpp_get_version", WrapHiMpiDvppGetVersion, METH_VARARGS, "dvpp get version"},
25+ {"sys_create_epoll", WrapHiMpiSysCreateEpoll, METH_VARARGS, "sys create epoll"},
26+ {"sys_ctl_epoll", WrapHiMpiSysCtlEpoll, METH_VARARGS, "sys ctl epoll"},
27+ {"sys_wait_epoll", WrapHiMpiSysWaitEpoll, METH_VARARGS, "sys wait epoll"},
28+ {"sys_close_epoll", WrapHiMpiSysCloseEpoll, METH_VARARGS, "sys close epoll"},
29+ {"sys_set_chn_csc_matrix", WrapHiMpiSysSetChnCscMatrix, METH_VARARGS, "sys set chn csc matrix"},
30+ {"sys_get_chn_csc_matrix", WrapHiMpiSysGetChnCscMatrix, METH_VARARGS, "sys get chn csc matrix"},
31+ {"sys_get_image_align_info", WrapHiMpiSysGetImageAlignInfo, METH_VARARGS, "sys get image align info"},
32+ 
33+ // 视频、图像解码接口
34+ {"vdec_create_chn", WrapHiMpiVdecCreateChn, METH_VARARGS, "vdec create chn"},
35+ {"vdec_destroy_chn", WrapHiMpiVdecDestroyChn, METH_VARARGS, "vdec destroy chn"},
36+ {"vdec_get_chn_attr", WrapHiMpiVdecGetChnAttr, METH_VARARGS, "vdec get chn attr"},
37+ {"vdec_set_chn_attr", WrapHiMpiVdecSetChnAttr, METH_VARARGS, "vdec set chn attr"},
38+ {"vdec_start_recv_stream", WrapHiMpiVdecStartRecvStream, METH_VARARGS, "vdec start recv stream"},
39+ {"vdec_stop_recv_stream", WrapHiMpiVdecStopRecvStream, METH_VARARGS, "vdec stop recv stream"},
40+ {"vdec_query_status", WrapHiMpiVdecQueryStatus, METH_VARARGS, "vdec query status"},
41+ {"vdec_reset_chn", WrapHiMpiVdecResetChn, METH_VARARGS, "vdec reset chn"},
42+ {"vdec_set_chn_param", WrapHiMpiVdecSetChnParam, METH_VARARGS, "vdec set chn param"},
43+ {"vdec_get_chn_param", WrapHiMpiVdecGetChnParam, METH_VARARGS, "vdec get chn param"},
44+ {"vdec_set_protocol_param", WrapHiMpiVdecSetProtocolParam, METH_VARARGS, "vdec set protocol param"},
45+ {"vdec_get_protocol_param", WrapHiMpiVdecGetProtocolParam, METH_VARARGS, "vdec get protocol param"},
46+ {"vdec_send_stream", WrapHiMpiVdecSendStream, METH_VARARGS, "vdec send stream"},
47+ {"vdec_get_frame", WrapHiMpiVdecGetFrame, METH_VARARGS, "vdec get frame"},
48+ {"vdec_release_frame", WrapHiMpiVdecReleaseFrame, METH_VARARGS, "vdec release frame"},
49+ {"vdec_get_fd", WrapHiMpiVdecGetFd, METH_VARARGS, "vdec get fd"},
50+ {"vdec_close_fd", WrapHiMpiVdecCloseFd, METH_VARARGS, "vdec close fd"},
51+ {"vdec_get_pic_buf_size", WrapHiMpiVdecGetPicBufSize, METH_VARARGS, "vdec get pic buf size"},
52+ {"vdec_get_tmv_buf_size", WrapHiMpiVdecGetTmvBufSize, METH_VARARGS, "vdec get tvm buf size"},
53+ {"dvpp_get_image_info", WrapHiMpiDvppGetImageInfo, METH_VARARGS, "dvpp get image info"},
54+ {"vdec_set_jpegd_precision_mode", WrapHiMpiVdecSetJpegdPrecisionMode, METH_VARARGS,
55+ "vdec set jpegd precision mode"},
56+ {"vdec_get_jpegd_output_info", WrapHiMpiVdecGetJpegdOutputInfo, METH_VARARGS, "vdec get jpegd output info"},
57+ {"vdec_set_display_mode", WrapHiMpiVdecSetDisplayMode, METH_VARARGS, "vdec set display mode"},
58+ {"vdec_get_display_mode", WrapHiMpiVdecGetDisplayMode, METH_VARARGS, "vdec get display mode"},
59+ 
60+ // 视频、图像编码接口
61+ {"venc_create_chn", WrapHiMpiVencCreateChn, METH_VARARGS, "venc create chn"},
62+ {"venc_destroy_chn", WrapHiMpiVencDestroyChn, METH_VARARGS, "venc destroy chn"},
63+ {"venc_start_chn", WrapHiMpiVencStartChn, METH_VARARGS, "venc start chn"},
64+ {"venc_stop_chn", WrapHiMpiVencStopChn, METH_VARARGS, "venc stop chn"},
65+ {"venc_query_status", WrapHiMpiVencQueryStatus, METH_VARARGS, "venc query status"},
66+ {"venc_get_stream", WrapHiMpiVencGetStream, METH_VARARGS, "venc get stream"},
67+ {"venc_release_stream", WrapHiMpiVencReleaseStream, METH_VARARGS, "venc release stream"},
68+ {"venc_send_frame", WrapHiMpiVencSendFrame, METH_VARARGS, "venc send frame"},
69+ {"venc_send_frame_ex", WrapHiMpiVencSendFrameEx, METH_VARARGS, "venc send frame ex"},
70+ {"venc_set_mod_param", WrapHiMpiVencSetModParam, METH_VARARGS, "venc set mod param"},
71+ {"venc_get_mod_param", WrapHiMpiVencGetModParam, METH_VARARGS, "venc get mod param"},
72+ {"venc_request_idr", WrapHiMpiVencRequestIdr, METH_VARARGS, "venc request idr"},
73+ {"venc_get_fd", WrapHiMpiVencGetFd, METH_VARARGS, "venc get fd"},
74+ {"venc_close_fd", WrapHiMpiVencCloseFd, METH_VARARGS, "venc close fd"},
75+ {"venc_set_jpeg_param", WrapHiMpiVencSetJpegParam, METH_VARARGS, "venc set jpeg param"},
76+ {"venc_get_jpeg_param", WrapHiMpiVencGetJpegParam, METH_VARARGS, "venc get jpeg param"},
77+ {"venc_set_chn_param", WrapHiMpiVencSetChnParam, METH_VARARGS, "venc set chn param"},
78+ {"venc_get_chn_param", WrapHiMpiVencGetChnParam, METH_VARARGS, "venc get chn param"},
79+ {"venc_set_chn_attr", WrapHiMpiVencSetChnAttr, METH_VARARGS, "venc set chn attr"},
80+ {"venc_get_chn_attr", WrapHiMpiVencGetChnAttr, METH_VARARGS, "venc get chn attr"},
81+ {"venc_set_scene_mode", WrapHiMpiVencSetSceneMode, METH_VARARGS, "venc set scene mode"},
82+ {"venc_set_rc_param", WrapHiMpiVencSetRcParam, METH_VARARGS, "venc set rc param"},
83+ {"venc_get_rc_param", WrapHiMpiVencGetRcParam, METH_VARARGS, "venc get rc param"},
84+ {"venc_set_jpeg_huffman_param", WrapHiMpiVencSetJpegHuffmanParam, METH_VARARGS, "venc set jpeg huffman param"},
85+ {"venc_get_jpeg_huffman_param", WrapHiMpiVencGetJpegHuffmanParam, METH_VARARGS, "venc get jpeg huffman param"},
86+ {"venc_compact_jpeg_tables", WrapHiMpiVencCompactJpegTables, METH_VARARGS, "venc compact jpeg tables"},
87+ {"venc_send_jpege_frame", WrapHiMpiVencSendJpegeFrame, METH_VARARGS, "venc send jpege frame"},
88+ {"venc_get_jpege_predicted_size", WrapHiMpiVencGetJpegePredictedSize, METH_VARARGS,
89+ "venc get jpege predicted size"},
90+ {"venc_get_scene_mode", WrapHiMpiVencGetSceneMode, METH_VARARGS, "venc get scene mode"},
91+ {"venc_set_cu_pred", WrapHiMpiVencSetCuPred, METH_VARARGS, "venc set cu pred"},
92+ {"venc_get_cu_pred", WrapHiMpiVencGetCuPred, METH_VARARGS, "venc get cu pred"},
93+ {"venc_set_h264_vui", WrapHiMpiVencSetH264Vui, METH_VARARGS, "venc set h264 vui"},
94+ {"venc_get_h264_vui", WrapHiMpiVencGetH264Vui, METH_VARARGS, "venc get h264 vui"},
95+ {"venc_set_h265_vui", WrapHiMpiVencSetH265Vui, METH_VARARGS, "venc set h265 vui"},
96+ {"venc_get_h265_vui", WrapHiMpiVencGetH265Vui, METH_VARARGS, "venc get h265 vui"},
97+ {"venc_set_intra_refresh", WrapHiMpiVencSetIntraRefresh, METH_VARARGS, "venc venc set intra refresh"},
98+ {"venc_get_intra_refresh", WrapHiMpiVencGetIntraRefresh, METH_VARARGS, "venc get intra refresh"},
99+ {"venc_set_ref_param", WrapHiMpiVencSetRefParam, METH_VARARGS, "venc set ref param"},
100+ {"venc_get_ref_param", WrapHiMpiVencGetRefParam, METH_VARARGS, "venc get ref param"},
101+ {"venc_set_roi_attr", WrapHiMpiVencSetRoiAttr, METH_VARARGS, "venc set roi attr"},
102+ {"venc_get_roi_attr", WrapHiMpiVencGetRoiAttr, METH_VARARGS, "venc get roi attr"},
103+ {"venc_set_slice_split", WrapHiMpiVencSetSliceSplit, METH_VARARGS, "venc set slice split"},
104+ {"venc_get_slice_split", WrapHiMpiVencGetSliceSplit, METH_VARARGS, "venc get slice split"},
105+ {"venc_get_qpmap_stride", WrapHiMpiVencGetQpmapStride, METH_VARARGS, "venc get qpmap stride"},
106+ {"venc_get_qpmap_size", WrapHiMpiVencGetQpmapSize, METH_VARARGS, "venc get qpmap size"},
107+ {"venc_set_streamcopy_param", WrapHiMpiVencSetStreamcopyParam, METH_VARARGS, "venc set streamcopy param"},
108+ {"venc_get_streamcopy_param", WrapHiMpiVencGetStreamcopyParam, METH_VARARGS, "venc get streamcopy param"},
109+ 
110+ // 图像处理接口
111+ {"vpc_create_chn", WrapHiMpiVpcCreateChn, METH_VARARGS, "vpc create chn"},
112+ {"vpc_destroy_chn", WrapHiMpiVpcDestroyChn, METH_VARARGS, "vpc destroy chn"},
113+ {"vpc_resize", WrapHiMpiVpcResize, METH_VARARGS, "vpc resize"},
114+ {"vpc_crop", WrapHiMpiVpcCrop, METH_VARARGS, "vpc crop"},
115+ {"vpc_crop_resize", WrapHiMpiVpcCropResize, METH_VARARGS, "vpc crop resize"},
116+ {"vpc_crop_resize_paste", WrapHiMpiVpcCropResizePaste, METH_VARARGS, "vpc cropc resize paste"},
117+ {"vpc_convert_color", WrapHiMpiVpcConvertColor, METH_VARARGS, "vpc convert color"},
118+ {"vpc_convert_color_v2", WrapHiMpiVpcConvertColorV2, METH_VARARGS, "vpc convert color v2"},
119+ {"vpc_convert_color_to_yuv420", WrapHiMpiVpcConvertColorToYuv420, METH_VARARGS, "vpc convert color to yuv420"},
120+ {"vpc_copy_make_border", WrapHiMpiVpcCopyMakeBorder, METH_VARARGS, "vpc copy make border"},
121+ {"vpc_pyrdown", WrapHiMpiVpcPyrdown, METH_VARARGS, "vpc pyrdown"},
122+ {"vpc_calc_hist", WrapHiMpiVpcCalcHist, METH_VARARGS, "vpc calc hist"},
123+ {"vpc_calc_hist_v2", WrapHiMpiVpcCalcHistV2, METH_VARARGS, "vpc calc hist v2"},
124+ {"vpc_equalize_hist", WrapHiMpiVpcEqualizeHist, METH_VARARGS, "vpc equalize hist"},
125+ {"vpc_get_process_result", WrapHiMpiVpcGetProcessResult, METH_VARARGS, "vpc get process result"},
126+ {"vpc_sys_create_chn", WrapHiMpiVpcSysCreateChn, METH_VARARGS, "vpc sys create chn"},
127+ {"vpc_crop_resize_make_border", WrapHiMpiVpcCropResizeMakeBorder, METH_VARARGS, "vpc crop resize make border"},
128+ {"vpc_batch_crop_resize_paste", WrapHiMpiVpcBatchCropResizePaste, METH_VARARGS, "vpc batch crop resize paste"},
129+ {"vpc_batch_crop_resize_make_border", WrapHiMpiVpcBatchCropResizeMakeBorder, METH_VARARGS,
130+ "vpc batch crop resize make border"},
131+ {"vpc_crop_resize_resize_paste", WrapHiMpiVpcCropResizeResizePaste, METH_VARARGS, "vpc crop resize resize paste"},
132+ {"vpc_dilate", WrapHiMpiVpcDilate, METH_VARARGS, "vpc dilate"},
133+ {"vpc_draw_cover", WrapHiMpiVpcDrawCover, METH_VARARGS, "vpc draw cover"},
134+ {"vpc_draw_line", WrapHiMpiVpcDrawLine, METH_VARARGS, "vpc draw line"},
135+ {"vpc_draw_mosaic", WrapHiMpiVpcDrawMosaic, METH_VARARGS, "vpc draw mosaic"},
136+ {"vpc_draw_osd", WrapHiMpiVpcDrawOsd, METH_VARARGS, "vpc draw osd"},
137+ {"vpc_blur", WrapHiMpiVpcBlur, METH_VARARGS, "vpc blur"},
138+ {"vpc_gaussian_blur", WrapHiMpiVpcGaussianBlur, METH_VARARGS, "vpc gaussian blur"},
139+ {"vpc_erode", WrapHiMpiVpcErode, METH_VARARGS, "vpc erode"},
140+ {"vpc_filter2d", WrapHiMpiVpcFilter2d, METH_VARARGS, "vpc filter2d"},
141+ {"vpc_flip", WrapHiMpiVpcFlip, METH_VARARGS, "vpc flip"},
142+ {"vpc_get_affine_lut", WrapHiMpiVpcGetAffineLut, METH_VARARGS, "vpc get affinelut"},
143+ {"vpc_get_lut_mem_size", WrapHiMpiVpcGetLutMemSize, METH_VARARGS, "vpc get lut mem size"},
144+ {"vpc_get_affine_transform", WrapHiMpiVpcGetAffineTransform, METH_VARARGS, "vpc get affine transform"},
145+ {"vpc_get_perspective_lut", WrapHiMpiVpcGetPerspectiveLut, METH_VARARGS, "vpc get perspective lut"},
146+ {"vpc_get_remap_lut", WrapHiMpiVpcGetRemapLut, METH_VARARGS, "vpc get remap lut"},
147+ {"vpc_get_rotation_matrix", WrapHiMpiVpcGetRotationMatrix, METH_VARARGS, "vpc get rotation matrix"},
148+ {"vpc_lut_remap", WrapHiMpiVpcLutRemap, METH_VARARGS, "vpc lut remap"},
149+ {"vpc_set_chn_workspace", WrapHiMpiVpcSetChnWorkspace, METH_VARARGS, "vpc set chn workspace"},
150+ {"vpc_median_blur", WrapHiMpiVpcMedianBlur, METH_VARARGS, "vpc median blur"},
151+ {"vpc_rotate", WrapHiMpiVpcRotate, METH_VARARGS, "vpc rotate"},
152+ {"vpc_warp_affine", WrapHiMpiVpcWarpAffine, METH_VARARGS, "vpc warp affine"},
153+ {"vpc_set_chn_opt_attr", WrapHiMpiVpcSetChnOptAttr, METH_VARARGS, "vpc set chn opt attr"},
154+ 
155+ // pngd图像解码
156+ {"pngd_create_chn", WrapHiMpiPngdCreateChn, METH_VARARGS, "pngd create chn"},
157+ {"pngd_destroy_chn", WrapHiMpiPngdDestroyChn, METH_VARARGS, "pngd destroy chn"},
158+ {"pngd_send_stream", WrapHiMpiPngdSendStream, METH_VARARGS, "pngd send stream"},
159+ {"pngd_get_image_data", WrapHiMpiPngdGetImageData, METH_VARARGS, "pngd get image data"},
160+ {"png_get_image_info", WrapHiMpiPngGetImageInfo, METH_VARARGS, "png get image info"},
161+ {nullptr, nullptr, 0, nullptr}};
162+}
163+ 
164+PyMethodDef* GetHimpiMethods() { return g_methodsHimpi; }
@@ -0,0 +1,18 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_PYHIMPI_METHODS_CONTENT_H
12+#define WORD_PYHIMPI_METHODS_CONTENT_H
13+ 
14+#include <Python.h>
15+ 
16+PyMethodDef* GetHimpiMethods();
17+ 
18+#endif // WORD_PYHIMPI_METHODS_CONTENT_H
@@ -0,0 +1,112 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_MDL_H
12+#define WORD_MDL_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+PyObject* WrapAclMdlLoadFromFile(PyObject* self, PyObject* args);
18+PyObject* WrapAclMdlUnload(PyObject* self, PyObject* args);
19+PyObject* WrapAclMdlQuerySize(PyObject* self, PyObject* args);
20+PyObject* WrapAclMdlExecute(PyObject* self, PyObject* args);
21+PyObject* WrapAclMdlExecuteAsync(PyObject* self, PyObject* args);
22+PyObject* WrapAclMdlGetDatasetBuffer(PyObject* self, PyObject* args);
23+PyObject* WrapAclMdlGetDatasetNumBuffers(PyObject* self, PyObject* args);
24+PyObject* WrapAclMdlAddDatasetBuffer(PyObject* self, PyObject* args);
25+PyObject* WrapAclMdlGetOutputSizeByIndex(PyObject* self, PyObject* args);
26+PyObject* WrapAclMdlGetNumInputs(PyObject* self, PyObject* args);
27+PyObject* WrapAclMdlGetNumOutputs(PyObject* self, PyObject* args);
28+PyObject* WrapAclMdlGetInputSizeByIndex(PyObject* self, PyObject* args);
29+PyObject* WrapAclMdlCreateDataset(PyObject* self, PyObject* args);
30+PyObject* WrapAclMdlDestroyDataset(PyObject* self, PyObject* args);
31+PyObject* WrapAclMdlCreateDesc(PyObject* self, PyObject* args);
32+PyObject* WrapAclMdlGetDesc(PyObject* self, PyObject* args);
33+PyObject* WrapAclMdlDestroyDesc(PyObject* self, PyObject* args);
34+ 
35+PyObject* WrapAclMdlLoadFromMem(PyObject* self, PyObject* args);
36+PyObject* WrapAclMdlLoadFromFileWithMem(PyObject* self, PyObject* args);
37+PyObject* WrapAclMdlLoadFromMemWithMem(PyObject* self, PyObject* args);
38+PyObject* WrapAclMdlLoadFromFileWithQ(PyObject* self, PyObject* args);
39+PyObject* WrapAclMdlLoadFromMemWithQ(PyObject* self, PyObject* args);
40+PyObject* WrapAclMdlQuerySizeFromMem(PyObject* self, PyObject* args);
41+PyObject* WrapAclMdlSetDynamicBatchSize(PyObject* self, PyObject* args);
42+PyObject* WrapAclMdlSetDynamicHWSize(PyObject* self, PyObject* args);
43+PyObject* WrapAclMdlGetCurOutputDims(PyObject* self, PyObject* args);
44+PyObject* WrapAclMdlGetFirstAippInfo(PyObject* self, PyObject* args);
45+PyObject* WrapAclMdlSetDatasetTensorDesc(PyObject* self, PyObject* args);
46+PyObject* WrapAclMdlGetDatasetTensorDesc(PyObject* self, PyObject* args);
47+ 
48+PyObject* WrapAclMdlCreateAIPP(PyObject* self, PyObject* args);
49+PyObject* WrapAclMdlDestroyAIPP(PyObject* self, PyObject* args);
50+ 
51+PyObject* WrapAclMdlGetInputDims(PyObject* self, PyObject* args);
52+PyObject* WrapAclMdlGetInputDimsV2(PyObject* self, PyObject* args);
53+PyObject* WrapAclMdlGetOutputDims(PyObject* self, PyObject* args);
54+PyObject* WrapAclMdlGetInputNameByIndex(PyObject* self, PyObject* args);
55+PyObject* WrapAclMdlGetOutputNameByIndex(PyObject* self, PyObject* args);
56+PyObject* WrapAclMdlGetInputFormat(PyObject* self, PyObject* args);
57+PyObject* WrapAclMdlGetOutputFormat(PyObject* self, PyObject* args);
58+PyObject* WrapAclMdlGetInputDataType(PyObject* self, PyObject* args);
59+PyObject* WrapAclMdlGetOutputDataType(PyObject* self, PyObject* args);
60+PyObject* WrapAclMdlGetInputIndexByName(PyObject* self, PyObject* args);
61+PyObject* WrapAclMdlGetOutputIndexByName(PyObject* self, PyObject* args);
62+PyObject* WrapAclMdlGetDynamicBatch(PyObject* self, PyObject* args);
63+PyObject* WrapAclMdlGetDynamicHW(PyObject* self, PyObject* args);
64+ 
65+PyObject* WrapAclMdlSetAIPPInputFormat(PyObject* self, PyObject* args);
66+PyObject* WrapAclMdlSetAIPPCscParams(PyObject* self, PyObject* args);
67+PyObject* WrapAclMdlSetAIPPRbuvSwapSwitch(PyObject* self, PyObject* args);
68+PyObject* WrapAclMdlSetAIPPAxSwapSwitch(PyObject* self, PyObject* args);
69+PyObject* WrapAclMdlSetAIPPSrcImageSize(PyObject* self, PyObject* args);
70+PyObject* WrapAclMdlSetAIPPScfParams(PyObject* self, PyObject* args);
71+PyObject* WrapAclMdlSetAIPPCropParams(PyObject* self, PyObject* args);
72+PyObject* WrapAclMdlSetAIPPPaddingParams(PyObject* self, PyObject* args);
73+PyObject* WrapAclMdlSetAIPPDtcPixelMean(PyObject* self, PyObject* args);
74+PyObject* WrapAclMdlSetAIPPDtcPixelMin(PyObject* self, PyObject* args);
75+PyObject* WrapAclMdlSetAIPPPixelVarReci(PyObject* self, PyObject* args);
76+PyObject* WrapAclMdlSetInputAIPP(PyObject* self, PyObject* args);
77+PyObject* WrapAclMdlSetInputDynamicDims(PyObject* self, PyObject* args);
78+PyObject* WrapAclMdlGetInputDynamicGearCount(PyObject* self, PyObject* args);
79+PyObject* WrapAclMdlGetInputDynamicDims(PyObject* self, PyObject* args);
80+PyObject* WrapAclMdlGetOpAttr(PyObject* self, PyObject* args);
81+PyObject* WrapAclMdlGetAippDataSize(PyObject* self, PyObject* args);
82+ 
83+PyObject* WrapAclMdlCreateAndGetOpDesc(PyObject* self, PyObject* args);
84+PyObject* WrapAclMdlInitDump(PyObject* self, PyObject* args);
85+PyObject* WrapAclMdlFinalizeDump(PyObject* self, PyObject* args);
86+PyObject* WrapAclMdlGetAippType(PyObject* self, PyObject* args);
87+PyObject* WrapAclMdlSetAIPPByInputIndex(PyObject* self, PyObject* args);
88+PyObject* WrapAclMdlSetDump(PyObject* self, PyObject* args);
89+PyObject* WrapAclMdlDumpRegCallback(PyObject* self, PyObject* args);
90+PyObject* WrapAclMdlDumpUnregCallback(PyObject* self, PyObject* args);
91+PyObject* WrapAclMdlLoadWithConfig(PyObject* self, PyObject* args);
92+PyObject* WrapAclMdlCreateConfigHandle(PyObject* self, PyObject* args);
93+PyObject* WrapAclMdlDestroyConfigHandle(PyObject* self, PyObject* args);
94+PyObject* WrapAclMdlSetConfigOpt(PyObject* self, PyObject* args);
95+PyObject* WrapAclMdlGetTensorRealName(PyObject* self, PyObject* args);
96+ 
97+// model execute with config handle
98+PyObject* WrapAclMdlCreateExecConfigHandle(PyObject* self, PyObject* args);
99+PyObject* WrapAclMdlDestroyExecConfigHandle(PyObject* self, PyObject* args);
100+PyObject* WrapAclMdlSetExecConfigOpt(PyObject* self, PyObject* args);
101+PyObject* WrapAclMdlExecuteV2(PyObject* self, PyObject* args);
102+ 
103+PyObject* WrapAclMdlGetDescFromFile(PyObject* self, PyObject* args);
104+PyObject* WrapAclMdlGetDescFromMem(PyObject* self, PyObject* args);
105+PyObject* WrapAclMdlGetInputDimsRange(PyObject* self, PyObject* args);
106+PyObject* WrapAclMdlBundleLoadFromFile(PyObject* self, PyObject* args);
107+PyObject* WrapAclMdlBundleLoadFromMem(PyObject* self, PyObject* args);
108+PyObject* WrapAclMdlBundleUnload(PyObject* self, PyObject* args);
109+PyObject* WrapAclMdlBundleGetModelId(PyObject* self, PyObject* args);
110+PyObject* WrapAclMdlBundleGetModelNum(PyObject* self, PyObject* args);
111+ 
112+#endif // WORD_MDL_H
@@ -0,0 +1,107 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "mdl_wrap.h"
12+ 
13+namespace {
14+PyMethodDef g_methodsMdl[] = {
15+ {"load_from_file", WrapAclMdlLoadFromFile, METH_VARARGS, "mdl load from file"},
16+ {"unload", WrapAclMdlUnload, METH_VARARGS, "mdl unload"},
17+ {"query_size", WrapAclMdlQuerySize, METH_VARARGS, "mdl query size"},
18+ {"execute", WrapAclMdlExecute, METH_VARARGS, "mdl execute"},
19+ {"execute_async", WrapAclMdlExecuteAsync, METH_VARARGS, "mdl execute async"},
20+ {"create_dataset", WrapAclMdlCreateDataset, METH_VARARGS, "mdl create dataset"},
21+ {"destroy_dataset", WrapAclMdlDestroyDataset, METH_VARARGS, "mdl destroy dataset"},
22+ {"get_dataset_buffer", WrapAclMdlGetDatasetBuffer, METH_VARARGS, "mdl get dataset buffer"},
23+ {"get_dataset_num_buffers", WrapAclMdlGetDatasetNumBuffers, METH_VARARGS, "mdl get dataset num buffers"},
24+ {"add_dataset_buffer", WrapAclMdlAddDatasetBuffer, METH_VARARGS, "mdl add dataset buffer"},
25+ {"get_output_size_by_index", WrapAclMdlGetOutputSizeByIndex, METH_VARARGS, "mdl get output size by index"},
26+ {"get_num_inputs", WrapAclMdlGetNumInputs, METH_VARARGS, "mdl get num inputs"},
27+ {"get_num_outputs", WrapAclMdlGetNumOutputs, METH_VARARGS, "mdl get num outputs"},
28+ {"get_input_size_by_index", WrapAclMdlGetInputSizeByIndex, METH_VARARGS, "mdl get input size by index"},
29+ {"create_desc", WrapAclMdlCreateDesc, METH_VARARGS, "mdl create desc"},
30+ {"get_desc", WrapAclMdlGetDesc, METH_VARARGS, "mdl get desc"},
31+ {"destroy_desc", WrapAclMdlDestroyDesc, METH_VARARGS, "mdl destroy desc"},
32+ {"load_from_mem", WrapAclMdlLoadFromMem, METH_VARARGS, "mdl load from mem"},
33+ {"load_from_file_with_mem", WrapAclMdlLoadFromFileWithMem, METH_VARARGS, "mdl load from file with mem"},
34+ {"load_from_mem_with_mem", WrapAclMdlLoadFromMemWithMem, METH_VARARGS, "mdl load from mem with mem"},
35+ {"query_size_from_mem", WrapAclMdlQuerySizeFromMem, METH_VARARGS, "mdl query size from mem"},
36+ {"set_dynamic_batch_size", WrapAclMdlSetDynamicBatchSize, METH_VARARGS, "mdl set dynamic batch size"},
37+ {"set_dynamic_hw_size", WrapAclMdlSetDynamicHWSize, METH_VARARGS, "mdl set dynamic hw size"},
38+ {"get_cur_output_dims", WrapAclMdlGetCurOutputDims, METH_VARARGS, "mdl get cur num outputs"},
39+ {"get_first_aipp_info", WrapAclMdlGetFirstAippInfo, METH_VARARGS, "get first aipp info"},
40+ {"create_aipp", WrapAclMdlCreateAIPP, METH_VARARGS, "mdl create aipp"},
41+ {"destroy_aipp", WrapAclMdlDestroyAIPP, METH_VARARGS, "mdl destroy aipp"},
42+ {"get_input_dims", WrapAclMdlGetInputDims, METH_VARARGS, "mdl get input dims"},
43+ {"get_input_dims_v2", WrapAclMdlGetInputDimsV2, METH_VARARGS, "mdl get input dims v2"},
44+ {"get_output_dims", WrapAclMdlGetOutputDims, METH_VARARGS, "mdl get output dims"},
45+ {"get_input_name_by_index", WrapAclMdlGetInputNameByIndex, METH_VARARGS, "mdl get input name by index"},
46+ {"get_output_name_by_index", WrapAclMdlGetOutputNameByIndex, METH_VARARGS, "mdl get output name by index"},
47+ {"get_input_format", WrapAclMdlGetInputFormat, METH_VARARGS, "mdl get input format"},
48+ {"get_output_format", WrapAclMdlGetOutputFormat, METH_VARARGS, "mdl get output format"},
49+ {"get_input_data_type", WrapAclMdlGetInputDataType, METH_VARARGS, "mdl get input data type"},
50+ {"get_output_data_type", WrapAclMdlGetOutputDataType, METH_VARARGS, "mdl get output data type"},
51+ {"get_input_index_by_name", WrapAclMdlGetInputIndexByName, METH_VARARGS, "mdl get input index by name"},
52+ {"get_output_index_by_name", WrapAclMdlGetOutputIndexByName, METH_VARARGS, "mdl get Output index by name"},
53+ {"get_dynamic_batch", WrapAclMdlGetDynamicBatch, METH_VARARGS, "mdl get dynamic batch"},
54+ {"get_dynamic_hw", WrapAclMdlGetDynamicHW, METH_VARARGS, "mdl get dynamic hw"},
55+ {"set_aipp_input_format", WrapAclMdlSetAIPPInputFormat, METH_VARARGS, "mdl set aipp input format"},
56+ {"set_aipp_csc_params", WrapAclMdlSetAIPPCscParams, METH_VARARGS, "mdl set aipp csc params"},
57+ {"set_aipp_rbuv_swap_switch", WrapAclMdlSetAIPPRbuvSwapSwitch, METH_VARARGS, "mdl set aipp rbuv swap switch"},
58+ {"set_aipp_ax_swap_switch", WrapAclMdlSetAIPPAxSwapSwitch, METH_VARARGS, "mdl set aipp ax swap switch"},
59+ {"set_aipp_src_image_size", WrapAclMdlSetAIPPSrcImageSize, METH_VARARGS, "mdl set aipp src image size"},
60+ {"set_aipp_crop_params", WrapAclMdlSetAIPPCropParams, METH_VARARGS, "mdl set aipp crop params"},
61+ {"set_aipp_padding_params", WrapAclMdlSetAIPPPaddingParams, METH_VARARGS, "mdl set aipp padding params"},
62+ {"set_aipp_dtc_pixel_mean", WrapAclMdlSetAIPPDtcPixelMean, METH_VARARGS, "mdl set aipp dtc pixel mean"},
63+ {"set_aipp_dtc_pixel_min", WrapAclMdlSetAIPPDtcPixelMin, METH_VARARGS, "mdl set aipp dtc pixel min"},
64+ {"set_aipp_pixel_var_reci", WrapAclMdlSetAIPPPixelVarReci, METH_VARARGS, "mdl set aipp pixel var reci"},
65+ {"set_input_aipp", WrapAclMdlSetInputAIPP, METH_VARARGS, "mdl set input aipp"},
66+ {"set_input_dynamic_dims", WrapAclMdlSetInputDynamicDims, METH_VARARGS, "mdl set input dynamic dims"},
67+ {"get_input_dynamic_gear_count", WrapAclMdlGetInputDynamicGearCount, METH_VARARGS,
68+ "mdl get input dynamic gear count"},
69+ {"get_input_dynamic_dims", WrapAclMdlGetInputDynamicDims, METH_VARARGS, "mdl get input dynamic dims"},
70+ {"create_and_get_op_desc", WrapAclMdlCreateAndGetOpDesc, METH_VARARGS, "mdl create_and_get_op_desc"},
71+ {"init_dump", WrapAclMdlInitDump, METH_VARARGS, "mdl init dump"},
72+ {"finalize_dump", WrapAclMdlFinalizeDump, METH_VARARGS, "mdl finalize dump"},
73+ {"get_aipp_type", WrapAclMdlGetAippType, METH_VARARGS, "mdl get aipp type"},
74+ {"set_aipp_by_input_index", WrapAclMdlSetAIPPByInputIndex, METH_VARARGS, "mdl set aipp by input index"},
75+ {"set_dump", WrapAclMdlSetDump, METH_VARARGS, "mdl set dump"},
76+ {"dump_reg_callback", WrapAclMdlDumpRegCallback, METH_VARARGS, "dump reg callback"},
77+ {"dump_unreg_callback", WrapAclMdlDumpUnregCallback, METH_VARARGS, "dump unreg callback"},
78+ {"load_with_config", WrapAclMdlLoadWithConfig, METH_VARARGS, "load with config"},
79+ {"create_config_handle", WrapAclMdlCreateConfigHandle, METH_VARARGS, "create config handle"},
80+ {"destroy_config_handle", WrapAclMdlDestroyConfigHandle, METH_VARARGS, "destroy config handle"},
81+ {"set_config_opt", WrapAclMdlSetConfigOpt, METH_VARARGS, "set config opt"},
82+ {"get_tensor_real_name", WrapAclMdlGetTensorRealName, METH_VARARGS, "get tensor real name"},
83+ {"set_dataset_tensor_desc", WrapAclMdlSetDatasetTensorDesc, METH_VARARGS, "set dataset tensor desc"},
84+ {"get_dataset_tensor_desc", WrapAclMdlGetDatasetTensorDesc, METH_VARARGS, "get dataset tensor desc"},
85+ {"get_op_attr", WrapAclMdlGetOpAttr, METH_VARARGS, "get op attr"},
86+ {"get_aipp_data_size", WrapAclMdlGetAippDataSize, METH_VARARGS, "get aipp data size"},
87+ {"create_exec_config_handle", WrapAclMdlCreateExecConfigHandle, METH_VARARGS, "create mdlExecConfigHandle"},
88+ {"destroy_exec_config_handle", WrapAclMdlDestroyExecConfigHandle, METH_VARARGS, "destroy mdlExecConfigHandle"},
89+ {"set_exec_config_opt", WrapAclMdlSetExecConfigOpt, METH_VARARGS, "set mdlExecConfigHandle"},
90+ {"execute_v2", WrapAclMdlExecuteV2, METH_VARARGS, "execute model with mdlExecConfigHandle"},
91+ {"get_desc_from_file", WrapAclMdlGetDescFromFile, METH_VARARGS, "get desc from file"},
92+ {"get_desc_from_mem", WrapAclMdlGetDescFromMem, METH_VARARGS, "get desc from mem"},
93+ {"get_input_dims_range", WrapAclMdlGetInputDimsRange, METH_VARARGS, "get input dims range"},
94+ {"bundle_load_from_file", WrapAclMdlBundleLoadFromFile, METH_VARARGS, "bundle load from file"},
95+ {"bundle_load_from_mem", WrapAclMdlBundleLoadFromMem, METH_VARARGS, "bundle load from mem"},
96+ {"bundle_unload", WrapAclMdlBundleUnload, METH_VARARGS, "bundle unload"},
97+ {"bundle_get_model_id", WrapAclMdlBundleGetModelId, METH_VARARGS, "bundle get model id"},
98+ {"bundle_get_model_num", WrapAclMdlBundleGetModelNum, METH_VARARGS, "bundle get model num"},
99+#ifdef USE_MDL
100+ {"set_aipp_scf_params", WrapAclMdlSetAIPPScfParams, METH_VARARGS, "mdl set aipp scf params"},
101+ {"load_from_file_with_q", WrapAclMdlLoadFromFileWithQ, METH_VARARGS, "mdl load from file with q"},
102+ {"load_from_mem_with_q", WrapAclMdlLoadFromMemWithQ, METH_VARARGS, "mdl load from mem with q"},
103+#endif
104+ {nullptr, nullptr, 0, nullptr}};
105+} // namespace
106+ 
107+PyMethodDef* GetMdlMethods() { return g_methodsMdl; }
@@ -0,0 +1,18 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_MDL_METHODS_CONTENT_H
12+#define WORD_MDL_METHODS_CONTENT_H
13+ 
14+#include <Python.h>
15+ 
16+PyMethodDef* GetMdlMethods();
17+ 
18+#endif // WORD_mdl.METHODS_CONTENT_H
@@ -0,0 +1,101 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_MEDIA_COMMON_FUNCS_H
12+#define WORD_MEDIA_COMMON_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+// 媒体数据处理
18+PyObject* WrapAclDvppMalloc(PyObject* self, PyObject* args);
19+PyObject* WrapAclDvppMallocWithCfg(PyObject* self, PyObject* args);
20+PyObject* WrapAclDvppFree(PyObject* self, PyObject* args);
21+// 通道创建与释放
22+PyObject* WrapAclDvppCreateChannel(PyObject* self, PyObject* args);
23+PyObject* WrapAclDvppDestroyChannel(PyObject* self, PyObject* args);
24+PyObject* WrapAclDvppSetChannelDescParam(PyObject* self, PyObject* args);
25+PyObject* WrapAclDvppGetChannelDescParam(PyObject* self, PyObject* args);
26+// acldvppChannelDesc
27+PyObject* WrapAclDvppCreateChannelDesc(PyObject* self, PyObject* args);
28+PyObject* WrapAclDvppDestroyChannelDesc(PyObject* self, PyObject* args);
29+PyObject* WrapAclDvppGetChannelDescChannelId(PyObject* self, PyObject* args);
30+PyObject* WrapAclDvppSetChannelDescMode(PyObject* self, PyObject* args);
31+// acldvppPicDesc
32+PyObject* WrapAclDvppCreatePicDesc(PyObject* self, PyObject* args);
33+PyObject* WrapAclDvppDestroyPicDesc(PyObject* self, PyObject* args);
34+PyObject* WrapAclDvppSetPicDescData(PyObject* self, PyObject* args);
35+PyObject* WrapAclDvppSetPicDescSize(PyObject* self, PyObject* args);
36+PyObject* WrapAclDvppSetPicDescFormat(PyObject* self, PyObject* args);
37+PyObject* WrapAclDvppSetPicDescWidth(PyObject* self, PyObject* args);
38+PyObject* WrapAclDvppSetPicDescHeight(PyObject* self, PyObject* args);
39+PyObject* WrapAclDvppSetPicDescWidthStride(PyObject* self, PyObject* args);
40+PyObject* WrapAclDvppSetPicDescHeightStride(PyObject* self, PyObject* args);
41+PyObject* WrapAclDvppSetPicDescRetCode(PyObject* self, PyObject* args);
42+PyObject* WrapAclDvppGetPicDescData(PyObject* self, PyObject* args);
43+PyObject* WrapAclDvppGetPicDescSize(PyObject* self, PyObject* args);
44+PyObject* WrapAclDvppGetPicDescFormat(PyObject* self, PyObject* args);
45+PyObject* WrapAclDvppGetPicDescWidth(PyObject* self, PyObject* args);
46+PyObject* WrapAclDvppGetPicDescHeight(PyObject* self, PyObject* args);
47+PyObject* WrapAclDvppGetPicDescWidthStride(PyObject* self, PyObject* args);
48+PyObject* WrapAclDvppGetPicDescHeightStride(PyObject* self, PyObject* args);
49+PyObject* WrapAclDvppGetPicDescRetCode(PyObject* self, PyObject* args);
50+// acldvppStreamDesc
51+PyObject* WrapAclDvppCreateStreamDesc(PyObject* self, PyObject* args);
52+PyObject* WrapAclDvppDestroyStreamDesc(PyObject* self, PyObject* args);
53+PyObject* WrapAclDvppSetStreamDescData(PyObject* self, PyObject* args);
54+PyObject* WrapAclDvppSetStreamDescSize(PyObject* self, PyObject* args);
55+PyObject* WrapAclDvppSetStreamDescFormat(PyObject* self, PyObject* args);
56+PyObject* WrapAclDvppSetStreamDescTimestamp(PyObject* self, PyObject* args);
57+PyObject* WrapAclDvppSetStreamDescRetCode(PyObject* self, PyObject* args);
58+PyObject* WrapAclDvppSetStreamDescEos(PyObject* self, PyObject* args);
59+PyObject* WrapAclDvppGetStreamDescData(PyObject* self, PyObject* args);
60+PyObject* WrapAclDvppGetStreamDescSize(PyObject* self, PyObject* args);
61+PyObject* WrapAclDvppGetStreamDescFormat(PyObject* self, PyObject* args);
62+PyObject* WrapAclDvppGetStreamDescTimestamp(PyObject* self, PyObject* args);
63+PyObject* WrapAclDvppGetStreamDescRetCode(PyObject* self, PyObject* args);
64+PyObject* WrapAclDvppGetStreamDescEos(PyObject* self, PyObject* args);
65+// acldvppBatchPicDesc
66+PyObject* WrapAclDvppCreateBatchPicDesc(PyObject* self, PyObject* args);
67+PyObject* WrapAclDvppDestroyBatchPicDesc(PyObject* self, PyObject* args);
68+PyObject* WrapAclDvppGetPicDesc(PyObject* self, PyObject* args);
69+// acldvppLutMap
70+PyObject* WrapAclDvppCreateLutMap(PyObject* self, PyObject* args);
71+PyObject* WrapAclDvppDestroyLutMap(PyObject* self, PyObject* args);
72+PyObject* WrapAclDvppGetLutMapData(PyObject* self, PyObject* args);
73+PyObject* WrapAclDvppGetLutMapDims(PyObject* self, PyObject* args);
74+// acldvppBorderConfig
75+PyObject* WrapAclDvppCreateBorderConfig(PyObject* self, PyObject* args);
76+PyObject* WrapAclDvppDestroyBorderConfig(PyObject* self, PyObject* args);
77+PyObject* WrapAclDvppGetBorderConfigValue(PyObject* self, PyObject* args);
78+PyObject* WrapAclDvppGetBorderConfigBorderType(PyObject* self, PyObject* args);
79+PyObject* WrapAclDvppGetBorderConfigTop(PyObject* self, PyObject* args);
80+PyObject* WrapAclDvppGetBorderConfigBottom(PyObject* self, PyObject* args);
81+PyObject* WrapAclDvppGetBorderConfigLeft(PyObject* self, PyObject* args);
82+PyObject* WrapAclDvppGetBorderConfigRight(PyObject* self, PyObject* args);
83+PyObject* WrapAclDvppSetBorderConfigValue(PyObject* self, PyObject* args);
84+PyObject* WrapAclDvppSetBorderConfigBorderType(PyObject* self, PyObject* args);
85+PyObject* WrapAclDvppSetBorderConfigTop(PyObject* self, PyObject* args);
86+PyObject* WrapAclDvppSetBorderConfigBottom(PyObject* self, PyObject* args);
87+PyObject* WrapAclDvppSetBorderConfigLeft(PyObject* self, PyObject* args);
88+PyObject* WrapAclDvppSetBorderConfigRight(PyObject* self, PyObject* args);
89+// acldvppHist
90+PyObject* WrapAclDvppClearHist(PyObject* self, PyObject* args);
91+PyObject* WrapAclDvppCreateHist(PyObject* self, PyObject* args);
92+PyObject* WrapAclDvppDestroyHist(PyObject* self, PyObject* args);
93+PyObject* WrapAclDvppGetHistData(PyObject* self, PyObject* args);
94+PyObject* WrapAclDvppGetHistDims(PyObject* self, PyObject* args);
95+PyObject* WrapAclDvppGetHistRetCode(PyObject* self, PyObject* args);
96+// PNGD功能
97+PyObject* WrapAclDvppPngDecodeAsync(PyObject* self, PyObject* args);
98+PyObject* WrapAclDvppPngGetImageInfo(PyObject* self, PyObject* args);
99+PyObject* WrapAclDvppPngPredictDecSize(PyObject* self, PyObject* args);
100+ 
101+#endif // WORD_MEDIA_COMMON_FUNCS_H
@@ -0,0 +1,142 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "media_jpeg.h"
12+#include "acl/acl.h"
13+#include "acl/ops/acl_dvpp.h"
14+ 
15+PyObject* WrapAclDvppJpegDecodeAsync(PyObject* /* self */, PyObject* args)
16+{
17+ acldvppChannelDesc* channelDesc = nullptr;
18+ void* data = nullptr;
19+ uint32_t size = 0;
20+ acldvppPicDesc* outputDesc = nullptr;
21+ aclrtStream stream = nullptr;
22+ 
23+ CHECK_NULL(
24+ PyArg_ParseTuple(args, "kkIkk", &channelDesc, &data, &size, &outputDesc, &stream),
25+ "acl.media.dvpp_jpeg_decode_async args parse failed");
26+ 
27+ aclError ret = acldvppJpegDecodeAsync(channelDesc, data, size, outputDesc, stream);
28+ return Py_BuildValue("i", ret);
29+}
30+ 
31+PyObject* WrapAclDvppJpegGetImageInfo(PyObject* /* self */, PyObject* args)
32+{
33+ void* data = nullptr;
34+ uint32_t size = 0;
35+ uint32_t width = 0;
36+ uint32_t height = 0;
37+ int32_t components = 0;
38+ 
39+ CHECK_NULL(PyArg_ParseTuple(args, "kI", &data, &size), "acl.media.dvpp_jpeg_get_image_info args parse failed");
40+ 
41+ aclError ret = acldvppJpegGetImageInfo(data, size, &width, &height, &components);
42+ return Py_BuildValue("IIii", width, height, components, ret);
43+}
44+ 
45+PyObject* WrapAclDvppJpegGetImageInfoV2(PyObject* /* self */, PyObject* args)
46+{
47+ const void* data = nullptr;
48+ uint32_t size = 0;
49+ uint32_t width = 0;
50+ uint32_t height = 0;
51+ int32_t components = 0;
52+ acldvppJpegFormat format = ACL_JPEG_CSS_UNKNOWN;
53+ 
54+ CHECK_NULL(PyArg_ParseTuple(args, "kI", &data, &size), "acl.media.dvpp_jpeg_get_image_info_v2 args parse failed");
55+ 
56+ aclError ret = acldvppJpegGetImageInfoV2(data, size, &width, &height, &components, &format);
57+ return Py_BuildValue("IIiii", width, height, components, format, ret);
58+}
59+ 
60+PyObject* WrapAclDvppJpegPredictDecSize(PyObject* /* self */, PyObject* args)
61+{
62+ void* data = nullptr;
63+ uint32_t dataSize = 0;
64+ int outputPixelFormat = 0;
65+ uint32_t decSize = 0;
66+ 
67+ CHECK_NULL(
68+ PyArg_ParseTuple(args, "kIi", &data, &dataSize, &outputPixelFormat),
69+ "acl.media.dvpp_jpeg_predict_dec_size args parse failed");
70+ 
71+ aclError ret =
72+ acldvppJpegPredictDecSize(data, dataSize, static_cast<acldvppPixelFormat>(outputPixelFormat), &decSize);
73+ return Py_BuildValue("Ii", decSize, ret);
74+}
75+ 
76+PyObject* WrapAclDvppJpegEncodeAsync(PyObject* /* self */, PyObject* args)
77+{
78+ acldvppChannelDesc* channelDesc = nullptr;
79+ acldvppPicDesc* inputDesc = nullptr;
80+ void* data = nullptr;
81+ uint32_t* size = nullptr;
82+ acldvppJpegeConfig* config = nullptr;
83+ aclrtStream stream = nullptr;
84+ 
85+ CHECK_NULL(
86+ PyArg_ParseTuple(args, "kkkkkk", &channelDesc, &inputDesc, &data, &size, &config, &stream),
87+ "acl.media.dvpp_jpeg_encode_async args parse failed");
88+ 
89+ aclError ret = acldvppJpegEncodeAsync(channelDesc, inputDesc, data, size, config, stream);
90+ return Py_BuildValue("i", ret);
91+}
92+ 
93+PyObject* WrapAclDvppJpegPredictEncSize(PyObject* /* self */, PyObject* args)
94+{
95+ acldvppPicDesc* inputDesc = nullptr;
96+ acldvppJpegeConfig* config = nullptr;
97+ uint32_t size = 0;
98+ 
99+ CHECK_NULL(
100+ PyArg_ParseTuple(args, "kk", &inputDesc, &config), "acl.media.dvpp_jpeg_predict_enc_size args parse failed");
101+ 
102+ aclError ret = acldvppJpegPredictEncSize(inputDesc, config, &size);
103+ return Py_BuildValue("Ii", size, ret);
104+}
105+ 
106+PyObject* WrapAclDvppCreateJpegeConfig(PyObject* /* self */, PyObject* /* args */)
107+{
108+ acldvppJpegeConfig* jpegeConfig = acldvppCreateJpegeConfig();
109+ return Py_BuildValue("k", reinterpret_cast<uintptr_t>(jpegeConfig));
110+}
111+ 
112+PyObject* WrapAclDvppDestroyJpegeConfig(PyObject* /* self */, PyObject* args)
113+{
114+ acldvppJpegeConfig* jpegeConfig = nullptr;
115+ 
116+ CHECK_NULL(PyArg_ParseTuple(args, "k", &jpegeConfig), "acl.media.dvpp_destroy_jpege_config args parse failed");
117+ 
118+ aclError ret = acldvppDestroyJpegeConfig(jpegeConfig);
119+ return Py_BuildValue("i", ret);
120+}
121+ 
122+PyObject* WrapAclDvppSetJpegeConfigLevel(PyObject* /* self */, PyObject* args)
123+{
124+ acldvppJpegeConfig* jpegeConfig = nullptr;
125+ uint32_t level = 0;
126+ 
127+ CHECK_NULL(
128+ PyArg_ParseTuple(args, "kI", &jpegeConfig, &level), "acl.media.dvpp_set_jpege_config_level args parse failed");
129+ 
130+ aclError ret = acldvppSetJpegeConfigLevel(jpegeConfig, level);
131+ return Py_BuildValue("i", ret);
132+}
133+ 
134+PyObject* WrapAclDvppGetJpegeConfigLevel(PyObject* /* self */, PyObject* args)
135+{
136+ acldvppJpegeConfig* jpegeConfig = nullptr;
137+ 
138+ CHECK_NULL(PyArg_ParseTuple(args, "k", &jpegeConfig), "acl.media.dvpp_get_jpege_config_level args parse failed!");
139+ 
140+ uint32_t level = acldvppGetJpegeConfigLevel(jpegeConfig);
141+ return Py_BuildValue("I", level);
142+}
@@ -0,0 +1,28 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef WORD_MEDIA_JPEG_FUNCS_H
12+#define WORD_MEDIA_JPEG_FUNCS_H
13+ 
14+#include <Python.h>
15+#include "utils_methods.h"
16+ 
17+PyObject* WrapAclDvppJpegDecodeAsync(PyObject* self, PyObject* args);
18+PyObject* WrapAclDvppJpegGetImageInfo(PyObject* self, PyObject* args);
19+PyObject* WrapAclDvppJpegGetImageInfoV2(PyObject* self, PyObject* args);
20+PyObject* WrapAclDvppJpegPredictDecSize(PyObject* self, PyObject* args);
21+PyObject* WrapAclDvppJpegEncodeAsync(PyObject* self, PyObject* args);
22+PyObject* WrapAclDvppJpegPredictEncSize(PyObject* self, PyObject* args);
23+PyObject* WrapAclDvppCreateJpegeConfig(PyObject* self, PyObject* args);
24+PyObject* WrapAclDvppDestroyJpegeConfig(PyObject* self, PyObject* args);
25+PyObject* WrapAclDvppSetJpegeConfigLevel(PyObject* self, PyObject* args);
26+PyObject* WrapAclDvppGetJpegeConfigLevel(PyObject* self, PyObject* args);
27+ 
28+#endif // WORD_MEDIA_JPEG_FUNCS_H