Method for providing neural network to data processing device
The method optimizes neural network implementation on data processing devices by using a Pareto front approach to balance memory and execution time, addressing inefficiencies in existing neural network adaptations.
Patent Information
- Application Number
- JP2024044199
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-20
- Filing Date
- 2024-03-19
- Publication Date
- 2024-10-03
AI Technical Summary
Existing neural networks are not optimally adapted to the specific hardware constraints of data processing devices, leading to inefficiencies in memory and execution time, which varies significantly across different implementations.
A method to generate and select neural network implementation variants that optimize working memory demand, non-volatile memory demand, and execution time simultaneously, using a Pareto front approach to ensure optimal performance without degrading other factors, allowing users to choose the best variant based on their device's capabilities.
This method ensures efficient neural network deployment on data processing devices by optimizing memory and execution time, ensuring the chosen variant meets the device's requirements without compromising accuracy.
Smart Images

Figure 2024134549000001_ABST
Abstract
Description
[Technical field]
[0001] The present disclosure relates to a method for providing a neural network to a data processing apparatus. [Background technology]
[0002] Neural networks can be used for many tasks, in particular control tasks, such as driver assistance, robot control or other control of any kind of machine. Here, different implementations of "equivalent" neural networks (i.e. implementations that provide the same output with the same input) can have very different requirements in terms of RAM, non-volatile memory and execution time. Depending on the application and the available hardware, i.e. the data processing device (e.g. microcontroller) on which the neural network is executed, these requirements may be met more or less well or may be more or less important depending on the application. Therefore, an approach is desired that allows to provide a neural network appropriately for a given data processing device. Summary of the Invention [Means for solving the problem]
[0003] According to various embodiments, a method for providing a neural network on a data processing device is provided, the method comprising: determining a subset of a plurality of implementation variants of the neural network from a set of implementation variants of the neural network, where each implementation variant of the subset, which is not related to any of working memory demand, non-volatile memory demand, and execution time when executed on the data processing device, can be improved without degrading at least one of the other two of working memory demand, non-volatile memory demand, and execution time, and further, the subset for each of working memory demand, non-volatile memory demand, and execution time when executed on the data processing device includes at least one respective implementation variant that is optimal in this respect under the set of implementation variants. The method further comprises the steps of selecting one of the determined implementation variants according to a user input specifying a selection from the subset, and storing the selected implementation variant in the data processing device.
[0004] The above-described method allows for efficient provision of neural networks on a data processing device, taking into account the technical conditions of the data processing device and the respective application (e.g. devices controlled by the data processing device), and the user is provided with the means to select the implementation variant that is optimal (within the framework of computational accuracy or available implementations) with respect to the available data processing device and the respective application (and the resulting working memory demands, non-volatile memory demands and execution time prioritization).
[0005] Data processing devices use, for example, neural networks for control tasks, i.e. for controlling devices such as robots.
[0006] In the following, various examples are given.
[0007] Example 1 is a method for providing a neural network as described above.
[0008] Example 2 is a method according to Example 1, comprising the steps of: determining a set of layers of a neural network that have a longer execution time on a data processing device than other layers of the neural network when the neural network is implemented according to a reference implementation; determining various layer implementation variants for each layer of the set; determining implementation variants of the neural network by combining the determined layer implementation variants with an implementation variant of the neural network, where for layers that are not part of the set, a respective pre-set reference implementation is used; determining a subset of implementation variants by determining working memory demand, non-volatile memory demand and execution time for each of the determined implementation variants; and adding the determined implementation variant to the subset, whereby the subset or the implementation variants contained therein satisfy the above condition.
[0009] This allows for efficient computation of the subset, in particular by determining only those layer implementation variants for those layers whose execution time (i.e., computational cost) contributes most to the total execution time, e.g., above a pre-set threshold (e.g., 1%-5% of the execution time). For example, layer implementation variants that are optimal, respectively, with respect to at least one of memory demand, non-volatile memory demand, and execution time can be combined together to generate a subset of implementation variants (or at least candidate implementation variants for the subset of implementation variants to be added to the subset such that the subset or the implementation variants contained therein satisfy the above conditions). To determine the memory demand, non-volatile memory demand, and execution time, these layers are implemented according to the determined layer implementation.
[0010] Example 3 is the method of example 1 or 2, wherein all implementation variants of the set of implementation variants for an identical input to an input layer of the neural network provide identical outputs to an output layer of the neural network (i.e., are numerically identical).
[0011] This ensures that no accuracy is lost by optimizing the neural network implementation according to the methods described above.
[0012] Example 4 is the method of any one of Examples 1 to 3, wherein the implementation variant comprises at least one of the following: A set of layers implemented with the same computation function, A set of layers implemented with respective computational functions adapted to input variables, output variables and / or one or more quantization parameters of the layers and / or parameters such as kernel variables in the convolution; The data type used to store the weights in working memory, and A set of layers whose calculations are implemented using lookup tables They differ in at least one of the following:
[0013] These parameters provide efficient effects on memory demands, volatile memory demands and execution time without changing the output of the neural network. The data type determines, for example, whether weights require more memory space but can therefore be loaded directly into the processor.
[0014] Example 5 is a method according to any one of Examples 1 to 4, comprising the steps of receiving (e.g., by receiving corresponding user input) a specification of limitations of the data processing device relating to at least one of the non-volatile memory and the working memory, and determining a subset of implementation variants such that the implementation variants of the subset comply with the limitations.
[0015] This makes it possible to ensure that the implementation variant chosen corresponds to the capabilities of the data processing device.
[0016] Example 6 is a method according to any one of Examples 1 to 5, comprising receiving (e.g., by receiving corresponding user input) a specification of application requirements relating to at least one of a maximum computation time, a maximum non-volatile memory demand, and a maximum working memory demand, and determining a subset of implementation variants such that the implementation variants of the subset satisfy the application requirements.
[0017] This makes it possible to ensure that the implementation variant chosen corresponds to the requirements of the respective application (i.e. the respective task of the neural network).
[0018] Example 7 is a computer system configured to carry out the method according to any one of Examples 1 to 6.
[0019] Example 8 is a computer program comprising instructions that, when executed by a processor, cause the processor to perform the method according to any one of Examples 1 to 6.
[0020] Example 9 is a computer-readable medium having stored thereon instructions that, when executed by a processor, cause the processor to perform a method according to any one of Examples 1 to 6.
[0021] In the drawings, like reference characters generally refer to like parts in all the various drawings. The drawings are not necessarily to scale, emphasis instead being placed herein generally on illustrating the principles of the invention. In the following description, various aspects are described with reference to the following drawings: [Brief description of the drawings]
[0022] [Figure 1] FIG. 1 shows a device with a microcontroller. [Diagram 2] FIG. 1 is a schematic diagram showing a Pareto front. [Diagram 3]1 is a flow chart illustrating a method for providing a neural network on a data processing apparatus according to one embodiment. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0023] In the following detailed description, reference is made to the accompanying drawings, which show specific details and aspects for the purposes of illustration of the present disclosure in which the present invention can be implemented. Other aspects can be used, and structural, logical and electrical changes can be made, without departing from the scope of protection of the present invention. Various aspects of the present disclosure are not necessarily mutually exclusive, since some aspects of the present disclosure can be combined with one or more other aspects of the present disclosure to form new aspects.
[0024] In the following, various examples are explained more precisely.
[0025] FIG. 1 shows a device 100 that includes a microcontroller 102 .
[0026] The device 100 may be any type of robotic device and / or machine, e.g., a vehicle, a robotic arm, a washing machine, a drill, etc. The microcontroller 102 may have any control task in such a device, e.g., control of brakes, motors, etc.
[0027] The microcontroller 102 uses for this purpose a neural network 103, which (in the form of the specification of the neural network, in particular its weights) is stored in a non-volatile memory 104 (e.g. a flash memory) of the microcontroller 102 and is loaded for execution (e.g. when the device is switched on) into a working memory 105 (i.e. a RAM) of the microcontroller 102 and executed by a processor 106 (which may be several individual processors or processor cores).
[0028] Microcontrollers are at the lower end of the performance scale in terms of computational power, flash size and RAM size. Software for this hardware is therefore limited in three directions. In other respects, neural networks are computationally intensive. They have high working memory demands due to the activations to be stored and high flash demands due to the trained parameters. Their use on microcontrollers imposes limitations on the number of layers and the size of the layers. To save additional computation time, RAM and flash, int8 quantized networks are often used instead of float32 networks.
[0029] Moreover, a given neural network can be implemented in different ways. These implementations are bit-for-bit identical in terms of numerical results (i.e., they provide identical results for identical inputs), but differ in terms of computation time, working memory demands and non-volatile memory demands. Thus, the implementations can also be adapted to the internal needs of the respective overall system (here, device 100). Examples of different requirements are: The neural network 103 is called very frequently, for example once per rotation of a drilling machine or a washing machine. In this case the computation time becomes the most important criterion. The neural network 103 is only needed once when switching on the device 100, e.g. for self-diagnosis. The calculation time is therefore not critical and the working memory is of secondary importance, since it can be used again later by other functions. However, the non-volatile memory demand should be minimized as much as possible in order to have space for other functions. The neural network 103 should be used in devices 100 that need to keep a lot of data in working memory during operation. Therefore, working memory demand is the primary criterion. Neural networks should run as efficiently as possible, but can use up to 20kB of flash for this.
[0030] The implementation of neural networks for microcontrollers is often not done manually, but with tools specially developed for this purpose, but they are not in a position to generate various implementations with different compromises between computation time, working memory demands and non-volatile memory demands.Neural networks can be compressed by quantization, but this changes the numerical result of the neural network.
[0031] According to various embodiments, various implementations of the neural network are generated automatically, for example by the computer system 101. In contrast to quantization and pruning techniques, all implementations are strictly identical numerically (i.e. they provide the same output under the same input). However, they differ in the required computation time, working memory demand and non-volatile memory demand. Here, among all possible implementations, those that lie on the Pareto front (computation time, memory demand and non-volatile memory demand) are selected. If the number of implementations on the Pareto front is too large, very similar implementations are further removed from these.
[0032] The resulting set of implementations is offered to each user for selection, for example on the screen 108 of the computer system 101, listing their computation time, working memory demand and non-volatile memory demand. An implementation is then selected according to the user input and allowed to be loaded into the microcontroller 102 (by connection via cable, wireless connection, via USB stick, etc.).
[0033] For example, the computer system 101 generates C code for the neural network 103 in order to be able to finally install the trained neural network 103 (according to the selected implementation) on a microcontroller. In this case, the computer system 101, according to one embodiment, does not generate an implementation but generates a set of numerically identical implementations on a Pareto front (a space extended by computation time, memory demand and non-volatile memory demand). For the generated implementations, the properties (computation time, memory demand, non-volatile memory demand) are listed to the user and / or the Pareto front is shown graphically on the display 108.
[0034] Figure 2 shows a schematic diagram of such a Pareto front 200. These parameters are the computation time, the working memory demand and the non-volatile memory demand. Implementations on the Pareto surface, here shown in a two-dimensional simplified manner by the dotted line, are proposed to the user for selection.
[0035] The user can then choose the implementation that best corresponds to his requirements (or to the requirements of the device 100). Possible techniques for generating the different implementations are as follows. To save non-volatile memory, all layers of one type (e.g. fully connected layers or convolutional layers) can be implemented with only one function that is called for all layers (e.g. a function from a library) To improve computation time at the expense of non-volatile memory requirements, all layers of one type can be implemented by a single optimized function adapted to parameters such as input and output sizes, quantization parameters, and convolution kernel sizes. To save computation time at the expense of working memory, layer weights that are particularly computationally intensive can be permanently loaded into working memory and thereby made more quickly available to the processor 106 during computation. A particular layer can be implemented either algorithmically (longer computation time, lower non-volatile memory demands) or using lookup tables (lower computation time, higher non-volatile memory demands).
[0036] Various implementations can be easily categorized layer by layer with respect to inference time (i.e., execution time of a forward pass through the neural network). Non-volatile memory demand depends on the overall configuration, but can be relatively well estimated since the amount of memory required for individual layers is relatively constant. (Two different high-density implementations, highly optimized for input and output sizes, will have nearly identical non-volatile memory demands unless specific parts of the code can be optimized.) The working memory demand of an implementation arises from the amount of activations to be stored and can be precisely measured. From information about the individual layers, various parameters of possible implementations can be determined and listed.
[0037] The above approach takes into account a wide range of requirements for different applications, including: The implementation to choose depends on the target hardware: different microcontrollers may have significantly different amounts of non-volatile memory (e.g. flash memory). Some applications have stringent requirements, e.g. flash memory limit of 20kB or maximum inference time of 6ms. Other applications have less specific requirements and require the fastest possible implementation with as little non-volatile memory as possible. If there is still enough headroom left, a larger neural network can be chosen if necessary.
[0038] Therefore, on the one hand, optimizing for individual goal variables such as "optimizing for code size" or "optimizing for speed" as in the case of a compiler is insufficient. On the other hand, the above-mentioned approach avoids burdening the user with a large number of arbitrary options for defining each implementation by allowing the implementation to be selected from a Pareto surface (i.e., a Pareto front).
[0039] The Pareto surface can be determined, for example, by taking into account the following characteristics: The execution time of the neural network 103 (i.e., inference using the neural network) is, with some deviations, the sum of the execution times of the individual layers. · The total non-volatile memory demand consists of the non-volatile memory demand of all trained parameters (typically weights) and the non-volatile memory demand of the implemented functions (e.g. layer operations). This does not depend on whether layers share implementations or each layer has its own implementation. The amount of non-volatile memory required is calculated as the memory demand of the parameters + the memory demand of the implemented functions required. In the case of a unique implementation for each layer, there will be one function per layer, otherwise there will be one function for multiple layers. The flash demand can be easily determined from the functions and parameters used. For example, if in one implementation there is one function for two layers and in another implementation there are two functions, then the additional flash demand will be the additional function. There is no interaction with other layers of the network, as there is with the working memory demand. Working memory demand is a general property. Memory space may be reused by other layers in some cases, so an increase in the working memory demand of an individual layer does not necessarily increase the overall working memory demand.
[0040] The computer system 101 determines a subset of implementation variations to be presented to the user for selection, for example, as follows. 1. The layers of the neural network 103 are grouped according to their expected computational demands, which can be determined by measuring a reference implementation of each layer on the target hardware (i.e., on the microcontroller 102). 2. The computer system 101 generates various implementations of the neural network 103 layer by layer, starting from the layer with the highest computational demand, and measures or calculates the non-volatile memory demand, the local working memory demand and the computation time of the currently implemented layer. That is, the computer system 101 determines various implementations for each layer (also referred to herein as layer implementations to distinguish them from the implementation of the entire neural network). For frequently occurring layer configurations, these values can also be filed in a database. 3. For layers that contribute less than a certain limit (approximately 1%-5%) to the overall computational demand, the computer system 101 can directly present a memory-efficient reference implementation (working memory and non-volatile memory) in order to avoid an excessive number of layer implementations and neural network implementations to be observed. 4. The computer system 101 now combines together the layer implementations found for the implementation of the neural network 103. A memory budget is calculated for each combination (i.e., each implementation of the neural network 103) to determine the working memory demands. 5. From a given triple (inference time, working memory demand, non-volatile memory demand), the computer system 101 computes the Pareto front and presents to the user only the implementations (of neural networks) on the Pareto front for selection (e.g., on the display 108). The computation of the Pareto front can be implemented using standard libraries, e.g., the OApackage for Python.
[0041] In summary, various embodiments provide a method as illustrated in FIG.
[0042] FIG. 3 shows a flow chart 300 illustrating a method for providing a neural network on a data processing device according to one embodiment.
[0043] In step 301, from the set of implementation variants of the neural network, a subset is determined that comprises multiple implementation variants of the neural network (i.e. a subset of the set of implementation variants, thus the subset itself comprises multiple implementation variants, in the above example these are the implementation variants on the Pareto front), where: Each implementation variant of the subset that is not related to either the working memory demand (e.g. RAM demand), the non-volatile memory demand (e.g. Flash demand) or the execution time when executed on a data processing device (i.e. the computational cost, e.g. the execution time of a forward pass through a neural network, i.e. the execution time of an inference using a neural network) can be improved without degrading at least one of the other two of the working memory demand, the non-volatile memory demand and the execution time. The subsets for each of the working memory demand, the non-volatile memory demand, and the execution time when executed on a data processing apparatus include at least one respective implementation variant that is optimal in this respect under the set of implementation variants.
[0044] In step 302, one of the determined implementation variants is selected according to a user input (eg, a text entry or a click on a corresponding display element) specifying a selection from the subset.
[0045] In step 303, the selected implementation variants are stored in the data processing device (so that they can be executed there, e.g. they are transferred from the computer system performing the above steps to the data processing device and stored there, e.g. by a flash process).
[0046] Providing a neural network on a data processing apparatus includes, according to various embodiments, implementing or, in various embodiments, is provided by an implementation (storing an implementation variant on a data processing apparatus can also be considered as providing, and in particular implementing, the implementation variant (or a neural network according to the implementation variant) on a data processing apparatus).
[0047] The subsets form a Pareto surface in a set of (eg, possible, available, or provided) implementation variants, according to various embodiments.
[0048] The method of FIG. 3 can be implemented by one or more computers with one or more data processing units. The term "data processing unit" can be understood as any type of entity that allows processing of data or signals. The data or signals can be processed, for example, according to at least one (i.e., one or more) specific functions performed by the data processing unit. The data processing unit can include or consist of an analog circuit, a digital circuit, a logic circuit, a microprocessor, a microcontroller, a central processing unit (CPU), a graphic processing unit (GPU), a digital signal processor (DSP), a programmable gate array integrated circuit (FPGA), or any combination thereof. Any other manner for implementing the respective functions described in more detail herein can also be understood as a data processing unit or a logic circuit assembly. One or more method steps described in detail herein can be executed (e.g., implemented) by the data processing unit by one or more specific functions performed by it.
[0049] That is, the method is specifically computer-implemented according to various embodiments.
[0050] The approach of Fig. 3 is used to provide a neural network on a data processing device, which then executes it and generates control signals for, for example, a robotic device based on the output of the neural network (e.g. object detection). The term "robotic device" can be understood as referring to any technical system (with mechanical parts whose operation is controlled), such as, for example, a computer-controlled machine, a vehicle, a household appliance, a power tool, a manufacturing machine, a personal assistant, or an access control system, in which the control rules of this technical system are learned and then this technical system is controlled accordingly.
[0051] Neural networks can process, for example, sensor signals, ultrasound, motion, thermal images, etc. from various sensors, for example, video, radar, LiDAR, etc., to obtain sensor data regarding the state of a system to be controlled (e.g., a robot or objects in its environment). Processing of the sensor data can include, for example, classifying the sensor data or performing semantic segmentation on the sensor data, for example, to detect the presence of objects (in the environment from which the sensor data was obtained). Thus, for example, neural networks can be used to control a robot, for example, to accomplish different operational tasks under different scenarios. In particular, these embodiments are applicable to controlling and monitoring the execution of operational tasks, for example, in an assembly line.
Claims
1. A method for providing a neural network (103) on a data processing device (100), the method comprising the steps of: determining a subset of a plurality of implementation variants of the neural network (103) from a set of implementation variants of the neural network (103), each implementation variant of the subset not related to any of working memory demand, non-volatile memory demand and execution time when executed on the data processing device (100) is improvable without degrading at least one of the other two of the working memory demand, the non-volatile memory demand and the execution time, and further, the subset for each of the working memory demand, the non-volatile memory demand and the execution time when executed on the data processing device (100) includes at least one respective implementation variant that is optimal in this respect under the set of implementation variants; selecting one of the sought implementation variants in accordance with user input specifying a selection from said subset; storing said selected implementation variant in said data processing device (100).
2. The method comprises: determining a set of layers of the neural network (103) that have a longer execution time on the data processing device (100) than other layers of the neural network (103) when the neural network is implemented according to a reference implementation; determining various layer implementation variants for each layer of the set; - determining implementation variants of the neural network (103) by combining the determined layer implementation variants with an implementation variant of the neural network (103), where for layers that are not part of the set a respective predefined reference implementation is used; determining the subset of implementation variants by determining, for each of the determined implementation variants, the working memory demand, the non-volatile memory demand, and the execution time; The method of claim 1 , comprising:
3. 3. The method of claim 1, wherein all implementation variants of a set of implementation variants for the same input to an input layer of the neural network provide the same output to an output layer of the neural network.
4. Said implementation variants include at least one of the following: A set of layers implemented with the same computation function, a set of layers implemented with respective computation functions adapted to the input variables, the output variables and / or one or more quantization parameters of the layers; the data type used to store the weights in the working memory; and A set of layers whose calculations are implemented using lookup tables The method according to claim 1 , wherein the first and second halves of the first and second halves of the second and third ...
5. The method comprises: receiving a specification of limitations of said data processing device (100) with respect to at least one of a non-volatile memory and a working memory; determining the subset of implementation variants such that the implementation variants of the subset comply with the constraint; The method of any one of claims 1 to 4, comprising:
6. The method comprises: receiving a specification of application requirements with respect to at least one of a maximum computation time, a maximum non-volatile memory demand, and a maximum working memory demand; determining the subset of implementation variants such that the implementation variants of the subset meet the application requirements; The method of any one of claims 1 to 5, comprising:
7. A computer system (101) configured to carry out the method according to any one of claims 1 to 6.
8. A computer program comprising instructions which, when executed by a processor, cause the processor to carry out a method according to any one of claims 1 to 6.
9. A computer readable medium having stored thereon instructions that, when executed by a processor, cause the processor to perform the method of any one of claims 1 to 6.
