* Copyright (c) 2026 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
#include "rt_binary.h"
#include "rt_context.h"
#include "rt_memory.h"
#include "rt_device.h"
#include "rt_stream.h"
#include "rt_synchronize.h"
#include "rt_group.h"
#include "rt_allocator.h"
#include "rt_notify.h"
namespace {
PyMethodDef g_methodsRt[] = {
{"binary_load_from_file", WrapAclRtBinaryLoadFromFile, METH_VARARGS, "binary load from file"},
{"binary_load_from_data", WrapAclRtBinaryLoadFromData, METH_VARARGS, "binary load from data"},
{"get_function_addr", WrapAclRtGetFunctionAddr, METH_VARARGS, "get function address"},
{"get_function_name", WrapAclRtGetFunctionName, METH_VARARGS, "get function name"},
{"register_cpu_func", WrapAclRtRegisterCpuFunc, METH_VARARGS, "register cpu function"},
{"create_binary", WrapAclRtCreateBinary, METH_VARARGS, "create binary data to describe operators"},
{"destroy_binary", WrapAclRtDestroyBinary, METH_VARARGS, "destroy the binary data generated by create_binary"},
{"binary_load", WrapAclRtBinaryLoad, METH_VARARGS, "get the operator instance from a loaded binary file"},
{"binary_unload", WrapAclRtBinaryUnLoad, METH_VARARGS, "delete the operator instance loaded by binary_load"},
{"binary_get_function", WrapAclRtBinaryGetFunction, METH_VARARGS, "get the kernel object by name"},
{"launch_kernel", WrapAclRtLaunchKernel, METH_VARARGS, "launch kernel tasks"},
{"kernel_args_init", WrapAclRtKernelArgsInit, METH_VARARGS, "kernel args init"},
{"kernel_args_init_by_user_mem", WrapAclRtKernelArgsInitByUserMem, METH_VARARGS, "kernel args init by user mem"},
{"kernel_args_get_mem_size", WrapAclRtKernelArgsGetMemSize, METH_VARARGS, "kernel args get mem size"},
{"kernel_args_get_handle_mem_size", WrapAclRtKernelArgsGetHandleMemSize, METH_VARARGS,
"kernel args get handle mem size"},
{"kernel_args_append", WrapAclRtKernelArgsAppend, METH_VARARGS, "kernel args append"},
{"kernel_args_append_place_holder", WrapAclRtKernelArgsAppendPlaceHolder, METH_VARARGS,
"kernel args append place holder"},
{"kernel_args_get_place_holder_buffer", WrapAclRtKernelArgsGetPlaceHolderBuffer, METH_VARARGS,
"kernel args get place holder buffer"},
{"kernel_args_para_update", WrapAclRtKernelArgsParaUpdate, METH_VARARGS, "kernel args para update"},
{"kernel_args_finalize", WrapAclRtKernelArgsFinalize, METH_VARARGS, "kernel args finalize"},
{"launch_kernel_with_config", WrapAclRtLaunchKernelWithConfig, METH_VARARGS, "launch kernel with config"},
{"set_device", WrapAclRtSetDevice, METH_VARARGS, "acl set device"},
{"reset_device", WrapAclRtResetDevice, METH_VARARGS, "acl reset device"},
{"reset_device_force", WrapAclRtResetDeviceForce, METH_VARARGS, "acl reset device by force"},
{"get_device", WrapAclRtGetDevice, METH_VARARGS, "acl get device"},
{"set_device_sat_mode", WrapAclRtSetDeviceSatMode, METH_VARARGS, "set device sat mode"},
{"get_device_sat_mode", WrapAclRtGetDeviceSatMode, METH_VARARGS, "get device sat mode"},
{"get_run_mode", WrapAclRtGetRunMode, METH_VARARGS, "acl get run mode"},
{"set_ts_device", WrapAclRtSetTsDevice, METH_VARARGS, "acl set ts device"},
{"get_device_count", WrapAclRtGetDeviceCount, METH_VARARGS, "acl get device count"},
{"create_context", WrapAclRtCreateContext, METH_VARARGS, "create context"},
{"destroy_context", WrapAclRtDestroyContext, METH_VARARGS, "destroy context"},
{"set_context", WrapAclRtSetCurrentContext, METH_VARARGS, "set context"},
{"get_context", WrapAclRtGetCurrentContext, METH_VARARGS, "get context"},
{"ctx_get_current_default_stream", WrapAclRtCtxGetCurrentDefaultStream, METH_VARARGS,
"ctx get current default stream"},
{"get_overflow_status", WrapAclRtGetOverflowStatus, METH_VARARGS, "get overflow status"},
{"reset_overflow_status", WrapAclRtResetOverflowStatus, METH_VARARGS, "reset overflow status"},
{"malloc", WrapAclRtMalloc, METH_VARARGS, "malloc device memory"},
{"free", WrapAclRtFree, METH_VARARGS, "free device memory"},
{"get_mem_info", WrapAclRtGetMemInfo, METH_VARARGS, "get mem info"},
{"malloc_cached", WrapAclRtMallocCached, METH_VARARGS, "memory cached"},
{"mem_flush", WrapAclRtMemFlush, METH_VARARGS, "memory flush"},
{"mem_invalidate", WrapAclRtMemInvalidate, METH_VARARGS, "memory invalidate"},
{"malloc_host", WrapAclRtMallocHost, METH_VARARGS, "malloc host memory"},
{"free_host", WrapAclRtFreeHost, METH_VARARGS, "free host memory"},
{"memcpy", WrapAclRtMemcpy, METH_VARARGS, "copy memory"},
{"memcpy_async", WrapAclRtMemcpyAsync, METH_VARARGS, "copy memory async"},
{"memset", WrapAclRtMemset, METH_VARARGS, "memset memory"},
{"memset_async", WrapAclRtMemsetAsync, METH_VARARGS, "memset memory async"},
{"create_stream", WrapAclRtCreateStream, METH_VARARGS, "create stream"},
{"create_stream_with_config", WrapAclRtCreateStreamWithConfig, METH_VARARGS, "create stream with config"},
{"destroy_stream", WrapAclRtDestroyStream, METH_VARARGS, "destroy stream"},
{"destroy_stream_force", WrapAclRtDestroyStreamForce, METH_VARARGS, "destroy stream force"},
{"set_stream_overflow_switch", WrapAclRtSetStreamOverflowSwitch, METH_VARARGS, "set stream overflow switch"},
{"get_stream_overflow_switch", WrapAclRtGetStreamOverflowSwitch, METH_VARARGS, "get stream overflow switch"},
{"set_stream_failure_mode", WrapAclRtSetStreamFailureMode, METH_VARARGS, "set stream failure mode"},
{"stream_query", WrapAclRtStreamQuery, METH_VARARGS, "query stream status"},
{"create_event", WrapAclRtCreateEvent, METH_VARARGS, "create event"},
{"create_event_with_flag", WrapAclRtCreateEventWithFlag, METH_VARARGS, "create event with flag"},
{"create_event_ex_with_flag", WrapAclRtCreateEventExWithFlag, METH_VARARGS, "create event ex with flag"},
{"destroy_event", WrapAclRtDestroyEvent, METH_VARARGS, "destroy event"},
{"synchronize_stream", WrapAclRtSynchronizeStream, METH_VARARGS, "Synchronize stream"},
{"synchronize_stream_with_timeout", WrapAclRtSynchronizeStreamWithTimeout, METH_VARARGS,
"synchronize stream with timeout"},
{"process_report", WrapAclRtProcessReport, METH_VARARGS, "process report"},
{"subscribe_report", WrapAclRtSubscribeReport, METH_VARARGS, "subscribe_report"},
{"unsubscribe_report", WrapAclRtUnSubscribeReport, METH_VARARGS, "unsubscribe report"},
{"launch_callback", WrapAclRtLaunchCallback, METH_VARARGS, "launch callback"},
{"synchronize_device", WrapAclRtSynchronizeDevice, METH_VARARGS, "synchronize device"},
{"record_event", WrapAclRtRecordEvent, METH_VARARGS, "record even"},
{"reset_event", WrapAclRtResetEvent, METH_VARARGS, "reset event"},
{"query_event", WrapAclRtQueryEvent, METH_VARARGS, "query event"},
{"query_event_status", WrapAclRtQueryEventStatus, METH_VARARGS, "query event status"},
{"query_event_wait_status", WrapAclRtQueryEventWaitStatus, METH_VARARGS, "query event wait status"},
{"synchronize_event", WrapAclRtSynchronizeEvent, METH_VARARGS, "synchronize event"},
{"synchronize_event_with_timeout", WrapAclRtSynchronizeEventWithTimeout, METH_VARARGS,
"synchronize event with timeout"},
{"event_elapsed_time", WrapAclRtEventElapsedTime, METH_VARARGS, "event elapsed time"},
{"event_get_timestamp", WrapAclRtEventGetTimestamp, METH_VARARGS, "event get time stamp"},
{"get_event_id", WrapAclRtGetEventId, METH_VARARGS, "get event id"},
{"get_event_avail_num", WrapAclRtGetEventAvailNum, METH_VARARGS, "get event avail num"},
{"stream_wait_event", WrapAclRtStreamWaitEvent, METH_VARARGS, "stream wait event"},
{"stream_get_id", WrapAclRtStreamGetId, METH_VARARGS, "stream get id"},
{"get_stream_available_num", WrapAclRtGetStreamAvailableNum, METH_VARARGS, "get stream available num"},
{"set_stream_attribute", WrapAclRtSetStreamAttribute, METH_VARARGS, "set stream attribute"},
{"get_stream_attribute", WrapAclRtGetStreamAttribute, METH_VARARGS, "get stream attribute"},
{"get_thread_last_task_id", WrapAclRtGetThreadLastTaskId, METH_VARARGS, "get thread last task id"},
{"reduce_async", WrapAclRtReduceAsync, METH_VARARGS, "reduce async"},
{"set_exception_info_callback", WrapAclRtSetExceptionInfoCallback, METH_VARARGS, "set exception info callback"},
{"get_error_code_from_exception_info", WrapAclRtGetErrorCodeFromExceptionInfo, METH_VARARGS,
"get errorCode from exception info"},
{"get_task_id_from_exception_info", WrapAclRtGetTaskIdFromExceptionInfo, METH_VARARGS,
"get task id from exception info"},
{"get_stream_id_from_exception_info", WrapAclRtGetStreamIdFromExceptionInfo, METH_VARARGS,
"get stream id from exception info"},
{"get_thread_id_from_exception_info", WrapAclRtGetThreadIdFromExceptionInfo, METH_VARARGS,
"get thread id from exception info"},
{"get_device_id_from_exception_info", WrapAclRtGetDeviceIdFromExceptionInfo, METH_VARARGS,
"get device id from exception info"},
{"set_op_wait_timeout", WrapAclRtSetOpWaitTimeout, METH_VARARGS, "set op wait timeout"},
{"set_op_execute_time_out", WrapAclRtSetOpExecuteTimeOut, METH_VARARGS, "set op execute timeout"},
{"memcpy2d", WrapAclRtMemcpy2d, METH_VARARGS, "memcpy2d"},
{"memcpy2d_async", WrapAclRtMemcpy2dAsync, METH_VARARGS, "memcpy2d async"},
{"reserve_mem_address", WrapAclRtReserveMemAddress, METH_VARARGS, "reserve virtual memory"},
{"release_mem_address", WrapAclRtReleaseMemAddress, METH_VARARGS, "release virtual memory"},
{"malloc_physical", WrapAclRtMallocPhysical, METH_VARARGS, "malloc physical memory"},
{"free_physical", WrapAclRtFreePhysical, METH_VARARGS, "free physical memory"},
{"malloc_with_cfg", WrapAclRtMallocWithCfg, METH_VARARGS, "malloc memory with config"},
{"malloc_for_task_scheduler", WrapAclRtMallocForTaskScheduler, METH_VARARGS, "malloc memory for task scheduler"},
{"malloc_host_with_cfg", WrapAclRtMallocHostWithCfg, METH_VARARGS, "malloc host memory with config"},
{"map_mem", WrapAclRtMapMem, METH_VARARGS, "map virtual address to physical address"},
{"unmap_mem", WrapAclRtUnmapMem, METH_VARARGS, "unmap virtual address"},
{"mem_export_to_shareable_handle", WrapAclRtMemExportToShareableHandle, METH_VARARGS,
"mem export to shareable handle"},
{"device_get_bare_tgid", WrapAclRtDeviceGetBareTgid, METH_VARARGS, "device get bare tgid"},
{"mem_set_pid_to_shareable_handle", WrapAclRtMemSetPidToShareableHandle, METH_VARARGS,
"mem set pid to shareable handle"},
{"mem_import_from_shareable_handle", WrapAclRtMemImportFromShareableHandle, METH_VARARGS,
"mem import from shareable handle"},
{"mem_get_allocation_granularity", WrapAclRtMemGetAllocationGranularity, METH_VARARGS,
"mem get allocation granularity"},
{"get_device_utilization_rate", WrapAclRtGetDeviceUtilizationRate, METH_VARARGS, "get device utilization rate"},
{"query_device_status", WrapAclRtQueryDeviceStatus, METH_VARARGS, "query device status"},
{"ctx_set_sys_param_opt", WrapAclRtCtxSetSysParamOpt, METH_VARARGS, "acl context set system parameter option"},
{"ctx_get_sys_param_opt", WrapAclRtCtxGetSysParamOpt, METH_VARARGS, "acl context get system parameter option"},
{"set_sys_param_opt", WrapAclRtSetSysParamOpt, METH_VARARGS, "acl set system parameter option"},
{"get_sys_param_opt", WrapAclRtGetSysParamOpt, METH_VARARGS, "acl get system parameter option"},
{"malloc_align32", WrapAclRtMallocAlign32, METH_VARARGS, "acl malloc align32"},
{"allocator_create_desc", WrapAclRtAllocatorCreateDesc, METH_VARARGS, "allocator create desc"},
{"allocator_destroy_desc", WrapAclRtAllocatorDestroyDesc, METH_VARARGS, "allocator destroy desc"},
{"allocator_set_obj_to_desc", WrapAclRtAllocatorSetObjToDesc, METH_VARARGS, "allocator set obj to desc"},
{"allocator_set_alloc_func_to_desc", WrapAclRtAllocatorSetAllocFuncToDesc, METH_VARARGS,
"allocator set alloc func to desc"},
{"allocator_set_free_func_to_desc", WrapAclRtAllocatorSetFreeFuncToDesc, METH_VARARGS,
"allocator set free func to desc"},
{"allocator_set_alloc_advise_func_to_desc", WrapAclRtAllocatorSetAllocAdviseFuncToDesc, METH_VARARGS,
"allocator set alloc advise func to desc"},
{"allocator_set_get_addr_from_block_func_to_desc", WrapAclRtAllocatorSetGetAddrFromBlockFuncToDesc, METH_VARARGS,
"allocator set get addr from block func to desc"},
{"allocator_register", WrapAclRtAllocatorRegister, METH_VARARGS, "allocator register"},
{"allocator_unregister", WrapAclRtAllocatorUnregister, METH_VARARGS, "allocator unregister"},
{"peek_at_last_error", WrapAclRtPeekAtLastError, METH_VARARGS, "peek at last error"},
{"get_last_error", WrapAclRtGetLastError, METH_VARARGS, "get last error"},
{"synchronize_device_with_timeout", WrapAclRtSynchronizeDeviceWithTimeout, METH_VARARGS,
"synchronize device with timeout"},
{"cmo_async", WrapAclRtCmoAsync, METH_VARARGS, "cmo async"},
{"device_task_abort", WrapAclRtDeviceTaskAbort, METH_VARARGS, "device task abort"},
{"memcpy_async_with_condition", WrapAclRtMemcpyAsyncWithCondition, METH_VARARGS, "memcpy async with condition"},
{"stream_abort", WrapAclRtStreamAbort, METH_VARARGS, "stream abort"},
{"pointer_get_attributes", WrapAclRtPointerGetAttributes, METH_VARARGS, "pointer get attributes"},
{"host_register", WrapAclRtHostRegister, METH_VARARGS, "host register"},
{"host_unregister", WrapAclRtHostUnregister, METH_VARARGS, "host unregister"},
{"get_memcpy_desc_size", WrapAclRtGetMemcpyDescSize, METH_VARARGS, "get memcpy desc size"},
{"set_memcpy_desc", WrapAclRtSetMemcpyDesc, METH_VARARGS, "set memcpy desc"},
{"memcpy_async_with_desc", WrapAclRtMemcpyAsyncWithDesc, METH_VARARGS, "memcpy async with desc"},
{"value_write", WrapAclRtValueWrite, METH_VARARGS, "value write"},
{"value_wait", WrapAclRtValueWait, METH_VARARGS, "value wait"},
{"device_can_access_peer", WrapAclRtDeviceCanAccessPeer, METH_VARARGS, "device can access peer"},
{"device_enable_peer_access", WrapAclRtDeviceEnablePeerAccess, METH_VARARGS, "device enable peer access"},
{"device_disable_peer_access", WrapAclRtDeviceDisablePeerAccess, METH_VARARGS, "device disable peer access"},
{"ipc_mem_get_export_key", WrapAclRtIpcMemGetExportKey, METH_VARARGS, "ipc mem get export key"},
{"ipc_mem_set_import_pid", WrapAclRtIpcMemSetImportPid, METH_VARARGS, "ipc mem set import pid"},
{"ipc_mem_import_by_key", WrapAclRtIpcMemImportByKey, METH_VARARGS, "ipc mem import by key"},
{"ipc_mem_close", WrapAclRtIpcMemClose, METH_VARARGS, "ipc mem close"},
{"get_device_info", WrapAclRtGetDeviceInfo, METH_VARARGS, "get device info"},
{"device_get_stream_priority_range", WrapAclRtDeviceGetStreamPriorityRange, METH_VARARGS,
"device get stream priority range"},
{"get_device_capability", WrapAclRtGetDeviceCapability, METH_VARARGS, "get device capability"},
{"get_device_res_limit", WrapAclRtGetDeviceResLimit, METH_VARARGS, "get device res limit"},
{"set_device_res_limit", WrapAclRtSetDeviceResLimit, METH_VARARGS, "set device res limit"},
{"reset_device_res_limit", WrapAclRtResetDeviceResLimit, METH_VARARGS, "reset device res limit"},
{"get_devices_topo", WrapAclRtGetDevicesTopo, METH_VARARGS, "get devices topo"},
{"create_notify", WrapAclRtCreateNotify, METH_VARARGS, "create notify"},
{"destroy_notify", WrapAclRtDestroyNotify, METH_VARARGS, "destroy notify"},
{"record_notify", WrapAclRtRecordNotify, METH_VARARGS, "record notify"},
{"wait_and_reset_notify", WrapAclRtWaitAndResetNotify, METH_VARARGS, "wait and reset notify"},
{"get_notify_id", WrapAclRtGetNotifyId, METH_VARARGS, "get notify id"},
{"notify_batch_reset", WrapAclRtNotifyBatchReset, METH_VARARGS, "notify batch reset"},
{"notify_get_export_key", WrapAclRtNotifyGetExportKey, METH_VARARGS, "notify get export key"},
{"notify_set_import_pid", WrapAclRtNotifySetImportPid, METH_VARARGS, "notify set import pid"},
{"notify_import_by_key", WrapAclRtNotifyImportByKey, METH_VARARGS, "notify import by key"},
{"get_stream_res_limit", WrapAclRtGetStreamResLimit, METH_VARARGS, "get stream res limit"},
{"set_stream_res_limit", WrapAclRtSetStreamResLimit, METH_VARARGS, "set stream res limit"},
{"reset_stream_res_limit", WrapAclRtResetStreamResLimit, METH_VARARGS, "reset stream res limit"},
{"use_stream_res_in_current_thread", WrapAclRtUseStreamResInCurrentThread, METH_VARARGS,
"use stream res in current thread"},
{"unuse_stream_res_in_current_thread", WrapAclRtUnuseStreamResInCurrentThread, METH_VARARGS,
"unuse stream res in current thread"},
{"get_res_in_current_thread", WrapAclRtGetResInCurrentThread, METH_VARARGS, "get res in current thread"},
{"get_primary_ctx_state", WrapAclRtCtxGetPrimaryCtxState, METH_VARARGS, "get primary ctx state"},
{"get_logic_dev_id_by_user_dev_id", WrapAclRtGetLogicDevIdByUserDevId, METH_VARARGS,
"get logic dev id by user dev id"},
{"get_user_dev_id_by_logic_dev_id", WrapAclRtGetUserDevIdByLogicDevId, METH_VARARGS,
"get user dev id by logic dev id"},
{"get_logic_dev_id_by_phy_dev_id", WrapAclRtGetLogicDevIdByPhyDevId, METH_VARARGS,
"get logic dev id by phy dev id"},
{"get_phy_dev_id_by_logic_dev_id", WrapAclRtGetPhyDevIdByLogicDevId, METH_VARARGS,
"get phy dev id by logic dev id"},
{"set_op_execute_timeout_v2", WrapAclRtSetOpExecuteTimeOutV2, METH_VARARGS, "set op execute timeout v2"},
{"get_op_timeout_interval", WrapAclGetOpTimeOutInterval, METH_VARARGS, "get op timeout interval"},
{"get_op_execute_timeout", WrapAclGetOpExecuteTimeOut, METH_VARARGS, "get op execute timeout"},
{"device_get_uuid", WrapAclRtDeviceGetUuid, METH_VARARGS, "device get uuid"},
{"device_peer_access_status", WrapAclRtDevicePeerAccessStatus, METH_VARARGS, "device peer access status"},
{"host_register_v2", WrapAclRtHostRegisterV2, METH_VARARGS, "host register v2"},
{"host_get_device_pointer", WrapAclRtHostGetDevicePointer, METH_VARARGS, "host get device pointer"},
#ifdef USE_MDL
{"set_group", WrapAclRtSetGroup, METH_VARARGS, "set group"},
{"get_group_count", WrapAclRtGetGroupCount, METH_VARARGS, "get group count"},
{"create_group_info", WrapAclRtCreateGroupInfo, METH_VARARGS, "create group info"},
{"destroy_group_info", WrapAclRtDestroyGroupInfo, METH_VARARGS, "destroy group info"},
{"get_all_group_info", WrapAclRtGetAllGroupInfo, METH_VARARGS, "get all group info"},
{"get_group_info_detail", WrapAclRtGetGroupInfoDetail, METH_VARARGS, "get group info detail"},
{"get_mem_uce_info", WrapAclRtGetMemUceInfo, METH_VARARGS, "get mem uce info"},
{"mem_uce_repair", WrapAclRtMemUceRepair, METH_VARARGS, "mem uce repair"},
#endif
{nullptr, nullptr, 0, nullptr}};
}
PyMethodDef* GetRtMethods() { return g_methodsRt; }