A memory allocation method, device, equipment and storage medium

By identifying the computing subgraph and dependencies of computing units in the neural network model, allocating target data to safe areas and optimizing memory allocation, the problem of performance degradation caused by data access patterns is solved, and more efficient memory utilization and computing performance are achieved.

CN118535348BActive Publication Date: 2024-10-25YAOYAO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411001149.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-10-25
Estimated Expiration
2044-07-25

AI Technical Summary

Technical Problem

In the deployment of neural network models, due to data access patterns, data copies between the neural network processor and the central processing unit increase, resulting in increased latency and reduced performance.

Method used

By obtaining the computing subgraph of the computing unit and its dependencies, determine the target data that needs to be retained and allocate it to a safe area to ensure that the data is not affected by subsequent operations, and allocate memory to the computing unit so that its base addresses are the same and do not overlap. , to avoid additional data copies.

Benefits of technology

It saves memory address space, improves memory utilization, reduces computing latency and memory bandwidth usage, and improves the deployment performance of neural network models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535348B_ABST
    Figure CN118535348B_ABST
Patent Text Reader

Abstract

The present disclosure provides a memory allocation method, device, equipment and storage medium. The above method includes: obtaining the corresponding calculation subgraphs in the first calculation unit and the second calculation unit; based on the corresponding calculation subgraphs in the first calculation unit and the second calculation unit, and the dependency relationship between the calculation subgraphs, determining the first target data, the first target data is the memory data that the calculation unit still needs to use in subsequent calculations; allocating the first target data to a safe area, the safe area is a memory area that will not be affected by subsequent operations; allocating memory to each of the at least two calculation units; wherein the base addresses of the respective memory allocations of the first calculation unit and the second calculation unit are the same, and the respective memories of the first calculation unit and the second calculation unit do not overlap with the safe area. The present disclosure can improve the execution efficiency of the neural network model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence, specifically to the field of neural network technology in artificial intelligence, and especially to the field of neural network memory allocation optimization technology in artificial intelligence. Background Art

[0002] Artificial Intelligence (AI) is a discipline that studies how computers can simulate certain thought processes and intelligent behaviors of human beings (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. AI hardware technologies generally include technologies such as sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing; AI software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, and knowledge graph technology.

[0003] Artificial intelligence technology includes computer vision technology, speech recognition technology, natural speech processing technology, and machine learning / deep learning. Artificial intelligence technology can empower all walks of life to improve industry efficiency and achieve digital transformation.

[0004] In recent years, deep learning has developed very rapidly, making neural networks widely used in computer vision tasks such as image recognition, segmentation and tracking. In order to pursue the performance of actual deployment of neural networks, dedicated accelerated neural network processor chips are designed for operations in neural networks. The neural network processor chip adopts a data-driven parallel computing architecture, which greatly improves the running speed of neural networks. However, there are operations in a complex neural network that are not supported by the neural network processor and still require the help of the central processing unit to achieve. This involves data interaction between two heterogeneous platforms, the neural network processor and the central processing unit. In the traditional coprocessor system design, in order to protect the independence and security of memory data, the memory space of the host and the coprocessor will be isolated, but this will cause additional data movement and copying overhead. Summary of the invention

[0005] In order to solve at least one of the technical problems mentioned above, the present disclosure provides a memory allocation method, apparatus, device and storage medium.

[0006] According to a first aspect of the present disclosure, a memory allocation method is provided, which is applied to a computing device, wherein the computing device includes at least two computing units, and the at least two computing units include a first computing unit and a second computing unit, and comprises: obtaining a computing subgraph corresponding to each of the first computing unit and the second computing unit; determining first target data based on the computing subgraphs corresponding to each of the first computing unit and the second computing unit, and the dependency relationship between the computing subgraphs, wherein the first target data is memory data that the computing unit still needs to use in subsequent calculations; allocating the first target data to a safe area, wherein the safe area is a memory area that will not be affected by subsequent operations; allocating memory to each of the at least two computing units; wherein the base addresses of the respective memory allocations of the first computing unit and the second computing unit are the same, and the respective allocated memory areas of the first computing unit and the second computing unit do not overlap with the safe area.

[0007] In some possible implementations, the at least two computing units include a neural network processor and a central processing unit, the computing subgraph of the neural network processor is a computing subgraph supported by the neural network processor, and the computing subgraph of the central processing unit is a computing subgraph supported by the central processing unit.

[0008] In some possible implementations, the first target data includes input data and output data of the computational subgraph.

[0009] In some possible implementations, the method further includes: determining second target data, where the second target data is the input data and output data of the computational subgraph to which memory has been allocated; and adding the second target data to the first target data.

[0010] In some possible implementations, the method further includes: determining third target data based on the dependency relationship between the computational subgraphs and the first target data, wherein the third target data is memory data in the first target data that will no longer be used by the computational unit in subsequent calculations; and removing the third target data from the first target data.

[0011] In some possible implementations, the dependency relationship between the above-mentioned computing subgraphs is a topological relationship between the above-mentioned computing subgraphs.

[0012] According to a second aspect of the present disclosure, a memory allocation device is provided, the device comprising:

[0013] An acquisition module, used to acquire the computation subgraphs corresponding to the first computation unit and the second computation unit respectively;

[0014] A computing module, used to determine first target data based on the computing subgraphs corresponding to the first computing unit and the second computing unit, and the dependency relationship between the computing subgraphs, where the first target data is memory data that the computing unit still needs to use in subsequent computing;

[0015] A moving module, used for allocating the first target data to a safe area, where the safe area is a memory area that will not be affected by subsequent operations;

[0016] An allocation module is used to allocate memory to each of the at least two computing units mentioned above; wherein the base addresses of the memory allocations of the first computing unit and the second computing unit are the same, and the memory areas allocated to the first computing unit and the second computing unit do not overlap with the security area.

[0017] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, in which at least one instruction is stored. The at least one instruction or at least one program is loaded and executed by a processor to implement the memory allocation method as described above in the first aspect.

[0018] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements the memory allocation method as described in the first aspect by executing the instructions stored in the memory.

[0019] The present disclosure provides a memory allocation method, apparatus, device and storage medium, which determine the memory data that each computing unit still needs to use in subsequent calculations based on a calculation subgraph of at least two computing units, and allocate the memory data that still needs to be used to a safe area, so that the memory data that still needs to be used in the safe area cannot be affected by subsequent operations; further, by allocating memory to each of the at least two computing units, the memory area allocated to each computing unit does not overlap with the safe area, and at the same time, the base addresses of the memory allocations of the at least two computing units are the same, which saves memory address space and improves the utilization rate of the memory address space without the need for additional copying of data, thereby greatly reducing memory bandwidth occupancy and reducing computing delays.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0022] Figure 1 A flowchart of a memory allocation method in an embodiment of the present disclosure;

[0023] Figure 2 A flowchart of a method for updating first target data in an embodiment of the present disclosure;

[0024] Figure 3 is a flowchart of another method for updating the first target data in an embodiment of the present disclosure;

[0025] Figure 4 is a schematic diagram of the structure of a memory allocation device in an embodiment of the present disclosure;

[0026] Figure 5 A block diagram of an electronic device according to an embodiment of the present disclosure is shown;

[0027] Figure 6 A block diagram of another electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.

[0030] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0031] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0032] The term "and / or" herein is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set consisting of A, B, and C.

[0033] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0034] In scenarios such as high-performance computing and deep learning training, data access patterns are often highly parallel and complex. Each interaction between the neural network processor and the central processing unit requires an additional data copy. As the number of data copies increases, the actual delay will increase significantly, which will greatly reduce the performance of the neural network model deployment. In view of this, the embodiments of the present disclosure provide a memory allocation method to solve the problem of reduced performance of the neural network model deployment caused by the data access pattern.

[0035] Figure 1 is a flowchart of a memory allocation method in an embodiment of the present disclosure, such as Figure 1 As shown, the following steps are included:

[0036] Step S101, obtaining the calculation subgraphs corresponding to the first calculation unit and the second calculation unit respectively.

[0037] In an embodiment of the present application, the at least two computing units include a first computing unit and a second computing unit. The first computing unit and the second computing unit are names for two independent components or parts in a computing system, which may be a neural network processor, a central processing unit, a digital signal processor, a server node, an execution thread or a computing logic module, etc. Each unit is responsible for processing different tasks or data sets, and the present disclosure does not limit this. In practical applications, the at least two computing units include a neural network processor and a central processing unit, the computational subgraph of the neural network processor is the computational subgraph supported by the neural network processor, and the computational subgraph of the central processing unit is the computational subgraph supported by the central processing unit.

[0038] In an embodiment of the present application, a computational subgraph refers to a portion of a data flow graph, a control flow graph, or a computational graph associated with each computing unit. In computer science, a computational graph is a graphical representation method used to represent a computational process, which consists of nodes (representing computational operations) and edges (representing data flow). A computational subgraph is a fragment of this large graph, focusing on describing the input, output, and computational logic of a specific computing unit. Each computing unit has its own computational subgraph to describe the computational details and data flow within the unit. The computational subgraph mentioned above in the present application can be a layer, or a combination of two or more layers.

[0039] Step S102, based on the computing subgraphs corresponding to the first computing unit and the second computing unit, and the dependency relationship between the computing subgraphs, determine the first target data, where the first target data is the memory data that the computing unit still needs to use in subsequent calculations.

[0040] In an embodiment of the present application, after obtaining the corresponding computation subgraphs in each computation unit in step S101, the memory data that each computation unit still needs to use in subsequent computations is determined based on the corresponding computation subgraphs in each computation unit and the dependency relationship between the computation subgraphs. The dependency relationship may be a topological relationship between the computation subgraphs, and the topological relationship between the computation subgraphs may be a data flow direction between the computation subgraphs.

[0041] In an embodiment of the present application, the corresponding computing subgraph in each computing unit is a computing subgraph supported by the respective computing unit. The memory data that the above-mentioned computing units still need to use in subsequent calculations may be input data and output data, the results of connecting different computing units, status information or parameters. This application does not impose any restrictions on this.

[0042] After obtaining the first target data, the embodiment of the present application can determine which memory data must be retained in subsequent calculations. This process helps to optimize resource usage, reduce unnecessary data storage and transmission, and improve computing efficiency.

[0043] Step S103, allocating the first target data to a security area, where the security area is a memory area that will not be affected by subsequent operations.

[0044] In the embodiment of the present application, the allocation includes moving or copying the data to the security area, which is not limited in the present application. The security area in the present application refers to an area defined in the memory with a special protection mechanism. The purpose of the design of this area is to ensure that the data therein will not be accidentally modified or overwritten by subsequent computing operations, thereby protecting the integrity and consistency of the data.

[0045] In the embodiments of the present application, by placing key data in a safe area, data corruption caused by concurrent operations, program errors or improper resource management can be effectively prevented, thereby ensuring the stability and reliability of the computing process. In a multi-threaded environment, parallel computing or distributed system, it can help avoid problems such as data competition, deadlock or data inconsistency.

[0046] Step S104, allocating memory to each of the at least two computing units mentioned above; wherein the base addresses of the memory allocations of the first computing unit and the second computing unit are the same, and the memory areas allocated to the first computing unit and the second computing unit do not overlap with the security area.

[0047] In an embodiment of the present application, after step S103 allocates the above-mentioned first target data to the security area, memory is allocated to each of the at least two computing units so that the memory area allocated to each computing unit does not overlap with the security area. In this way, the base addresses of the memory allocations of at least two computing units are the same, which saves memory address space and improves the utilization rate of the memory address space.

[0048] In one embodiment of the present disclosure, the above method further includes updating the first target data, such as Figure 2 FIG. 1 is a flow chart of a method for updating the first target data in an embodiment of the present disclosure, and the steps are as follows:

[0049] Step S201: determining second target data, where the second target data is the input data and output data of the computation subgraph to which memory has been allocated;

[0050] Step S202: Add the second target data to the first target data.

[0051] Exemplarily, the computation subgraphs supported by the first computation unit are A, B, C, D, and E, and the computation subgraphs supported by the second computation unit are A, B, C, and F. The dependencies between the computation subgraphs are: A→B, B→C, C→D, C→E, and C→F. A→B indicates that the output data of the computation subgraph A is used as the input data of the computation subgraph B. Based on the dependencies between the computation subgraphs, it can be determined that the first target data is the output data of the computation subgraph C.

[0052] In one embodiment of the present disclosure, the above method further includes another update of the first target data, such as Figure 3 FIG. 1 is a flow chart of another method for updating the first target data in an embodiment of the present disclosure, and the steps are as follows:

[0053] Step S301: determining third target data based on the dependency relationship between the computing subgraphs and the first target data, where the third target data is memory data in the first target data that will not be used by the computing unit in subsequent computing;

[0054] Step S302: remove the third target data from the first target data.

[0055] Exemplarily, the calculation subgraphs supported by the first calculation unit are A, B, C, D, and E, and the calculation subgraphs supported by the second calculation unit are A, B, C, and F. The dependencies between the calculation subgraphs are: A→B, B→C, C→D, C→E, and C→F. Among them, A→B means that the output data of the A calculation subgraph is used as the input data of the B calculation subgraph. Based on the dependencies between the calculation subgraphs, it can be determined that the first target data is the output data of the C calculation subgraph. Based on the dependencies between the calculation subgraphs and the first target data, the third target data is determined to be the output data of the D calculation subgraph and the output data of the E calculation subgraph, and the third target data is removed from the first target data, so that the final first target data is the output data of the C calculation subgraph.

[0056] In an embodiment of the present application, the above two methods for updating the first target data constitute a dynamic data management strategy, which aims to dynamically adjust the retention and release of data in the memory according to the actual needs of the computing process to maximize resource utilization and optimize computing performance.

[0057] The present disclosure provides a memory allocation method, which determines the memory data that each computing unit still needs to use in subsequent calculations based on a calculation subgraph of at least two computing units, and allocates the memory data that still needs to be used to a secure area, so that subsequent operations cannot affect the memory data that still needs to be used in the secure area; further, by allocating memory to each of the at least two computing units, the memory area allocated to each computing unit does not overlap with the secure area, so that the base addresses of the memory allocations of the at least two computing units are the same, thereby saving memory address space and improving the utilization rate of the memory address space.

[0058] Those skilled in the art will appreciate that, in the above method of the specific implementation, the order in which the steps are written does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0059] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not go into details.

[0060] Figure 4 is a schematic diagram of the structure of the memory allocation device in the embodiment of the present disclosure, such as Figure 4 As shown, the above device comprises:

[0061] An acquisition module 401 is used to acquire the computation subgraphs corresponding to the first computation unit and the second computation unit respectively;

[0062] A calculation module 402 is used to determine first target data based on the calculation subgraphs corresponding to the first calculation unit and the second calculation unit, and the dependency relationship between the calculation subgraphs, where the first target data is memory data that the calculation unit still needs to use in subsequent calculations;

[0063] A moving module 403 is used to allocate the first target data to a safe area, where the safe area is a memory area that will not be affected by subsequent operations;

[0064] The allocation module 404 is used to allocate memory to each of the at least two computing units mentioned above; wherein the base addresses of the memory allocations of the first computing unit and the second computing unit are the same, and the memory areas allocated to the first computing unit and the second computing unit do not overlap with the security area.

[0065] In one embodiment of the present disclosure, the above-mentioned device also includes an update module, which is used to determine second target data, where the second target data is the input data and output data of the above-mentioned calculation subgraph to which memory has been allocated, and add the second target data to the above-mentioned first target data.

[0066] In one embodiment of the present disclosure, the above-mentioned device also includes a computing module, and the above-mentioned computing module is used to determine third target data based on the dependency relationship between the above-mentioned computing subgraphs and the above-mentioned first target data, and the above-mentioned third target data is memory data in the above-mentioned first target data that will no longer be used by the above-mentioned computing unit in subsequent calculations; and remove the above-mentioned third target data from the above-mentioned first target data.

[0067] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the memory allocation method described in the above embodiments. Its specific implementation can refer to the description of the above embodiments, and for the sake of brevity, it will not be repeated here.

[0068] The present disclosure also provides a computer-readable storage medium, wherein at least one instruction or at least one program is stored in the computer-readable storage medium, and when the at least one instruction or at least one program is loaded and executed by a processor, the method is implemented. The computer-readable storage medium may be a non-volatile computer-readable storage medium.

[0069] The embodiment of the present disclosure further proposes an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the memory allocation method.

[0070] The electronic device may be provided as a terminal, a server, or a device in other forms.

[0071] Figure 5 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like.

[0072] Reference Figure 5 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0073] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0074] The memory 804 is configured to store various types of data to support the operation of the electronic device 800. Examples of these data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The power supply component 806 provides power to various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing and distributing power for the electronic device 800.

[0075] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0076] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0077] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0078] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0079] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0080] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned memory allocation method.

[0081] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 804 including computer program instructions, which can be executed by a processor 820 of an electronic device 800 to perform the above-mentioned memory allocation method.

[0082] Figure 6 1 is a block diagram of another electronic device according to an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a server. Figure 6 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions that can be executed by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above-mentioned memory allocation method.

[0083] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output (I / O) interface 1958. The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.

[0084] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to perform the above-mentioned memory allocation method.

[0085] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0086] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a protruding structure in a groove on which instructions are stored, and any suitable combination thereof. The computer-readable storage medium used herein is not interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagated through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0087] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0088] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by using the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0089] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of boxes in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0090] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0091] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0092] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the above-mentioned module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the standard function in the square box can also occur in a sequence different from the standard in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a special hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0093] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A memory allocation method, characterized in that: The method is applied to a computing device, wherein the computing device includes at least two computing units, wherein the at least two computing units include a first computing unit and a second computing unit, and the method includes: Obtaining the computation subgraphs corresponding to the first computation unit and the second computation unit respectively; Determine first target data based on the computing subgraphs corresponding to the first computing unit and the second computing unit, respectively, and the dependency relationship between the computing subgraphs, where the first target data is memory data that the computing unit still needs to use in subsequent computing; Allocating the first target data to a security area, where the security area is a memory area that will not be affected by subsequent operations; Allocating memory to each of the at least two computing units; The base addresses of the respective memory allocations of the first computing unit and the second computing unit are the same, and the respective memory areas allocated to the first computing unit and the second computing unit do not overlap with the security area; Among them, the at least two computing units include a neural network processor and a central processing unit, the computing subgraph of the neural network processor is a computing subgraph supported by the neural network processor, and the computing subgraph of the central processing unit is a computing subgraph supported by the central processing unit.

2. The method according to claim 1, characterized in that The first target data includes input data and output data of the computational subgraph.

3. The method according to claim 2, characterized in that The method also includes: determining second target data, where the second target data is input data and output data of the computational subgraph to which memory has been allocated; and adding the second target data to the first target data.

4. The method according to claim 3, characterized in that The method also includes: determining third target data based on the dependency relationship between the computing subgraphs and the first target data, wherein the third target data is memory data that the computing unit in the first target data will no longer use in subsequent calculations; and removing the third target data from the first target data.

5. The method according to claim 1, characterized in that The dependency relationship between the computation subgraphs is the topological relationship between the computation subgraphs.

6. A memory allocation device, characterized in that: The device comprises at least two computing units, wherein the at least two computing units comprise a first computing unit and a second computing unit, and the device further comprises: An acquisition module, used to acquire the computation subgraphs corresponding to the first computation unit and the second computation unit respectively; A computing module, configured to determine first target data based on the computing subgraphs corresponding to the first computing unit and the second computing unit, and the dependency relationship between the computing subgraphs, wherein the first target data is memory data that the computing unit still needs to use in subsequent computing; A moving module, used for allocating the first target data to a safe area, where the safe area is a memory area that will not be affected by subsequent operations; an allocation module, configured to allocate memory to each of the at least two computing units; The base addresses of the respective memory allocations of the first computing unit and the second computing unit are the same, and the respective memory areas allocated to the first computing unit and the second computing unit do not overlap with the security area; Among them, the at least two computing units include a neural network processor and a central processing unit, the computing subgraph of the neural network processor is a computing subgraph supported by the neural network processor, and the computing subgraph of the central processing unit is a computing subgraph supported by the central processing unit.

7. The device according to claim 6, characterized in that The device also includes an updating module, which is used to determine second target data, where the second target data is the input data and output data of the computing subgraph to which memory has been allocated, and add the second target data to the first target data.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by a processor to implement the memory allocation method as described in any one of claims 1 to 5.

9. An electronic device, characterized in that: It includes at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements the memory allocation method as described in any one of claims 1 to 5 by executing the instructions stored in the memory.