Data storage method, device, equipment and medium based on neural network model
By determining the memory alignment rules in the neural network model and optimizing the storage method of data in memory, the problem of low efficiency in the neural network model for memory resource utilization is solved, and the computing efficiency and operating performance of the model are significantly improved.
Patent Information
- Application Number
- CN202411093698.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-08-09
AI Technical Summary
The lack of memory optimization processing for neural network models in the prior art leads to low utilization efficiency of memory resources by neural network models, which affects computing efficiency.
By obtaining the data to be stored in the neural network model, determining the memory alignment rules based on the data, optimizing the storage method of the data structure in memory, making it more compact and efficient.
Memory alignment can reduce memory fragmentation, improve memory utilization, and speed up data access, thereby improving the operating efficiency of neural network models and optimizing data storage methods to significantly improve the operating performance of the model.
Smart Images

Figure CN118626148B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a data storage method, device, equipment and medium based on a neural network model. Background Art
[0002] In deep learning and high-performance computing, the training and reasoning of neural network models involve a large number of matrix operations. These operations require high efficiency of memory access, especially when the matrix size is large, misaligned data will cause additional memory access overhead, thus reducing the overall computing efficiency.
[0003] In the existing technology, there is no memory optimization processing for neural network models, which leads to low utilization efficiency of memory resources by neural network models, affecting the computing efficiency of neural network models. For example, in the scenario of single instruction multiple data (SIMD) or vector processor, multiple redundant instruction operations are required to obtain target data from memory, and these redundant instruction operations will not only reduce efficiency, but also occupy operating resources, resulting in a decrease in the effective utilization of hardware.
[0004] Therefore, there is an urgent need for a data storage method for neural network models to improve the computing performance of neural network models. Summary of the invention
[0005] The main purpose of the embodiments of the present invention is to provide a data storage method, device, equipment and medium based on a neural network model, aiming to solve the problem that there is no memory optimization processing for the neural network model in the related technology, which leads to low efficiency of memory resource utilization by the neural network model and affects the computational efficiency of the neural network model.
[0006] In a first aspect, an embodiment of the present invention provides a data storage method based on a neural network model, comprising:
[0007] Obtaining data to be stored corresponding to the neural network model, and determining a corresponding memory alignment rule according to the data to be stored;
[0008] Performing storage processing on the data to be stored according to the memory alignment rule to obtain a storage range corresponding to the data to be stored;
[0009] The data to be stored is stored according to the storage range to obtain a data storage result corresponding to the neural network model.
[0010] In a second aspect, an embodiment of the present invention provides a data storage device based on a neural network model, comprising:
[0011] A data acquisition module, used to obtain the data to be stored corresponding to the neural network model, and determine the corresponding memory alignment rule according to the data to be stored;
[0012] A range determination module, used to perform storage processing on the data to be stored according to the memory alignment rule, and obtain a storage range corresponding to the data to be stored;
[0013] The data storage module is used to store the data to be stored according to the storage range and obtain the data storage result corresponding to the neural network model.
[0014] In a third aspect, an embodiment of the present invention further provides a terminal device, comprising a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for realizing a connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the steps of any one of the data storage methods based on a neural network model provided in the specification of the present invention are implemented.
[0015] In a fourth aspect, an embodiment of the present invention further provides a storage medium for computer-readable storage, characterized in that the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any data storage method based on a neural network model provided in the specification of the present invention.
[0016] The embodiment of the present invention provides a data storage method, device, equipment and medium based on a neural network model. The method includes obtaining data to be stored corresponding to the neural network model, determining a corresponding memory alignment rule according to the data to be stored; performing storage processing on the data to be stored according to the memory alignment rule to obtain a storage range corresponding to the data to be stored; performing data storage on the data to be stored according to the storage range to obtain a data storage result corresponding to the neural network model. The method can optimize the storage method of the data structure in the memory by determining the memory alignment rule according to the data to be stored, making it more compact and efficient. Memory alignment can reduce memory fragmentation, improve memory utilization, and speed up data access, thereby improving the operating efficiency of the neural network model, and then perform storage processing on the data to be stored according to the storage range, which can effectively manage the storage space. This helps to reduce redundant space when storing data, and ensures the validity and integrity of data storage, avoiding data loss or damage. Therefore, the optimized data storage method can significantly improve the operating performance of the neural network model. Reducing unnecessary storage and access operations can reduce system latency, enable the model to process input data more quickly, and improve the overall response speed and efficiency. The method can not only effectively manage the data storage required by the neural network model, but also bring significant advantages in performance, space utilization and system stability, and is one of the important links in building an efficient neural network model. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A schematic diagram of a data storage method based on a neural network model provided by an embodiment of the present invention;
[0019] Figure 2 A schematic diagram of model parameter composition provided by an embodiment of the present invention;
[0020] Figure 3 A schematic diagram of the effect of sequentially connecting and storing model parameters provided for implementing this embodiment;
[0021] Figure 4 A method for implementing this embodiment is provided Figure 3 The corresponding reading effect diagram when reading the provided storage effect;
[0022] Figure 5 A schematic diagram of the effect of storing data to be stored in a unit size provided for implementing this embodiment;
[0023] Figure 6 A schematic diagram of the module structure of a data storage device based on a neural network model provided by an embodiment of the present invention;
[0024] Figure 7 A schematic block diagram of the structure of a terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0027] It should be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0028] The embodiment of the present invention provides a data storage method, device, equipment and medium based on a neural network model. The data storage method based on a neural network model can be applied to a terminal device, which can be an electronic device such as a tablet computer, a laptop computer, a desktop computer, a personal digital assistant and a wearable device. The terminal device can be a server or a server cluster.
[0029] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0030] Please refer to Figure 1 , Figure 1 A schematic flow chart of a data storage method based on a neural network model provided in an embodiment of the present invention.
[0031] like Figure 1 As shown, the data storage method based on the neural network model includes steps S101 to S103.
[0032] Step S101: obtain the data to be stored corresponding to the neural network model, and determine the corresponding memory alignment rule according to the data to be stored.
[0033] For example, first you need to understand the structure and parameters of the neural network model. A neural network model is usually composed of multiple layers of neurons and weights, and these weights and biases constitute the data to be stored. Secondly, memory alignment refers to the alignment of data to a specific address according to certain rules when it is stored in memory. In a neural network model, memory alignment rules are usually determined according to the requirements of the hardware platform (such as CPU or GPU) to maximize storage and access efficiency. For example, for a common 64-bit processor, data may need to be aligned to 8 bytes. Finally, using a deep learning framework (such as PyTorch or TensorFlow) in a programming language (such as Python), you can load and access the weight and bias data of the neural network model to obtain the data to be stored, and then obtain the memory alignment rules for the data format of the data to be stored.
[0034] In practical applications, illustratively, a memory allocation request is received, and a memory alignment condition (ie, a memory alignment rule) corresponding to the data to be stored in the memory allocation request is determined.
[0035] In some embodiments, obtaining the data to be stored corresponding to the neural network model includes: determining a model structure corresponding to the neural network model, the model structure including at least a first structure layer and a second structure layer; obtaining a first model parameter corresponding to the neural network model according to the first structure layer; obtaining a second model parameter corresponding to the neural network model according to the second structure layer; and determining the data to be stored corresponding to the neural network model according to the first model parameter and the second model parameter.
[0036] For example, it is necessary to clarify the overall structure of the neural network model, including the type of each layer in the neural network model (such as fully connected layer, convolutional layer, etc.), the number of parameters and the connection method, and then find the first structure layer and the second structure layer according to the determined neural network structure. These layers are usually represented by specific neural network model objects in the code, such as in deep learning frameworks (such as TensorFlow, PyTorch).
[0037] For example, the first structural layer of the neural network model is an embedding layer, and the second layer is a fully connected layer, thereby obtaining the first model parameters corresponding to the neural network model in the embedding layer; and obtaining the second model parameters corresponding to the neural network model in the fully connected layer. For example, the second model parameters include a weight matrix and a bias vector.
[0038] Exemplarily, the first model parameters and the second model parameters extracted from the first structure layer and the second structure layer are combined into the data to be stored. The data to be stored is usually a structure composed of numerical values such as a weight matrix and a bias vector, which is used to describe a specific part of the neural network model.
[0039] It should be noted that the model structure corresponding to the neural network model can also include a first structure layer, a second structure layer, a third structure layer, etc. This application does not impose any specific restrictions on the model structure corresponding to the neural network model, and it can be selected according to actual needs.
[0040] Specifically, determining the model structure of the neural network model can more clearly understand and manage the various components of the model, and then determine the data to be stored based on the first structural layer and the second structural layer, which can ensure the logic of storage in each structural layer of the data to be stored, thereby providing support for subsequent improvement of the reliability and stability of the model.
[0041] In some embodiments, obtaining the first model parameter corresponding to the neural network model according to the first structural layer includes: determining a pruning threshold and obtaining first parameter information corresponding to the first structural layer; pruning the first parameter information according to the pruning threshold to obtain the pruned first model parameter.
[0042] For example, the pruning threshold is usually determined based on some criteria, such as the absolute value of the weight or the size of the gradient. This threshold determines which parameters will be pruned (set to zero) and which will be retained. The appropriate pruning threshold can be determined by a validation set or a specially designed pruning algorithm to achieve compression while retaining model performance.
[0043] Exemplarily, the first parameter information of the first structural layer generally includes a weight matrix and a bias vector, and then the first parameter information of the first structural layer is processed according to a determined pruning threshold to obtain a first model parameter. Specifically, weights less than the pruning threshold are set to zero to achieve a pruning effect. It should be noted that in the implementation process, the structural integrity and performance of the model need to be carefully preserved, and the pruning rate and model performance are usually balanced according to the sparsity after pruning and the retention criteria.
[0044] Specifically, the pruning threshold can simplify the model structure, reduce the complexity of the model, and help prevent the model from overfitting during the training process, thereby improving the generalization ability of the model. This reduces the impact on the environment and the requirements for subsequent data storage, making it easier to achieve the target effect.
[0045] In some embodiments, determining the data to be stored corresponding to the neural network model based on the first model parameters and the second model parameters includes: performing precision quantization processing on the first model parameters and the second model parameters to obtain third model parameters corresponding to the first model parameters and fourth model parameters corresponding to the second model parameters; determining the data to be stored corresponding to the neural network model based on the third model parameters and the fourth model parameters.
[0046] For example, precision quantization is a technique to reduce model storage and computational overhead by reducing the number of bits of parameters. Usually, the first model parameter and the second model parameter of the neural network model are precision quantized to convert them from floating point numbers to integers with fixed bits or low-precision floating point numbers.
[0047] Exemplarily, the importance of the first model parameter and the second model parameter in the neural network model is determined, and then different accuracy requirements are set for the first model parameter and the second model parameter during accuracy quantization according to different importance weights, so that the first model parameter and the second model parameter are respectively precision quantized according to different accuracy requirements, and then the third model parameter corresponding to the first model parameter and the fourth model parameter corresponding to the second model parameter are obtained.
[0048] Exemplarily, the third model parameter and the fourth model parameter after precision quantization are combined into data to be stored. These data structures should take into account the precision information of each model parameter to ensure that the model can be correctly restored during storage and subsequent processing.
[0049] Specifically, by quantizing the first and second model parameters, the storage space required for the neural network model can be significantly reduced. Converting floating-point parameters to fixed-bit integers or low-precision floating-point numbers effectively reduces the amount of data during storage and transmission of the model, providing good support for subsequent data storage.
[0050] In some embodiments, the precision quantization processing of the first model parameter and the second model parameter to obtain a third model parameter corresponding to the first model parameter and a fourth model parameter corresponding to the second model parameter includes: determining first precision information corresponding to the first structural layer and determining second precision information corresponding to the second structural layer; adjusting the first model parameter according to the first precision information to obtain an adjusted third model parameter; adjusting the second model parameter according to the second precision information to obtain an adjusted fourth model parameter.
[0051] Exemplarily, the parameter type corresponding to the first structural layer of the neural network model and the requirements for the output of the layer are analyzed, so as to select a suitable quantization strategy according to the results of the analysis of the parameter type and the requirements for the output of the layer. The quantization strategy may include but is not limited to fixed-point representation, floating-point reduction, mixed precision, etc. The specific selection depends on the analysis results, so as to obtain the first precision information.
[0052] Similarly, the parameter type corresponding to the second structural layer of the neural network model and the requirements for the output of the layer are analyzed, so as to select a suitable quantization strategy according to the results of the analysis of the parameter type and the requirements for the output of the layer. The quantization strategy may include but is not limited to fixed-point representation, floating-point reduction, mixed precision, etc. The specific selection depends on the analysis results, so as to obtain the second precision information. The first precision information and the second precision information include the number of bits, precision range, etc. of each parameter, which are used to convert the floating-point parameter into the selected precision representation.
[0053] Exemplarily, according to the determined first precision information, the first model parameters of the first structure layer are quantized, for example, the floating-point number parameters are converted into integers or floating-point numbers represented by the corresponding precision, ensuring that the model performance is maintained as much as possible in the case of precision loss, thereby obtaining the third model parameters. Similarly, according to the determined second precision information, the second model parameters of the second structure layer are quantized, for example, the floating-point number parameters are converted into integers or floating-point numbers represented by the corresponding precision, ensuring that the model performance is maintained as much as possible in the case of precision loss, thereby obtaining the fourth model parameters.
[0054] Specifically, different precision quantization processing is used for each layer in the neural network model, thereby ensuring that the performance loss is minimized while reducing the precision, thus providing good support for subsequent data storage.
[0055] In some embodiments, determining the corresponding memory alignment rule based on the data to be stored includes: obtaining a first storage space corresponding to the data to be stored; determining storage requirements, and using the first storage space to perform parameter combination on the data to be stored to obtain a combination result corresponding to the storage requirements; and determining the memory alignment rule based on the combination result.
[0056] Exemplarily, the first storage space required for each model parameter of different structural layers of the neural network model in the data to be stored is obtained. For example, each model parameter in the embedding layer in the neural network model requires 3 bytes, and the 3 bytes are used to determine the first storage space corresponding to the embedding layer in the neural network model, that is, the first storage space is the memory size required to store each model parameter in each structural layer in the neural network model.
[0057] For example, the format and organization of the stored data are determined according to specific storage requirements. This may include the order of data arrangement, byte alignment, etc. The storage requirements are usually determined by the requirements of the hardware platform and the application. For example, the storage requirements are for subsequent fast retrieval or saving memory, etc.
[0058] Exemplarily, according to storage requirements, the bytes corresponding to the data to be stored are aligned to 4-byte or 8-byte boundaries, etc., and then the number of bytes corresponding to the first storage space is used to perform parameter combination on the data to be stored to obtain a combination result that meets the storage requirements.
[0059] For example, if the storage requirement is fast acquisition, when the data to be stored is aligned to an 8-byte boundary, and the first storage space is 3 bytes, if 1 model parameter is stored in 8 bytes, the memory space is seriously wasted. If 2 model parameters are stored in every 8 bytes, memory waste is reduced and the corresponding parameters can be quickly acquired later. Therefore, two adjacent combinations of the parameters to be stored are performed to obtain a combination result.
[0060] Exemplarily, the combination result provides support for the alignment method required for subsequent data storage. For example, if the combination result is a combination of two adjacent data, when the data to be stored is aligned to an 8-byte boundary, the memory alignment rule is to store 2 model parameters in every 8 bytes, and if the data to be stored is aligned to a 4-byte boundary, 1 model parameter is stored in every 4 bytes, etc. The memory alignment rule is used to reduce the access time required for subsequent data acquisition.
[0061] Specifically, by reasonably allocating storage space, storage waste is minimized and rapid acquisition of subsequent data is guaranteed, and then the memory alignment rules are quickly determined to make subsequent data acquisition easier and improve computing efficiency.
[0062] In some embodiments, the method of using the first storage space to perform parameter combination on the data to be stored to obtain a combination result that meets the storage requirements includes: determining a unit size corresponding to each access according to the storage requirements; dividing the unit size and the first storage space to obtain an initial division result, and rounding down the initial division result to obtain a target division result; and determining the combination result corresponding to the data to be stored according to the target division result.
[0063] Exemplarily, the unit size for each access to data is determined based on the storage requirements and the data access mode. The unit size may be a byte, a word, or other specific data block size, which is determined based on the specific situation. For example, the storage requirement is to facilitate subsequent reading.
[0064] Exemplarily, the determined unit size is divided by the memory size corresponding to the first storage space to obtain an initial division result, and then the initial division result is rounded down to ensure that the target division result obtained is an integer. This target division result is used to indicate the number of model parameters that can be stored in a unit size.
[0065] For example, the unit size is 20 bytes, which is the size of each access when reading data later. If each model parameter in the data to be stored consists of 4 4-byte units, such as Figure 2 As shown, if the data to be stored is stored sequentially, such as Figure 3 As shown, some problems will occur when using the unit size to read data. Some redundant data will be read, and some required data will not be read, such as Figure 4 As shown, additional operations are required to obtain the required data. When obtaining a unit size, two model parameters need to be spanned, which does not meet the storage requirements and is inconvenient for subsequent reading. Therefore, the unit size of 20 bytes and the first storage space determined by 16 bytes corresponding to 4 4 bytes can be divided to obtain 20 / 16, which is equal to 1.25. After rounding down, the division result can be 1.
[0066] Exemplarily, the amount of data to be stored that can be stored in each unit size is determined according to the target division result, and then the combination result corresponding to the data to be stored is obtained.
[0067] For example, when the target division result is 1, the combined result is that the number of data to be stored that can be stored in each unit size is 1. The specific storage effect is as follows: Figure 5 As shown, the pure black box is the memory interval between the model parameter storage; when the target division result is 2, the combined result is that the number of data to be stored that can be stored in each unit size is 2, and so on.
[0068] Specifically, determining the unit size corresponding to each access can effectively balance the utilization of storage space and the efficiency of data access, thereby avoiding waste of storage space and improving the efficiency of data reading, and effectively solving the technical problem to be solved in this application.
[0069] Step S102: performing storage processing on the data to be stored according to the memory alignment rule to obtain a storage range corresponding to the data to be stored.
[0070] Exemplarily, the memory alignment rules are determined according to the requirements of the target storage hardware. For example, the alignment may be performed according to the size of 4 bytes, 8 bytes, etc., and then the required memory space size is determined according to the amount of data to be stored, and the memory space is allocated according to the alignment rules. Thus, the actual occupied memory address range is calculated, that is, the area from the start address to the end address, and this range includes all valid data storage locations.
[0071] For example, if the memory alignment rule is 4-byte alignment and our data size is 20 bytes, then at least 24 bytes of memory space are required to store this data. When allocating memory, the starting address must be a multiple of 4, such as address 0x1000. Then, we store the data starting from address 0x1000 until the data length is met and memory alignment is ensured.
[0072] In some embodiments, the data to be stored is processed according to the memory alignment rule to obtain a storage range corresponding to the data to be stored, including: determining the number of parameters corresponding to the unit size according to the memory alignment rule; determining the target unit number corresponding to the data to be stored according to the number of parameters; and determining the storage range corresponding to the data to be stored according to the unit size and the target unit number.
[0073] Exemplarily, the memory alignment rule is the number of data that can be stored in each unit size, and then the number of data that can be stored in each unit size in the memory alignment rule is determined as the number of parameters corresponding to the unit size.
[0074] For example, if the unit size is 20 bytes and the first storage space is 16 bytes, the target division result is 1, and the memory alignment rule is to store a model parameter in each unit size, and the number of parameters corresponding to the unit size is determined to be 1; if the unit size is 10 bytes and the first storage space is 4 bytes, the target division result is 2, and the memory alignment rule is to store a model parameter in each unit size, and the number of parameters corresponding to the unit size is determined to be 2.
[0075] Exemplarily, the total amount of data corresponding to the data to be stored is divided by the number of parameters and then rounded up to obtain the target unit number, and then the unit size is multiplied by the target unit number to determine the storage memory size, thereby obtaining the initial memory address corresponding to the data to be stored when it is stored, and then determining the storage range based on the initial memory address and the storage memory size.
[0076] Specifically, by determining the number of parameters corresponding to the unit size, the target number of units required to store data can be accurately calculated, thereby effectively controlling the use of storage space. This can avoid wasting storage space and improve storage efficiency. The data to be stored is stored continuously according to the required unit size and number, which complies with the memory alignment rules and helps improve the efficiency of memory access. This can be achieved by reducing memory fragmentation and improving cache utilization, thereby improving the overall performance of the system.
[0077] In some embodiments, the memory alignment rules include at least a first rule corresponding to the first structure layer and a second rule corresponding to the second structure layer; determining the number of parameters corresponding to the unit size according to the memory alignment rules includes: determining the first data corresponding to the unit size in the first structure layer according to the first rule; determining the second data corresponding to the unit size in the second structure layer according to the second rule; and determining the number of parameters based on the first data and the second data.
[0078] Exemplarily, each structural layer in the neural network model has different storage precision, the first rule corresponding to the first structural layer is the first data that can be stored in each unit size in the first structural layer, and the second rule corresponding to the second structural layer is the second data that can be stored in each unit size in the second structural layer.
[0079] For example, if the unit size is 20 bytes and the first storage space corresponding to the first structure layer is 8 bytes, the target division result is 2, and the first rule is to store two model parameters in each unit size, that is, the first data is 2; if the unit size is 20 bytes and the second storage space corresponding to the second structure layer is 16 bytes, the target division result is 1, and the second rule is to store one model parameter in each unit size, that is, the second data is 1.
[0080] Exemplarily, the first data corresponding to the first structure layer and the second data corresponding to the second structure layer are combined and determined as the parameter quantity.
[0081] Specifically, by using the different storage precisions of different structural layers, different numbers of parameters corresponding to different structural layers are obtained, which helps to distinguish the storage and processing methods of different structural layers, and further helps to improve the standardization, efficiency and maintainability of data processing.
[0082] Step S103: storing the data to be stored according to the storage range to obtain a data storage result corresponding to the neural network model.
[0083] Exemplarily, based on the storage range calculated in the previous step, the memory space size and starting address required by the neural network model are determined, and then the data to be stored is stored in the pre-allocated memory space according to the calculated storage range and memory alignment rules, and the continuity of data storage and storage according to the specified memory alignment rules are ensured to optimize data access efficiency.
[0084] In some embodiments, the data to be stored is stored according to the storage range to obtain the data storage result corresponding to the neural network model, including: combining parameters of the data to be stored according to the number of parameters to obtain the target storage parameters corresponding to the unit size; and storing the numerical values corresponding to the target storage parameters in the data to be stored in the storage range in sequence according to the parameter order to obtain the data storage result.
[0085] Exemplarily, according to the number of parameters, the parameters of the data to be stored are combined to obtain the target storage parameters corresponding to the unit size.
[0086] For example, when the number of parameters is 1, the target storage parameter corresponding to the unit size is any parameter in the data to be stored; when the number of parameters is 2, the target storage parameter corresponding to the unit size is the data of the combination of two adjacent parameters in the data to be stored.
[0087] Exemplarily, the numerical values corresponding to the target storage parameters in the data to be stored are stored in sequence in the storage range according to the parameter order, thereby obtaining a data storage result.
[0088] For example, when the number of parameters is 1, a corresponding numerical value in the data to be stored is stored in a unit size each time in the storage range according to the parameter order, so as to obtain the target storage parameter; when the number of parameters is 2, two corresponding numerical values in the data to be stored are stored in a unit size each time in the storage range according to the parameter order, so as to obtain the target storage parameter.
[0089] Specifically, it ensures that the data to be stored is correctly and orderly stored in the specified storage range according to the parameter sequence, and obtains the data storage results, thereby providing support for subsequent improvement of data acquisition efficiency.
[0090] In some embodiments, after obtaining the data storage result, the method further includes: determining a parameter splicing order corresponding to the data to be stored according to the target storage parameter; reading the data storage result to obtain a target reading result; and splicing the target reading result according to the parameter splicing order to obtain a parameter matrix.
[0091] Exemplarily, the number of parameters corresponding to the target storage parameters is determined, and then the parameter splicing order corresponding to the data to be stored is determined according to the number of parameters. For example, when the number of parameters is 1, the parameter splicing order is to obtain each unit size and then splice them one by one; when the number of parameters is 2, the parameter splicing order is to first obtain the two parameters contained in each unit size after obtaining each unit size, and then splice the parameters in sequence.
[0092] For example, the data storage result is read using the unit size to obtain the target reading result, and then the target reading result is spliced according to the parameter splicing order to obtain the parameter matrix. By improving the memory allocation and combining the specific computing requirements of the neural network model, a specific memory alignment strategy is designed, and then the data storage parameters are matrix-converted to obtain the parameter matrix, and vector instructions are used for vectorized calculations according to the parameter matrix, which significantly improves the efficiency of matrix operations and is particularly suitable for the training and reasoning of deep learning models. This method has good versatility and compatibility and can be widely used in various high-performance computing and large-scale data processing scenarios.
[0093] Specifically, by clearly defining the target storage parameters and parameter concatenation order, the correctness and consistency of data during storage and reading can be ensured. This can avoid errors caused by data order confusion and ensure the accuracy of data operations. By reading in the parameter concatenation order, the complexity of data access by the system can be reduced, thereby improving the efficiency of overall data processing.
[0094] In some implementations, reading the data storage result to obtain a target reading result includes: reading the data storage result using the unit size to obtain an initial reading result; and performing data splitting on the initial reading result using the parameter quantity to obtain the target reading result.
[0095] Exemplarily, the unit size is determined, and data is gradually read from the data storage result according to the unit size to obtain an initial reading result, and then according to the previously determined number of parameters, the initial reading result is split according to the size of the memory occupied by each data in the data to be stored, so as to obtain the target reading result corresponding to the number of parameters in each unit size.
[0096] For example, the unit size is 20 bytes, the number of parameters is 2, and the memory size occupied by each data in the data to be stored is 8 bytes. Then, the data at the initial address position and the position between the initial address position plus 8 bytes in the initial read result is determined as the first read result, and the data at the position between the initial address position plus 8 bytes and the initial address position plus 16 bytes is determined as the second read result, thereby determining the first read result and the second read result as the results of splitting the initial read result, that is, determining the first read result and the second read result as the target read results.
[0097] Specifically, correctly reading and splitting the data storage results according to the unit size and the number of parameters can ensure that the data is accurately read from the storage results to obtain the expected target reading results, avoid data splitting errors or missing data, and improve the efficiency and speed of overall data processing.
[0098] The embodiment of the present invention provides a data storage method, device, equipment and medium based on a neural network model. The method includes obtaining data to be stored corresponding to the neural network model, determining a corresponding memory alignment rule according to the data to be stored; performing storage processing on the data to be stored according to the memory alignment rule to obtain a storage range corresponding to the data to be stored; performing data storage on the data to be stored according to the storage range to obtain a data storage result corresponding to the neural network model. The method can optimize the storage method of the data structure in the memory by determining the memory alignment rule according to the data to be stored, making it more compact and efficient. Memory alignment can reduce memory fragmentation, improve memory utilization, and speed up data access, thereby improving the operating efficiency of the neural network model, and then perform storage processing on the data to be stored according to the storage range, which can effectively manage the storage space. This helps to reduce redundant space when storing data, and ensures the validity and integrity of data storage, avoiding data loss or damage. Therefore, the optimized data storage method can significantly improve the operating performance of the neural network model. Reducing unnecessary storage and access operations can reduce system latency, enable the model to process input data more quickly, and improve the overall response speed and efficiency. The method can not only effectively manage the data storage required by the neural network model, but also bring significant advantages in performance, space utilization and system stability, and is one of the important links in building an efficient neural network model.
[0099] See also Figure 6 , Figure 6A data storage device 200 based on a neural network model is provided in an embodiment of the present application. The data storage device 200 based on the neural network model includes a data acquisition module 201, a range determination module 202, and a data storage module 202, wherein the data acquisition module 201 is used to obtain the data to be stored corresponding to the neural network model, and determine the corresponding memory alignment rule according to the data to be stored; the range determination module 202 is used to perform storage processing on the data to be stored according to the memory alignment rule, and obtain the storage range corresponding to the data to be stored; the data storage module 202 is used to perform data storage on the data to be stored according to the storage range, and obtain the data storage result corresponding to the neural network model.
[0100] In some implementations, the data acquisition module 201, in the process of obtaining the data to be stored corresponding to the neural network model, executes:
[0101] Determine a model structure corresponding to the neural network model, wherein the model structure includes at least a first structure layer and a second structure layer;
[0102] Obtaining a first model parameter corresponding to the neural network model according to the first structural layer;
[0103] Obtaining a second model parameter corresponding to the neural network model according to the second structural layer;
[0104] The data to be stored corresponding to the neural network model is determined according to the first model parameter and the second model parameter.
[0105] In some implementations, the data acquisition module 201, in the process of obtaining the first model parameter corresponding to the neural network model according to the first structural layer, performs:
[0106] Determine a pruning threshold, and obtain first parameter information corresponding to the first structural layer;
[0107] The first parameter information is pruned according to the pruning threshold to obtain the pruned first model parameter.
[0108] In some implementations, the data acquisition module 201, during the process of determining the data to be stored corresponding to the neural network model according to the first model parameter and the second model parameter, performs:
[0109] Performing precision quantization processing on the first model parameter and the second model parameter to obtain a third model parameter corresponding to the first model parameter and a fourth model parameter corresponding to the second model parameter;
[0110] The data to be stored corresponding to the neural network model is determined according to the third model parameter and the fourth model parameter.
[0111] In some implementations, the precision quantization processing is performed on the first model parameter and the second model parameter, and the data acquisition module 201 performs, in the process of obtaining the third model parameter corresponding to the first model parameter and the fourth model parameter corresponding to the second model parameter:
[0112] Determine first precision information corresponding to the first structural layer and determine second precision information corresponding to the second structural layer;
[0113] Adjust the first model parameters according to the first accuracy information to obtain adjusted third model parameters;
[0114] The second model parameters are adjusted according to the second precision information to obtain adjusted fourth model parameters.
[0115] In some implementations, the data acquisition module 201, in the process of determining the corresponding memory alignment rule according to the data to be stored, executes:
[0116] Obtaining a first storage space corresponding to the data to be stored;
[0117] Determine storage requirements, and use the first storage space to perform parameter combination on the data to be stored to obtain a combination result that meets the storage requirements;
[0118] The memory alignment rule is determined according to the combination result.
[0119] In some implementations, the data acquisition module 201 performs, during the process of combining parameters of the data to be stored using the first storage space to obtain a combination result that satisfies the storage requirement:
[0120] Determine the unit size corresponding to each access according to the storage requirement;
[0121] Dividing the unit size and the first storage space to obtain an initial division result, and rounding down the initial division result to obtain a target division result;
[0122] The combination result corresponding to the data to be stored is determined according to the target division result.
[0123] In some implementations, the range determination module 202 performs, during the process of performing storage processing on the data to be stored according to the memory alignment rule and obtaining a storage range corresponding to the data to be stored:
[0124] Determine the number of parameters corresponding to the unit size according to the memory alignment rule;
[0125] Determine the target unit quantity corresponding to the data to be stored according to the parameter quantity;
[0126] The storage range corresponding to the data to be stored is determined according to the unit size and the target unit quantity.
[0127] In some implementations, the memory alignment rule includes at least a first rule corresponding to the first structure layer and a second rule corresponding to the second structure layer; the range determination module 202 performs, in the process of determining the number of parameters corresponding to the unit size according to the memory alignment rule:
[0128] Determine first data corresponding to the unit size in the first structural layer according to the first rule;
[0129] Determine second data corresponding to the unit size in the second structural layer according to the second rule;
[0130] The number of parameters is determined according to the first data and the second data.
[0131] In some implementations, the data storage module 203 performs, during the process of storing the data to be stored according to the storage range and obtaining the data storage result corresponding to the neural network model:
[0132] Combining parameters of the data to be stored according to the number of parameters to obtain a target storage parameter corresponding to the unit size;
[0133] The numerical values corresponding to the target storage parameters in the data to be stored are stored in the storage range in sequence according to the parameter order to obtain the data storage result.
[0134] In some implementations, after obtaining the data storage result, the data storage device 200 based on the neural network model further performs:
[0135] Determine the parameter splicing order corresponding to the data to be stored according to the target storage parameter;
[0136] Reading the data storage result to obtain a target reading result;
[0137] The target reading results are spliced according to the parameter splicing order to obtain a parameter matrix.
[0138] In some implementations, the data storage device 200 based on the neural network model performs, during the process of reading the data storage result to obtain the target reading result:
[0139] Using the unit size to read the data storage result to obtain an initial reading result;
[0140] The initial reading result is split into data using the parameter quantity to obtain the target reading result.
[0141] In some embodiments, the data storage device 200 based on the neural network model can be applied to a terminal device.
[0142] It should be noted that those skilled in the art can clearly understand that, for the sake of convenience and brevity of description, the specific working process of the data storage device 200 based on the neural network model described above can refer to the corresponding process in the aforementioned data storage method embodiment based on the neural network model, and will not be repeated here.
[0143] See also Figure 7 , Figure 7 A schematic block diagram of the structure of a terminal device provided in an embodiment of the present invention.
[0144] like Figure 7 As shown, the terminal device 300 includes a processor 301 and a memory 302 , and the processor 301 and the memory 302 are connected via a bus 303 , such as an I2C (Inter-integrated Circuit) bus.
[0145] Specifically, the processor 301 is used to provide computing and control capabilities to support the operation of the entire terminal device. The processor 301 can be a central processing unit (CPU), and the processor 301 can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0146] Specifically, the memory 302 may be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a mobile hard disk.
[0147] Those skilled in the art will understand that Figure 7The structure shown in the figure is only a block diagram of a partial structure related to the embodiment of the present invention, and does not constitute a limitation on the terminal device to which the embodiment of the present invention is applied. The specific server may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0148] The processor is used to run a computer program stored in the memory, and implement any one of the data storage methods based on the neural network model provided by the embodiments of the present invention when executing the computer program.
[0149] In one embodiment, the processor is used to run a computer program stored in the memory, and implements the following steps when executing the computer program:
[0150] Obtaining data to be stored corresponding to the neural network model, and determining a corresponding memory alignment rule according to the data to be stored;
[0151] Performing storage processing on the data to be stored according to the memory alignment rule to obtain a storage range corresponding to the data to be stored;
[0152] The data to be stored is stored according to the storage range to obtain a data storage result corresponding to the neural network model.
[0153] In some implementations, the processor 301, during the process of obtaining the data to be stored corresponding to the neural network model, executes:
[0154] Determine a model structure corresponding to the neural network model, wherein the model structure includes at least a first structure layer and a second structure layer;
[0155] Obtaining a first model parameter corresponding to the neural network model according to the first structural layer;
[0156] Obtaining a second model parameter corresponding to the neural network model according to the second structural layer;
[0157] The data to be stored corresponding to the neural network model is determined according to the first model parameter and the second model parameter.
[0158] In some implementations, the processor 301, in the process of obtaining the first model parameter corresponding to the neural network model according to the first structural layer, executes:
[0159] Determine a pruning threshold, and obtain first parameter information corresponding to the first structural layer;
[0160] The first parameter information is pruned according to the pruning threshold to obtain the pruned first model parameter.
[0161] In some implementations, during the process of determining the data to be stored corresponding to the neural network model according to the first model parameter and the second model parameter, the processor 301 executes:
[0162] Performing precision quantization processing on the first model parameter and the second model parameter to obtain a third model parameter corresponding to the first model parameter and a fourth model parameter corresponding to the second model parameter;
[0163] The data to be stored corresponding to the neural network model is determined according to the third model parameter and the fourth model parameter.
[0164] In some implementations, the processor 301, in the process of performing precision quantization processing on the first model parameter and the second model parameter to obtain a third model parameter corresponding to the first model parameter and a fourth model parameter corresponding to the second model parameter, executes:
[0165] Determine first precision information corresponding to the first structural layer and determine second precision information corresponding to the second structural layer;
[0166] Adjust the first model parameters according to the first accuracy information to obtain adjusted third model parameters;
[0167] The second model parameters are adjusted according to the second precision information to obtain adjusted fourth model parameters.
[0168] In some implementations, during the process of determining the corresponding memory alignment rule according to the data to be stored, the processor 301 executes:
[0169] Obtaining a first storage space corresponding to the data to be stored;
[0170] Determine storage requirements, and use the first storage space to perform parameter combination on the data to be stored to obtain a combination result that meets the storage requirements;
[0171] The memory alignment rule is determined according to the combination result.
[0172] In some implementations, the processor 301, in the process of combining parameters of the data to be stored by using the first storage space to obtain a combination result that meets the storage requirement, executes:
[0173] Determine the unit size corresponding to each access according to the storage requirement;
[0174] Dividing the unit size and the first storage space to obtain an initial division result, and rounding down the initial division result to obtain a target division result;
[0175] The combination result corresponding to the data to be stored is determined according to the target division result.
[0176] In some implementations, the processor 301, in the process of performing storage processing on the data to be stored according to the memory alignment rule and obtaining a storage range corresponding to the data to be stored, executes:
[0177] Determine the number of parameters corresponding to the unit size according to the memory alignment rule;
[0178] Determine the target unit quantity corresponding to the data to be stored according to the parameter quantity;
[0179] The storage range corresponding to the data to be stored is determined according to the unit size and the target unit quantity.
[0180] In some implementations, the memory alignment rule includes at least a first rule corresponding to the first structure layer and a second rule corresponding to the second structure layer; the processor 301, in the process of determining the number of parameters corresponding to the unit size according to the memory alignment rule, executes:
[0181] Determine first data corresponding to the unit size in the first structural layer according to the first rule;
[0182] Determine second data corresponding to the unit size in the second structural layer according to the second rule;
[0183] The number of parameters is determined according to the first data and the second data.
[0184] In some implementations, the processor 301 performs, during the process of storing the data to be stored according to the storage range and obtaining the data storage result corresponding to the neural network model:
[0185] Combining parameters of the data to be stored according to the number of parameters to obtain a target storage parameter corresponding to the unit size;
[0186] The numerical values corresponding to the target storage parameters in the data to be stored are stored in the storage range in sequence according to the parameter order to obtain the data storage result.
[0187] In some implementations, after obtaining the data storage result, the processor 301 further executes:
[0188] Determine the parameter splicing order corresponding to the data to be stored according to the target storage parameter;
[0189] Reading the data storage result to obtain a target reading result;
[0190] The target reading results are spliced according to the parameter splicing order to obtain a parameter matrix.
[0191] In some implementations, during the process of reading the data storage result to obtain the target reading result, the processor 301 executes:
[0192] Using the unit size to read the data storage result to obtain an initial reading result;
[0193] The initial reading result is split into data using the parameter quantity to obtain the target reading result.
[0194] It should be noted that those skilled in the art can clearly understand that, for the sake of convenience and brevity of description, the specific working process of the terminal device described above can refer to the corresponding process in the aforementioned data storage method embodiment based on the neural network model, and will not be repeated here.
[0195] An embodiment of the present invention also provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any data storage method based on a neural network model provided in the description of the embodiment of the present invention.
[0196] The storage medium may be an internal storage unit of the terminal device described in the foregoing embodiment, such as a hard disk or memory of the terminal device. The storage medium may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc., equipped on the terminal device.
[0197] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware embodiment, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or transient medium). As is known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0198] It should be understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system including the element.
[0199] The serial numbers of the embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. The above description is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A data storage method based on a neural network model, characterized in that: The method comprises: Acquire the data to be stored corresponding to the neural network model, and determine the corresponding memory alignment rule according to the data to be stored; the data to be stored includes model parameters of one or more structural layers in the neural network model; the memory alignment rule is determined based on the storage space required for each model parameter of different structural layers of the neural network model in the data to be stored; the memory alignment rule is used to indicate the format and organization method corresponding to the data to be stored; The data to be stored is stored and processed according to the memory alignment rule to obtain a storage range corresponding to the data to be stored; the memory alignment rule at least includes the number of data that can be stored in each unit size; the number of parameters corresponding to the unit size is determined by the number of data that can be stored in each unit size in the memory alignment rule; the storage range is the actually occupied memory address range, and the memory address range is all valid data storage locations in the area from the start address to the end address; Data storage is performed on the data to be stored according to the storage range to obtain a data storage result corresponding to the neural network model; Wherein, determining the corresponding memory alignment rule according to the data to be stored includes: Obtaining a first storage space corresponding to the data to be stored; Determine storage requirements, and use the first storage space to perform parameter combination on the data to be stored to obtain a combination result that meets the storage requirements; Determine the memory alignment rule according to the combination result; The step of combining parameters of the data to be stored by using the first storage space to obtain a combination result that satisfies the storage requirement includes: Determine the unit size corresponding to each access according to the storage requirement; Dividing the unit size and the first storage space to obtain an initial division result, and rounding down the initial division result to obtain a target division result; The combination result corresponding to the data to be stored is determined according to the target division result.
2. The method according to claim 1, characterized in that The storing process of the data to be stored according to the memory alignment rule to obtain a storage range corresponding to the data to be stored includes: Determine the number of parameters corresponding to the unit size according to the memory alignment rule; Determine the target unit quantity corresponding to the data to be stored according to the parameter quantity; The storage range corresponding to the data to be stored is determined according to the unit size and the target unit quantity.
3. The method according to claim 2, characterized in that The memory alignment rule includes at least a first rule corresponding to the first structure layer and a second rule corresponding to the second structure layer; and determining the number of parameters corresponding to the unit size according to the memory alignment rule includes: Determine first data corresponding to the unit size in the first structural layer according to the first rule; Determine second data corresponding to the unit size in the second structural layer according to the second rule; The number of parameters is determined according to the first data and the second data.
4. The method according to claim 2, characterized in that: The storing the data to be stored according to the storage range to obtain the data storage result corresponding to the neural network model includes: Combining parameters of the data to be stored according to the number of parameters to obtain a target storage parameter corresponding to the unit size; The numerical values corresponding to the target storage parameters in the data to be stored are stored in the storage range in sequence according to the parameter order to obtain the data storage result.
5. The method according to claim 4, characterized in that After obtaining the data storage result, the method further includes: Determine the parameter splicing order corresponding to the data to be stored according to the target storage parameter; Reading the data storage result to obtain a target reading result; The target reading results are spliced according to the parameter splicing order to obtain a parameter matrix.
6. The method according to claim 5, characterized in that The reading of the data storage result to obtain a target reading result includes: Using the unit size to read the data storage result to obtain an initial reading result; The initial reading result is split into data using the parameter quantity to obtain the target reading result.
7. The method according to claim 1, characterized in that The obtaining the data to be stored corresponding to the neural network model includes: Determine a model structure corresponding to the neural network model, wherein the model structure includes at least a first structure layer and a second structure layer; Obtaining a first model parameter corresponding to the neural network model according to the first structural layer; Obtaining a second model parameter corresponding to the neural network model according to the second structural layer; The data to be stored corresponding to the neural network model is determined according to the first model parameter and the second model parameter.
8. The method according to claim 7, characterized in that The obtaining, according to the first structural layer, a first model parameter corresponding to the neural network model comprises: Determine a pruning threshold, and obtain first parameter information corresponding to the first structural layer; The first parameter information is pruned according to the pruning threshold to obtain the pruned first model parameter.
9. The method according to claim 7, characterized in that: The step of determining the data to be stored corresponding to the neural network model according to the first model parameter and the second model parameter includes: Performing precision quantization processing on the first model parameter and the second model parameter to obtain a third model parameter corresponding to the first model parameter and a fourth model parameter corresponding to the second model parameter; The data to be stored corresponding to the neural network model is determined according to the third model parameter and the fourth model parameter.
10. The method according to claim 9, characterized in that The performing precision quantization processing on the first model parameter and the second model parameter to obtain a third model parameter corresponding to the first model parameter and a fourth model parameter corresponding to the second model parameter includes: Determine first precision information corresponding to the first structural layer and determine second precision information corresponding to the second structural layer; Adjust the first model parameters according to the first accuracy information to obtain adjusted third model parameters; The second model parameters are adjusted according to the second precision information to obtain adjusted fourth model parameters.
11. A data storage device based on a neural network model, characterized in that: include: A data acquisition module, used to obtain data to be stored corresponding to the neural network model, and determine a corresponding memory alignment rule according to the data to be stored; the data to be stored includes model parameters of one or more structural layers in the neural network model; the memory alignment rule is determined based on the storage space required for each model parameter of different structural layers of the neural network model in the data to be stored; The memory alignment rule is used to indicate the format and organization method corresponding to the data to be stored; A range determination module, used to perform storage processing on the data to be stored according to the memory alignment rule, and obtain a storage range corresponding to the data to be stored; The memory alignment rule includes at least the amount of data that can be stored in each unit size; The number of parameters corresponding to the unit size is determined by the number of data that can be stored in each unit size in the memory alignment rule; the storage range is the actually occupied memory address range, and the memory address range is all valid data storage locations in the area from the start address to the end address; A data storage module, used for storing the data to be stored according to the storage range, and obtaining a data storage result corresponding to the neural network model; The data acquisition module determines the corresponding memory alignment rule according to the data to be stored, and is specifically used for: Obtaining a first storage space corresponding to the data to be stored; Determine storage requirements, and use the first storage space to perform parameter combination on the data to be stored to obtain a combination result that meets the storage requirements; Determine the memory alignment rule according to the combination result; The data acquisition module combines the parameters of the data to be stored using the first storage space to obtain a combination result that meets the storage requirement, specifically for: Determine the unit size corresponding to each access according to the storage requirement; Dividing the unit size and the first storage space to obtain an initial division result, and rounding down the initial division result to obtain a target division result; The combination result corresponding to the data to be stored is determined according to the target division result.
12. A terminal device, characterized in that: The terminal device includes a processor and a memory; The memory is used to store computer programs; The processor is used to execute the computer program and implement the data storage method based on the neural network model as described in any one of claims 1 to 10 when executing the computer program.
13. A computer storage medium for computer storage, characterized in that: The computer storage medium stores at least one program, and at least one processor is used to execute the at least one program to implement the steps of the data storage method based on the neural network model as described in any one of claims 1 to 10.
Citation Information
Patent Citations
Method and system for deep learning algorithm acceleration on field-programmable gate array platform
CN106228238A