Search

CN-121996418-A - Method for calling RK3588NPU calculation force by using DBus

CN121996418ACN 121996418 ACN121996418 ACN 121996418ACN-121996418-A

Abstract

The invention relates to a method for calling RK3588NPU calculation force by using DBus, belonging to the technical field of edge calculation and inter-process communication. According to the method, the standard DBus server and client architecture is constructed, the bottom computing power calling logic of the RK3588NPU is packaged into DBus service, the server runs in a daemon mode, the model loading, reasoning execution, resource management and other core logic of the package RKNN SDK are achieved, the NPU computing power calling capability is exposed through a preset DBus interface, the client does not need to be in butt joint RKNN SDK, and the server interface can be called through a DBus protocol to complete the operations of NPU model reasoning, computing power state query, model resource release and the like. The invention realizes decoupling and standardized calling of NPU computing power, reduces the development cost of sharing NPU computing power by multiple applications, improves the flexibility and efficiency of RK3588NPU computing power calling, reduces the communication delay by 35% and improves the computing power resource utilization rate by 40% compared with the existing direct calling mode.

Inventors

  • CHEN HUIXIANG
  • ZHANG ZHIYUAN
  • ZHENG JUNQIANG
  • CHEN YOUWU
  • SUN ZHIXIN
  • LUO HAIBO
  • LIU WEI
  • CHEN XING

Assignees

  • 福建中锐网络股份有限公司

Dates

Publication Date
20260508
Application Date
20260120

Claims (10)

  1. 1. A method for invoking RK3588NPU computing forces using DBus, comprising: Step 1, defining DBus service interface specifications, and defining interface names, methods and input and output parameters of NPU computing power call through XML files; step 2, constructing a DBus server, running in the RK3588 system in a daemon mode, encapsulating RKNN SDK call logic by the server, wherein the logic comprises a model loading module, an NPU reasoning module, a calculation power state acquisition module and a resource management module, the server is registered to a system DBus bus or a session DBus bus, and monitoring and responding to an interface call request of a client; Step 3, constructing a DBus client, connecting the client to a DBus bus through a DBus protocol, calling an exposed interface of a server, transmitting parameters including a model path and reasoning input data to the server, and receiving reasoning results or calculation force state data returned by the server; Step 4, after the server receives a call request of the client, loading a specified RKNN model through a model loading module, calling RK3588 NPU through an NPU reasoning module to execute reasoning operation, reading an NPU hardware register or a system node through a computing power state acquisition module to acquire computing power occupancy rate, and releasing specified model resources through a resource management module; And 5, the server packages the data comprising the reasoning result and the calculation power occupancy rate into a format supported by the DBus protocol, returns the data to the client and completes one NPU calculation power call.
  2. 2. The method of claim 1, wherein in step 1, the method comprises at least a model reasoning method, a calculation occupancy query method, and a model resource release method.
  3. 3. The method for calculating force by using DBus to call RK3588NPU according to claim 2, wherein in step 1, a model reasoning method is used for inputting data by a model path of a character string type and reasoning of a byte array type, outputting data by reasoning of the byte array type, a force occupancy query method is free of inputting parameters, outputting parameters are calculated force occupancy percentages of double-precision floating points, and a model resource release method is used for inputting parameters by a model path of the character string type and outputting parameters.
  4. 4. The method of claim 1, wherein in step 2, the model loading module includes a caching mechanism, specifically, the server maintains a model cache list, when receiving a model loading request, queries the cache list first, returns to RKNN the model context directly if the model is loaded, and calls rknn _init interface loading model and stores the model cache list if the model is not loaded, wherein the cache list supports caching of at most 10 RKNN models.
  5. 5. The method of claim 1, wherein in step 2, the specific flow of the NPU inference module performing inference is: s21, calling rknn _query interfaces to obtain the input and output quantity and the attribute of the model; s22, setting inference input data by calling rknn _inputs_set interfaces; s23, calling rknn _run interface to trigger RK3588 NPU to execute reasoning operation; S24, calling rknn _outputs_get interface to acquire reasoning output result; S25, copying the output result to an independent memory space, and calling rknn _output_release interface to release temporary output buffer.
  6. 6. The method of claim 1, wherein in step 2, the calculation power state acquisition module acquires the NPU calculation power occupancy rate by reading the data of the nodes of the RK3588 system/sys/class/rockchip/rknpu/usage, wherein the data of the nodes are double-precision floating point values of 0-100.
  7. 7. The method of claim 1, wherein in step 3, the client supports programming languages including C/c++, python, and the client converts the inferred input data into byte array format and then transmits the byte array format to the server, and receives the byte array format output data returned by the server and then converts the byte array format output data into a numerical array matching the model output dimension.
  8. 8. The method for calling RK3588NPU computational power by using DBus according to claim 1, wherein the server side further comprises a concurrent processing module, and the concurrent processing of the multi-client requests is realized through a mutual exclusion locking mechanism, so that computational power calling queuing caused by single request blocking is avoided.
  9. 9. The method of claim 1, further comprising the DBus authority configuration step of configuring access authorities of different users to the NPU computing power invocation interface by writing DBus system authority configuration files, allowing a specified normal user to invoke NPU services in the system DBus bus.
  10. 10. A computer readable storage medium having stored thereon computer program instructions executable by a processor, which when executed by the processor are capable of carrying out the steps of the method according to any one of claims 1-9.

Description

Method for calling RK3588NPU calculation force by using DBus Technical Field The invention belongs to the technical field of edge calculation and inter-process communication, and particularly relates to a method for calling RK3588NPU calculation force by using DBus. Background RK3588 is used as a flagship-level edge computing chip for the micro-pushing of a core, and the built-in NPU of the flagship-level edge computing chip has a computing power peak value of 6.0TOPS, and is a core computing power carrier for the AI reasoning and intelligent analysis of an edge end. In the prior art, the calculation of invoking RK3588 NPU mainly depends on RKNN SDK provided by a Rayleigh core micro-scale, and a developer needs to directly integrate an API interface of RKNN SDK at an application layer to finish operations such as model loading, reasoning execution, resource release and the like. However, the existing calling mode has the following technical defects: 1. The coupling degree is high, each application needing to use the NPU computing force needs to integrate RKNN SDK, the application needs to process the bottom details such as model loading, reasoning logic and the like, the application and the NPU computing force calling logic are in deep coupling, and the development cost is high; 2. Under a multi-application scene, different applications need to repeatedly load the same RKNN model, so that NPU resources are excessively occupied, and the calculation power utilization rate is low; 3. the development threshold is high, a non-professional AI developer needs to master the bottom layer calling logic of RKNN SDK, so that the development difficulty of the edge AI application is increased; 4. The communication efficiency is low, if NPU computing power is needed to be cooperatively used among multiple applications, the standardized inter-process communication mode is lacking, and the problems of high data transmission delay and non-uniform interfaces are easy to occur. DBus is used as an inter-process communication (IPC) mechanism of a Linux system standard, has the characteristics of standardization, cross-process and low coupling, and can effectively solve the problems if the DBus can be combined with RK3588 NPU calculation power call, but no related mature implementation method exists at present. Disclosure of Invention The invention aims to solve the problems of high coupling degree, difficult cross-application sharing and high development threshold of the conventional RK3588NPU calculation force calling, and provides a method for calling the RK3588NPU calculation force by using DBus, so that the standardized, low-coupling and high-efficiency calling of the NPU calculation force is realized. In order to achieve the purpose, the technical scheme of the invention is that the method for calling RK3588NPU calculation force by using DBus comprises the following steps: Step 1, defining DBus service interface specifications, and defining interface names, methods and input and output parameters of NPU computing power call through XML files; step 2, constructing a DBus server, running in the RK3588 system in a daemon mode, encapsulating RKNN SDK call logic by the server, wherein the logic comprises a model loading module, an NPU reasoning module, a calculation power state acquisition module and a resource management module, the server is registered to a system DBus bus or a session DBus bus, and monitoring and responding to an interface call request of a client; Step 3, constructing a DBus client, connecting the client to a DBus bus through a DBus protocol, calling an exposed interface of a server, transmitting parameters including a model path and reasoning input data to the server, and receiving reasoning results or calculation force state data returned by the server; Step 4, after the server receives a call request of the client, loading a specified RKNN model through a model loading module, calling RK3588 NPU through an NPU reasoning module to execute reasoning operation, reading an NPU hardware register or a system node through a computing power state acquisition module to acquire computing power occupancy rate, and releasing specified model resources through a resource management module; And 5, the server packages the data comprising the reasoning result and the calculation power occupancy rate into a format supported by the DBus protocol, returns the data to the client and completes one NPU calculation power call. Further, in step 1, the method at least includes a model reasoning method, a calculation occupancy rate query method, and a model resource release method. Further, in step 1, the model inference method is used for inputting the inference input data of the character string type model path and the byte array type, the parameter outputting is used for outputting the inference output data of the byte array type, the calculation occupancy rate query method is free of inputting the parameter outputting is used f