A method and device for calling an NPU across devices, an electronic device, and a storage medium
By converting the NPUs of terminal devices within the network into NPU service objects and utilizing the distributed hardware management service registration interface, the problem of insufficient NPU specifications on the edge side is solved, achieving efficient NPU resource scheduling across devices, reducing latency, and meeting the real-time requirements of AI tasks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN KAIHONG ZHIGU DIGITAL IND DEV CO LTD
- Filing Date
- 2024-07-29
- Publication Date
- 2026-06-09
AI Technical Summary
In existing technologies, the specifications of NPUs on edge devices are limited by space, power consumption and cost, which cannot meet the high computing power requirements. Furthermore, the edge-cloud combination method relies on the network and has high latency, which cannot meet all working conditions.
The NPU of the terminal device in the network is converted into an NPU service object through the NPU virtual service, and then registered with the distributed hardware management service through the distributed hardware management service registration interface. The target terminal queries and selects the appropriate NPU service object to process the task.
It enables efficient utilization of the NPU of devices within the network, reduces processing latency, and meets the real-time requirements of AI tasks.
Smart Images

Figure CN119031029B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of neural network processor technology, and in particular to a method, apparatus, electronic device, and storage medium for cross-device NPU invocation. Background Technology
[0002] Neural Processing Units (NPUs) are specifically designed for low-power and parallel acceleration of artificial intelligence (AI) inference. They are specifically optimized for matrix operations and play an important role in various AI fields such as natural language processing and machine vision. Due to the rapid development of generative AI, more and more edge devices are now equipped with NPUs and large models, giving them AI capabilities.
[0003] Edge AI capabilities, such as large models and video stream processing, require high computing power from NPUs. However, due to limitations in space, power consumption, and cost, the specifications of edge devices' NPUs cannot meet these requirements.
[0004] The traditional solution is to combine edge and cloud computing, where simple tasks are processed locally, while more complex tasks are processed in the cloud, with the results retrieved and returned to the user from the edge. However, this edge-cloud combination strategy has some drawbacks, such as reliance on network connectivity and high latency, and it cannot meet all operating conditions. Summary of the Invention
[0005] This invention provides a method, apparatus, electronic device, and storage medium for cross-device NPU access, enabling terminal devices within a network to utilize the NPUs of other devices and making reasonable use of NPU resources.
[0006] According to one aspect of the present invention, a method for invoking an NPU across devices is provided, comprising:
[0007] The NPU of the terminal device in the network is converted into an NPU service object through NPU virtual service, wherein the number of terminal devices in the network is at least two, and at least one of the terminal devices in the network has an NPU;
[0008] The NPU virtual service calls the registration interface of the distributed hardware management service to register the NPU service objects of each terminal device to the distributed hardware management service.
[0009] When a target terminal within the network receives a task to be processed, it queries the target information of each NPU service object within the network through the distributed hardware management service, and determines the target NPU service object to process the task based on the target information.
[0010] According to another aspect of the present invention, an apparatus for cross-device invocation of an NPU is provided, comprising:
[0011] A conversion module is used to convert the NPU of a terminal device in the network into an NPU service object, wherein the number of terminal devices in the network is at least two, and at least one of the terminal devices in the network has an NPU;
[0012] The registration module is used to call the registration interface of the distributed hardware management service through the NPU virtual service to register the NPU service objects of each terminal device to the distributed hardware management service.
[0013] The calling module is used to query the target information of each NPU service object in the network through the distributed hardware management service when the target terminal in the network receives the task to be processed, and determine the target NPU service object to process the task based on the target information.
[0014] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0015] At least one processor;
[0016] and a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the method of cross-device invocation of NPU as described in any embodiment of the present invention.
[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the method of cross-device invocation of NPU as described in any embodiment of the present invention.
[0019] The technical solution of this invention converts the NPU of a terminal device within a network into an NPU service object through an NPU virtual service. The number of terminal devices within the network is at least two, and each terminal device possesses an NPU. Through the NPU virtual service, the registration interface of the distributed hardware management service is invoked to register the NPU service objects of each terminal device with the distributed hardware management service. When a target terminal within the network receives a task to be processed, the distributed hardware management service queries the target information of each NPU service object within the network, and determines the target NPU service object for processing the task based on the target information. This technical solution solves the problem that the current edge-cloud combined approach for processing neural network tasks relies on the network and suffers from high latency, failing to meet the needs of all operating conditions. By using the distributed hardware management service, the task to be processed by the current terminal device is scheduled to the NPU service objects of other terminal devices within the network. This allows terminal devices without NPUs or with insufficient NPU computing power to use the NPUs of other terminal devices, achieving efficient utilization of the NPUs of devices within the network and reducing processing latency.
[0020] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a flowchart of a method for cross-device NPU invocation provided in Embodiment 1 of the present invention;
[0023] Figure 2 This is an architecture diagram of a cross-device NPU system provided in Embodiment 2 of the present invention;
[0024] Figure 3 This is a flowchart of a method for cross-device NPU invocation provided in Embodiment 2 of the present invention;
[0025] Figure 4 This is a schematic diagram of a device for cross-device NPU invocation provided in Embodiment 3 of the present invention;
[0026] Figure 5 This is a schematic diagram of the structure of the electronic device provided in Embodiment 4 of the present invention. Detailed Implementation
[0027] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] Example 1
[0030] Figure 1 This is a flowchart of a method for cross-device NPU invocation according to Embodiment 1 of the present invention. This embodiment is applicable to situations where a current terminal device in a network invokes the NPU resources of other terminal devices. This method can be executed by a device for cross-device NPU invocation, which can be implemented in hardware and / or software and can be configured in the terminal device. Figure 1 As shown, the method includes:
[0031] S110. Convert the NPU of the terminal device in the network into an NPU service object through NPU virtual service.
[0032] Among them, the NPU virtual service is used to transform the functions of the NPU hardware of the terminal device into a service form that can be called through the network, namely the NPU service object; networking can be understood as building a communication network between terminal devices. The number of terminal devices in the network can be two or more, and at least one of the terminal devices in the network has an NPU. The network can include terminal devices with NPUs or terminal devices without NPUs.
[0033] Specifically, the NPU hardware resources of terminal devices within the network can be abstracted through NPU virtual services to obtain service forms that can be invoked over the network, namely NPU service objects.
[0034] In this embodiment of the invention, the step of converting the NPU of a terminal device within a network into an NPU service object through an NPU virtual service includes: deploying an NPU virtual service in the terminal device within the network; abstracting the NPU hardware of the terminal device through the NPU virtual service to obtain the abstracted NPU function; defining a target interface; and encapsulating the target interface and the abstracted NPU function into the NPU service object.
[0035] Specifically, an NPU virtual service is deployed on the terminal devices within the network. This service abstracts the NPU hardware of the terminal devices, identifying and extracting the core functions and features of the NPU. Next, a standard interface, or target interface, is defined to shield the differences between different NPU hardware and vendor SDKs. Further, the abstracted NPU functions and the defined standard interface are encapsulated into an NPU service object. This encapsulated NPU service object can be exposed to other terminal devices within the network via a software bus or other proprietary protocols. Other terminal devices can connect to this device via the network and invoke the provided NPU service object.
[0036] like Figure 2 The diagram shown is an architecture diagram of a cross-device NPU system provided in Embodiment 2 of the present invention. The system includes two terminal devices, device 1 and device 2, each with an NPU. Distributed hardware management services and NPU virtual services (NPU service objects) are deployed on both device 1 and device 2.
[0037] S120. Through the NPU virtual service, call the registration interface of the distributed hardware management service to register the NPU service objects of each terminal device to the distributed hardware management service.
[0038] The distributed hardware management service provides registration, deregistration, and query interfaces. The registration interface is used to register NPU service objects, the deregistration interface is used to deregister NPU service objects, and the query interface is used to query information about each NPU service object.
[0039] Specifically, when the terminal device starts up, it calls the registration interface of the distributed hardware management service through the NPU virtual service. Through this interface, the NPU service object is registered with the distributed hardware management service so that the distributed hardware management service can manage and allocate the NPU service object.
[0040] In this embodiment of the invention, after registering the NPU service objects of each terminal device to the distributed hardware management service, the method further includes: updating the target information of each NPU service object in real time through the distributed hardware management service.
[0041] The target information includes at least one of computing power information and load information.
[0042] Specifically, the distributed hardware management service is responsible for managing all information about the NPU service object, such as computing power, the device it belongs to, and its current operating status. The distributed hardware management service can obtain and update this information in real time and provide a query interface for the local machine and other devices in the network to query and obtain it.
[0043] S130. When the target terminal in the network receives the task to be processed, it queries the target information of each NPU service object in the network through the distributed hardware management service, and determines the target NPU service object to process the task to be processed based on the target information.
[0044] The target terminal can be a terminal device that receives the task to be processed, the task to be processed can be an AI task, and the target NPU service object can be an NPU service object used to execute the task to be processed.
[0045] Specifically, the client on the target terminal can query the target information of the NPU service objects of each terminal device in the network through the distributed hardware management service, and select a suitable NPU service object as the target NPU service object according to task requirements and load conditions. Then, it makes a service call to the target NPU service object to process the AI task.
[0046] Preferably, the communication method between terminal devices within the network includes at least one of soft bus, Bluetooth, Wi-Fi, and StarFlash.
[0047] Specifically, terminal devices within the network can invoke the NPU service objects of other terminals within the network through the aforementioned communication methods, eliminating the need to upload data related to the task to be processed to the cloud for processing via long-distance communication, thereby reducing network latency, improving task execution efficiency, and meeting the real-time requirements of AI task processing.
[0048] The technical solution of this invention converts the NPU of a terminal device within a network into an NPU service object through an NPU virtual service. The number of terminal devices within the network is at least two, and each terminal device possesses an NPU. Through the NPU virtual service, the registration interface of the distributed hardware management service is invoked to register the NPU service objects of each terminal device with the distributed hardware management service. When a target terminal within the network receives a task to be processed, the distributed hardware management service queries the target information of each NPU service object within the network, and determines the target NPU service object for processing the task based on the target information. This technical solution solves the problem that the current edge-cloud combined approach for processing neural network tasks relies on the network and suffers from high latency, failing to meet the needs of all operating conditions. By using the distributed hardware management service, the task to be processed by the current terminal device is scheduled to the NPU service objects of other terminal devices within the network. This allows terminal devices without NPUs or with insufficient NPU computing power to use the NPUs of other terminal devices, achieving efficient utilization of the NPUs of devices within the network and reducing processing latency.
[0049] Example 2
[0050] Figure 3 This is a flowchart illustrating a method for cross-device NPU invocation according to Embodiment 2 of the present invention. This embodiment further refines the processing procedure of the task to be processed based on the above embodiments. Specific implementation details can be found in the technical solution of this embodiment. Technical terms that are the same as or corresponding to those in the above embodiments will not be repeated here. Figure 3 As shown, the method includes:
[0051] S210. Convert the NPU of the terminal device in the network into an NPU service object through NPU virtual service.
[0052] The number of terminal devices in the network is at least two, and at least one of the terminal devices in the network has an NPU.
[0053] S220. Through the NPU virtual service, call the registration interface of the distributed hardware management service to register the NPU service objects of each terminal device to the distributed hardware management service.
[0054] S230. When the target terminal in the network receives a task to be processed, it queries the target information of the NPU service object corresponding to each terminal device in the network through the distributed hardware management service.
[0055] S240. Based on the target information, select a target NPU service object from among the multiple NPU service objects.
[0056] The terminal device corresponding to the target NPU service object is the terminal to be used. The terminal to be used can be a device that is different from the target terminal. For example, even if the target terminal does not have an NPU, it can still complete the AI task by using the target NPU service object of the terminal to be used through cross-device means.
[0057] It's understandable that multiple terminal devices within a network can possess NPUs. By converting the NPU hardware of each terminal device into NPU service objects, multiple NPU service objects can be obtained, each with different resource requirements. Therefore, computing resources can be rationally scheduled according to different tasks to maximize the utilization of computing resources. For example, based on the computing power required for the current task and the NPU load, a suitable NPU service object can be selected as the target NPU service object to run the current task.
[0058] S250. Determine the interface name and input parameters of the task to be processed, and pass in the interface name and input parameters so as to process the task to be processed through the target NPU service object and obtain the processing result of the task to be processed.
[0059] Specifically, the client on the target terminal queries the virtual NPU information of devices within the network through the distributed hardware management service. Based on this information, it obtains one of the NPU service objects, passes in the interface name and input parameters, and performs distributed service calls through this object. After receiving the interface name and input parameters, the target NPU service object processes the task according to preset logic. When the task is completed, the target NPU service object returns the processing result.
[0060] In this embodiment of the invention, the method further includes: when the target NPU service object is invoked for the first time, assigning a target identifier to the client invoking the target NPU service object and saving context information based on the target identifier; when the client repeatedly invokes the target NPU service object, obtaining and saving the context information based on the target identifier, and processing the task to be processed based on the context information.
[0061] The context information includes input data, intermediate results, and final results.
[0062] Specifically, when a client first invokes the NPU service object, the system assigns it a unique sessionId, which serves as the target identifier. The server maintains the context of each call based on the sessionId, including input data, intermediate results, and the final result. Through the sessionId, the server can maintain data consistency across multiple calls, ensuring the accuracy and integrity of the computation. The server provides multiple interfaces, supports multiple calls, and multi-threaded calls. In different calls, the server uses the passed sessionId to determine which group of calls it belongs to, thereby retrieving the context saved from previous calls and obtaining the intermediate data generated in previous calls, ensuring a consistent environment and complete and usable data. For each call, the caller's identity is verified to confirm whether they are the creator of the context.
[0063] S260. The processing result is fed back to the target terminal.
[0064] Specifically, the processing results can be fed back to the client on the target terminal.
[0065] This allows devices within the network to utilize the NPU capabilities of other devices, rationally scheduling computing resources based on different tasks to maximize the utilization of computational resources. For example, based on the computing power required for the current task and the NPU load, appropriate NPU resources are selected to run the task. This enables: 1. Devices without NPUs to complete AI tasks through cross-device collaboration; 2. Devices with insufficient computing power to complete complex AI task calculations through distributed computing.
[0066] The technical solution of this invention converts the NPU of a terminal device within a network into an NPU service object through an NPU virtual service. The number of terminal devices within the network is at least two, and each terminal device possesses an NPU. Through the NPU virtual service, the registration interface of the distributed hardware management service is invoked to register the NPU service objects of each terminal device with the distributed hardware management service. When a target terminal within the network receives a task to be processed, the distributed hardware management service queries the target information of each NPU service object within the network, and determines the target NPU service object for processing the task based on the target information. This technical solution solves the problem that the current edge-cloud combined approach for processing neural network tasks relies on the network and suffers from high latency, failing to meet the needs of all operating conditions. By using the distributed hardware management service, the task to be processed by the current terminal device is scheduled to the NPU service objects of other terminal devices within the network. This allows terminal devices without NPUs or with insufficient NPU computing power to use the NPUs of other terminal devices, achieving efficient utilization of the NPUs of devices within the network and reducing processing latency.
[0067] Example 3
[0068] Figure 4 This is a schematic diagram of a device for cross-device NPU invocation provided in Embodiment 3 of the present invention. Figure 4 As shown, the device includes:
[0069] The conversion module 310 is used to convert the NPU of a terminal device in the network into an NPU service object, wherein the number of terminal devices in the network is at least two, and at least one of the terminal devices in the network has an NPU;
[0070] The registration module 320 is used to call the registration interface of the distributed hardware management service through the NPU virtual service to register the NPU service objects of each terminal device to the distributed hardware management service.
[0071] The calling module 330 is used to query the target information of each NPU service object in the network through the distributed hardware management service when the target terminal in the network receives the task to be processed, and determine the target NPU service object to process the task based on the target information.
[0072] The technical solution of this invention converts the NPU of a terminal device within a network into an NPU service object through an NPU virtual service. The number of terminal devices within the network is at least two, and each terminal device possesses an NPU. Through the NPU virtual service, the registration interface of the distributed hardware management service is invoked to register the NPU service objects of each terminal device with the distributed hardware management service. When a target terminal within the network receives a task to be processed, the distributed hardware management service queries the target information of each NPU service object within the network, and determines the target NPU service object for processing the task based on the target information. This technical solution solves the problem that the current edge-cloud combined approach for processing neural network tasks relies on the network and suffers from high latency, failing to meet the needs of all operating conditions. By using the distributed hardware management service, the task to be processed by the current terminal device is scheduled to the NPU service objects of other terminal devices within the network. This allows terminal devices without NPUs or with insufficient NPU computing power to use the NPUs of other terminal devices, achieving efficient utilization of the NPUs of devices within the network and reducing processing latency.
[0073] Optional, the conversion module 310 is specifically used for:
[0074] An NPU virtual service is deployed in the terminal device within the network. The NPU virtual service is used to abstract the NPU hardware of the terminal device to obtain the abstracted NPU function.
[0075] Define the target interface, and encapsulate the target interface and the abstracted NPU functionality into the NPU service object.
[0076] Optionally, the device further includes a state refinement module, configured to: after registering the NPU service objects of each terminal device to the distributed hardware management service, update the target information of each NPU service object in real time through the distributed hardware management service, wherein the target information includes at least one of computing power information and load information.
[0077] Optionally, the calling module 330 is specifically used for:
[0078] The distributed hardware management service queries the target information of the NPU service object corresponding to each terminal device in the network.
[0079] Based on the target information, a target NPU service object is selected from a plurality of NPU service objects, wherein the terminal device corresponding to the target NPU service object is the terminal to be used.
[0080] Optionally, after determining the target NPU service object for processing the task to be processed based on the target information, the method further includes:
[0081] Determine the interface name and input parameters of the task to be processed, and pass in the interface name and input parameters so that the task to be processed can be processed through the target NPU service object to obtain the processing result of the task to be processed;
[0082] The processing result is then fed back to the target terminal.
[0083] Optionally, the device is also used for:
[0084] When the target NPU service object is invoked for the first time, a target identifier is assigned to the client invoking the target NPU service object, and context information is saved based on the target identifier, wherein the context information includes at least one of input data, intermediate results and final results;
[0085] When the client repeatedly calls the target NPU service object, the client obtains and saves context information based on the target identifier, and processes the task to be processed based on the context information.
[0086] Optionally, the communication methods between terminal devices within the network include at least one of soft bus, Bluetooth, Wi-Fi, and StarFlash.
[0087] The cross-device NPU invocation apparatus provided in the embodiments of the present invention can execute the cross-device NPU invocation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0088] Example 4
[0089] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0090] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0091] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0092] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as a method of invoking an NPU across devices.
[0093] In some embodiments, a method for cross-device NPU invocation may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the method for cross-device NPU invocation described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform a method for cross-device NPU invocation by any other suitable means (e.g., by means of firmware).
[0094] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0095] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0096] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0097] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0098] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0099] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0100] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0101] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for cross-device invocation of a neural network processor (NPU), characterized in that, include: The NPU of the terminal device in the network is converted into an NPU service object through NPU virtual service, wherein the number of terminal devices in the network is at least two, and at least one of the terminal devices in the network has an NPU; The NPU virtual service calls the registration interface of the distributed hardware management service to register the NPU service objects of each terminal device to the distributed hardware management service. When a target terminal in the network receives a task to be processed, it queries the target information of each NPU service object in the network through the distributed hardware management service, and determines the target NPU service object to process the task based on the target information. The step of converting the NPU of a terminal device within the network into an NPU service object through an NPU virtual service includes: deploying an NPU virtual service in the terminal device within the network; abstracting the NPU hardware of the terminal device through the NPU virtual service to obtain the abstracted NPU function; defining a target interface; and encapsulating the target interface and the abstracted NPU function into the NPU service object. After determining the target NPU service object for processing the task to be processed based on the target information, the method further includes: determining the interface name and input parameters of the task to be processed, and passing in the interface name and input parameters so as to process the task to be processed through the target NPU service object to obtain the processing result of the task to be processed; and feeding back the processing result to the target terminal. The method further includes: When the target NPU service object is invoked for the first time, a target identifier is assigned to the client invoking the target NPU service object, and context information is saved based on the target identifier, wherein the context information includes at least one of input data, intermediate results and final results; When the client repeatedly calls the target NPU service object, the client obtains and saves context information based on the target identifier, and processes the task to be processed based on the context information. The method further includes: When a client first calls the target NPU service object, the system assigns a unique sessionId to the client as the target identifier. The server maintains the context corresponding to the client's call based on the sessionId. The context includes input data, intermediate results, and final results. The server supports multiple interface calls, multiple calls, and multi-threaded calls. When the client makes different calls to the target NPU service object, the server identifies the call group by the passed sessionId, and then obtains the context and intermediate data previously saved by the call group to ensure the consistency of the call environment and the integrity of the data. For each call made by the client to the target NPU service object, the server verifies whether the caller is the creator of the context corresponding to that call; The communication methods between terminal devices within the network include at least one of soft bus, Bluetooth, Wi-Fi, and StarFlash.
2. The method according to claim 1, characterized in that, After registering the NPU service objects of each terminal device to the distributed hardware management service, the method further includes: The distributed hardware management service updates the target information of each NPU service object in real time, wherein the target information includes at least one of computing power information and load information.
3. The method according to claim 1, characterized in that, The step of querying the target information of each NPU service object within the network through the distributed hardware management service, and determining the target NPU service object for processing the task to be processed based on the target information, includes: The distributed hardware management service queries the target information of the NPU service object corresponding to each terminal device in the network. Based on the target information, a target NPU service object is selected from a plurality of NPU service objects, wherein the terminal device corresponding to the target NPU service object is the terminal to be used.
4. A device for cross-device access to a neural network processor (NPU), characterized in that, include: A conversion module is used to convert the NPU of a terminal device in the network into an NPU service object, wherein the number of terminal devices in the network is at least two, and at least one of the terminal devices in the network has an NPU; The registration module is used to call the registration interface of the distributed hardware management service through the NPU virtual service to register the NPU service objects of each terminal device to the distributed hardware management service. The calling module is used to query the target information of each NPU service object in the network through the distributed hardware management service when the target terminal in the network receives the task to be processed, and determine the target NPU service object to process the task to be processed based on the target information. The conversion module is specifically used for: An NPU virtual service is deployed in the terminal device within the network. The NPU virtual service is used to abstract the NPU hardware of the terminal device to obtain the abstracted NPU function. Define the target interface, and encapsulate the target interface and the abstracted NPU functionality into the NPU service object; After determining the target NPU service object for processing the task to be processed based on the target information, the method further includes: Determine the interface name and input parameters of the task to be processed, and pass in the interface name and input parameters so that the task to be processed can be processed through the target NPU service object to obtain the processing result of the task to be processed; The processing result is then fed back to the target terminal. The device is also used for: When the target NPU service object is invoked for the first time, a target identifier is assigned to the client invoking the target NPU service object, and context information is saved based on the target identifier, wherein the context information includes at least one of input data, intermediate results and final results; When the client repeatedly calls the target NPU service object, the client obtains and saves context information based on the target identifier, and processes the task to be processed based on the context information. The communication methods between terminal devices within the network include at least one of soft bus, Bluetooth, Wi-Fi, and StarFlash. When a client first calls the target NPU service object, the system assigns a unique sessionId to the client as the target identifier. The server maintains the context corresponding to the client's call based on the sessionId. The context includes input data, intermediate results, and final results. The server supports multiple interface calls, multiple calls, and multi-threaded calls. When the client makes different calls to the target NPU service object, the server identifies the call group by the passed sessionId, and then obtains the context and intermediate data previously saved by the call group to ensure the consistency of the call environment and the integrity of the data. For each call made by the client to the target NPU service object, the server verifies whether the caller is the creator of the context corresponding to that call; The communication methods between terminal devices within the network include at least one of soft bus, Bluetooth, Wi-Fi, and StarFlash.
5. An electronic device, characterized in that, The electronic device includes: At least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor to enable the at least one processor to perform the method of cross-device invocation of the neural network processor (NPU) as described in any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a processor to execute the method of cross-device invocation of a neural network processor (NPU) as described in any one of claims 1-3.