Processing method for operator in deep learning model structure
By converting 2-dimensional or 3-dimensional operators into 4-dimensional in deep learning models, the problem of complexity of multi-dimensional operator implementation in the model is solved, the code implementation is simplified, and the model efficiency and maintainability are improved.
Patent Information
- Application Number
- CN202311839474.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2025-06-27
AI Technical Summary
In deep learning models, operators of multiple dimensions need to be processed, resulting in complex and high workload of code implementation. Especially in the implementation of operators such as convolution and pooling, 2-dimensional or 3-dimensional data need to be processed frequently, which will affect the efficiency and maintainability of the model.
By adding dimensions to 2-dimensional or 3-dimensional operators to become 4-dimensional, the completed 4-dimensional operator functions can be directly used to reduce the need for functional implementation of 2-dimensional or 3-dimensional operators. The specific method is to add a dimension of 1 in the middle of the shape, for example, to change the operator (1, 32) of a 2-dimensional shape into a 4-dimensional shape (1, 1, 1, 32).
Through this method, the implementation process of operators in deep learning models can be simplified, the complexity and workload of code can be reduced, and the efficiency and maintainability of the model can be improved.
Smart Images

Figure CN120218117A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of neural network deep learning, and particularly relates to a method for processing operators in a deep learning model structure. Background Art
[0002] Deep learning (DL) is a new research direction in the field of machine learning (ML). It is introduced into machine learning to make it closer to the original goal of artificial intelligence (AI). Deep learning is to learn the internal laws and representation levels of sample data, and the information obtained in these learning processes is very helpful for the interpretation of data such as text, images, and sounds. Its ultimate goal is to enable machines to have the ability of analysis and learning like humans, and be able to recognize data such as text, images, and sounds. Deep learning is a complex machine learning algorithm. Currently, especially in the aspects of speech and image recognition, the achieved effects far exceed the previous related technologies.
[0003] In the process of implementing a neural network, the functions of each operator need to be implemented by code. For an image recognition model, the input shape of the network is 4D. Therefore, when implementing the functions of each operator, it will be processed in a 4D shape. There are many types of operators included in the model, and for a single operator, there may be many code branches to complete the functions due to different parameters. For example, in convolution, there is a parameter in standard convolution that determines whether the output width and height will be the same as the input width and height. According to this parameter, two parts of code need to be written for implementation.
[0004] However, there are already many 4D operators that need to be implemented, such as convolution, max pooling, average pooling, global pooling, fully connected, etc. If there are operators like reshape, squeeze, unsqueeze in the model structure that will transform the dimensions, then the output shapes of these operators will become 3D or even 2D. Then, those already implemented operators need to re-implement their functions entirely according to 2D or 3D, which requires a large amount of work to be completed.
[0005] In addition, the commonly used terms in the prior art include:
[0006] Deep learning: Deep learning is a type of machine learning, and machine learning is the necessary path to achieve artificial intelligence. The concept of deep learning stems from the research of artificial neural networks. A multi-layer perceptron with multiple hidden layers is a deep learning structure.
[0007] Operator: A deep learning algorithm consists of individual computing units, which are called operators (Operator, abbreviated as OP), including: conv, pooling, activation, etc.
[0008] Node: The basic computational unit of a neural network is a neuron, collectively referred to as a node. It receives inputs from other nodes or external sources and calculates an output. Summary of the Invention
[0009] To solve the above problems, the purpose of this application is: In this application, some operators with 2D or 3D shapes will be changed to 4D, so that the functions of the completed 4D operators can be directly used, and there is no need to add the function implementation of 2D or 3D operators. The method of changing from 2D or 3D to 4D here is to add dimensions with a value of 1 in the middle of the shape. For example, for a convolution, the input shape is 2D: (1, 32), then after becoming 4D, it is (1, 1, 1, 32). Adding dimensions like this does not change the sorting method of the specific data, but only adds two more dimensions in terms of dimension information.
[0010] Specifically, the present invention provides a method for processing operators in a deep learning model structure. The method enables the entire model to perform calculations with 4D data by changing the operators from 2D or 3D to 4D, including the following steps:
[0011] S1, determine whether the operator in the model is an operator that has already implemented the functions of 2D, 3D, and 4D; the operators that have already implemented the functions of 2D, 3D, and 4D include: Reshape, Transpose, Squeeze, Unsqueeze, Formatconvert; that is, Reshape, Transpose, Squeeze, Unsqueeze, Formatconvert are all operators that have implemented at least the computational logics of 2D, 3D, and 4D; if so, no processing is required;
[0012] If not, that is, when it is other operators, then proceed to step S2;
[0013] S2, determine whether the other operator belongs to one of the following situations. If so, handle it according to the following situations; if not, no processing is required:
[0014] Among them, other operators except the Reshape, Transpose, Squeeze, Unsqueeze, Formatconvert operators are collectively referred to as op; the output_shape operator is the output shape;
[0015] Situation 1) op1 -> Squeeze -> op2: Here, op1 and op2 represent different operators;
[0016] If the size of op1's output_shape == 4, then no new operator needs to be added between op1 and Squeeze;
[0017] If the size of op1's output_shape < 4, since the implemented size of op1's output_shape is 4, a new Squeeze operator needs to be added first to reduce the size of op1's output_shape to the same as that of op1's output_shape in the neural network model, and then the original Squeeze in the neural network model is executed;
[0018] Next, judge Squeeze and the size of output_shape.
[0019] If the size of Squeeze's output_shape == 4, then no new operator needs to be added between Squeeze and op2;
[0020] Since the implemented op1 and op2 are 4-dimensional, so
[0021] When the size of Squeeze's output_shape < 4, and since op2 requires a 4-dimensional input, an Unsqueeze operator needs to be added between Squeeze and op2 to raise the output dimension of Squeeze to 4 for op2 to use;
[0022] Then if new operators need to be added before and after Squeeze, the model will become
[0023] op1 -> new_Squeeze -> Squeeze -> new_Unsqueeze -> op2;
[0024] Case 2) op1 -> Unsqueeze -> op2:
[0025] Judge the size of op1's output_shape.
[0026] If the size of op1's output_shape == 4, then no new operator needs to be added between op1 and Unsqueeze;
[0027] If the `output_shape.size()` of `op1` is less than 4, since the `output_shape.size()` of the implemented `op1` is 4, a new `Squeeze` operator needs to be added first to reduce the `size` of the `output_shape` of `op1` to be the same as that of the `op1` in the neural network model, and then the `Unsqueeze` in the neural network model is executed;
[0028] Judge the size of the `output_shape.size` of `Unsqueeze`,
[0029] If the `output_shape.size()` of `Unsqueeze` == 4, then no new operator needs to be added between `Unsqueeze` and `op2`;
[0030] If the `output_shape.size()` of `Unsqueeze` is less than 4, then a new `Unsqueeze` operator needs to be added between `Unsqueeze` and `op2` to raise the output dimension of `Unsqueeze` to 4 dimensions for `op2` to use;
[0031] Then if new operators need to be added before and after `Unsqueeze`, the model will become `op1` -> `new_Squeeze` -> `Unsqueeze` -> `new_Unsqueeze` -> `op2`;
[0032] Case 3) `op1` -> `Transpose` -> `op2`:
[0033] Judge the size of `perm.size()` of `Transpose`, or the `output_shape.size` of `op1` can also be judged. If `perm.size()` == 4, then no new operator needs to be added between `op1` and `Transpose`, nor between `Transpose` and `op2`;
[0034] If `perm.size()` is less than 4, then a new `Squeeze` operator needs to be added between `op1` and `Transpose`. Since the implemented `op1` and `op2` are 4-dimensional, the `output_shape.size()` of `op1` needs to be reduced to be the same as that of the `op1` in the deep learning network model before executing `Transpose`; similarly, an `Unsqueeze` operator needs to be added between `Transpose` and `op2` to raise the `output_shape.size()` of `Transpose` to 4 dimensions for `op2` to use;
[0035] If new operators need to be added before and after Transpose, the model will become op1->new_Squeeze->Transpose->new_Unsqueeze->op2;
[0036] Case 4) op1->Reshape->op2:
[0037] There is no need to process between op1 and Reshape because regardless of whether the input is 2D, 3D or 4D, the output of Reshape follows the output_shape of Reshape. Therefore, the part that needs to be processed is between Reshape and op2;
[0038] Judge the size of Reshape's output_shape. If output_shape.size() < 4, increase Reshape's output_shape to 4D by adding dimensions to h and w; directly modify the output shape of Reshape to 4D without adding new operators.
[0039] The step S1 further includes:
[0040] Other operators except Reshape, Transpose, Squeeze, Unsqueeze, and Formatconvert only support 4D calculation logic. Therefore, when encountering these operators such as Reshape, Transpose, Squeeze, and Unsqueeze in the code, the operators connected to their upper and lower layers will be judged. Here, the types of operators connected to the upper and lower layers of the Formatconvert operator will not be judged because Formatconvert itself has already implemented dimension conversion and does not require additional new operators. If the operators connected to the upper and lower layers are still Reshape, Transpose, Squeeze, Unsqueeze, or Formatconvert, no processing is required. If not, proceed to step S2;
[0041] Among them, the function introductions are as follows:
[0042] Reshape changes the dimension information;
[0043] Transpose transposes;
[0044] Squeeze reduces dimensions;
[0045] Unsqueeze adds dimensions;
[0046] Formatconvert, which is used for data format conversion and the mutual conversion between two data formats, NHWC and NDHWC32. Among them, NHWC is a data format in deep learning, where N represents batch, H represents height, W represents width, and C represents channel. NDHWC32 is a custom data format that splits the C dimension by 32 times. Here, D is C / 32, and C32 is 32, that is, when the NHWC format of 1, 3, 3, 64 becomes NDHWC32, it is 1, 2, 3, 3, 32, and the 2 here is obtained by 64 / 32.
[0047] The reshape, transpose, squeeze, and unsqueeze are all in the NHWC format; the formats of other operators in the model include both NHWC and NDHWC32.
[0048] The other operators include convolution, pooling, and fully connected.
[0049] The pooling includes max pooling, average pooling, and global pooling.
[0050] In case 4) of step S2, if the output_shape of Reshape is (1, 128), then change the output_shape to (1, 1, 1, 128); if the output_shape of Reshape is (1, 2, 128), then change the output_shape to (1, 1, 2, 128).
[0051] In step S2, assume there is
[0052] Squeeze(output_shape: 1, 128) -> Quantize(output_shape: 1, 128). Then the shape output from Squeeze is two-dimensional, and the input data of Quantize is also two-dimensional. The function of Quantize is quantization, and here it is also an operator. In order not to increase the implementation of the two-dimensional Quantize function, an Unsqueeze operator needs to be added between Squeeze and Quantize to increase the dimension, increasing the output of Squeeze (1, 128) to the dimension of (1, 1, 1, 128).
[0053] Therefore, the advantage of this application is that by adding and modifying operators, the entire model can perform calculations with four-dimensional data, reducing the implementation of the functions of operators with multiple dimensions. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The accompanying drawings described herein are used to provide a further understanding of the present invention, form a part of this application, and do not limit the present invention.
[0055] Figure 1 It is a schematic flowchart of the method of this application. Detailed implementation manners
[0056] In order to more clearly understand the technical content and advantages of the present invention, the present invention will now be further described in detail with reference to the accompanying drawings.
[0057] The operators that need to be noted in all models are reshape, transpose, squeeze, unsqueeze, and Formatconvert.
[0058] Their function introductions are as follows:
[0059] Reshape, change the dimension information;
[0060] Transpose, transpose;
[0061] Squeeze, reduce the dimension;
[0062] Unsqueeze, increase the dimension;
[0063] Formatconvert, convert the data format, and convert between two data formats of NHWC and NDHWC32 (NHWC is a data format in deep learning, N: batch, H: height, W: width, C: channel; while NDHWC32 is a data format defined by our company (Hefei Juzheng Technology Co., Ltd., referred to as: Juzheng) itself, mainly splitting the C dimension by 32 times, where D: C / 32, C32: the channel is 32, that is, 1, 3, 3, 64 in the NHWC format becomes 1, 2, 3, 3, 32 in the NDHWC32 format, and the 2 in it is obtained by 64 / 32). Data format: Reshape, Transpose, Squeeze, Unsqueeze are all in the NHWC format. And the formats of other operators in the model are NHWC and NDHWC32.
[0064] Reshape, Transpose, Squeeze, Unsqueeze are operators that have implemented the functions of 2D, 3D, and 4D,
[0065] In the following text, other operators except Reshape, Transpose, Squeeze, Unsqueeze, and FormatConvert operators, such as convolution, pooling, fully connected, etc., are uniformly referred to as op in the following text. The output_shape operator in the following text is the output shape.
[0066] For example: In the model, there is
[0067] Squeeze(output_shape:1,128)->Quantize(output_shape:1,128). Then the shape output from Squeeze is 2-dimensional, and the input data of Quantize is also 2-dimensional. In order not to increase the implementation of the 2-dimensional Quantize function, an Unsqueeze operator needs to be added between Squeeze and Quantize to increase the dimension, increasing the output (1, 128) of Squeeze to (1, 1, 1, 128); the function of Quantize is quantization, and here it is also a kind of operator.
[0068] The present invention provides a method for processing operators in a deep learning model structure, such as Figure 1 as shown, including:
[0069] S1, determining whether the operator in the model is an operator that has already implemented 2-dimensional, 3-dimensional, and 4-dimensional functions; the operators that have already implemented 4-dimensional functions include: Reshape, Transpose, Squeeze, Unsqueeze, Formatconvert; where Formatconvert mainly realizes the mutual conversion between low dimensions and 5 dimensions;
[0070] If so, no processing is required;
[0071] If not, that is, when it is other operators, then step S2 is performed;
[0072] Other operators except the aforementioned Reshape, Transpose, Squeeze, Unsqueeze, and Formatconvert only support 4D computation logic. Therefore, in the code, when encountering operators such as Reshape, Transpose, Squeeze, and Unsqueeze, the operators connected to their upper and lower layers will be judged. Here, the types of operators connected to the upper and lower layers of the encountered Formatconvert operator will not be judged because Formatconvert itself has already implemented dimension conversion and does not require additional new operators. If the operators connected to the upper and lower layers are still operators such as Reshape, Transpose, Squeeze, Unsqueeze, and Formatconvert, no processing is required. If not, proceed to step S2;
[0073] The other operators include convolution, pooling (max pooling, average pooling, global pooling), and fully connected;
[0074] S2. Judge whether the other operators belong to one of the following situations. If so, process them according to the following situations; if not, do not process them:
[0075] Among them, other operators except the Reshape, Transpose, Squeeze, Unsqueeze, and Formatconvert operators are uniformly called op; the output_shape operator is the output shape;
[0076] Situation 1) op1 -> Squeeze -> op2: where op1 and op2 represent different operators;
[0077] If op1's output_shape.size() == 4, no new operator needs to be added between op1 and Squeeze;
[0078] If op1's output_shape.size() < 4, since the implemented op1's output_shape.size() is 4, a new Squeeze operator needs to be added first to reduce the size of op1's output_shape to the same as that of op1's output_shape in the neural network model, and then the original Squeeze in the neural network model is executed;
[0079] Judge Squeeze and output_shape.size(),
[0080] If the size of the output_shape of Squeeze is equal to 4, then there is no need to add a new operator between Squeeze and op2;
[0081] Because the implemented op1 and op2 are 4-dimensional, so
[0082] When the size of the output_shape of Squeeze is less than 4, and since op2 requires a 4-dimensional input, an Unsqueeze operator needs to be added between Squeeze and op2 to raise the output dimension of Squeeze to 4 for op2 to use;
[0083] Then if new operators need to be added before and after Squeeze, the model will become
[0084] op1 -> new_Squeeze -> Squeeze -> new_Unsqueeze -> op2;
[0085] Case 2) op1 -> Unsqueeze -> op2
[0086] Judge the size of the output_shape.size() of op1,
[0087] If the output_shape.size() of op1 is equal to 4, then no new operator needs to be added between op1 and Unsqueeze;
[0088] If the output_shape.size() of op1 is less than 4, because the output_shape.size() of the implemented op1 is 4, a new Squeeze operator needs to be added first to reduce the size of the output_shape of op1 to be the same as that of op1 in the neural network model, and then Unsqueeze in the neural network model is executed;
[0089] Judge the size of the output_shape.size of Unsqueeze,
[0090] If the output_shape.size() of Unsqueeze is equal to 4, then no new operator needs to be added between Unsqueeze and op2;
[0091] If the output_shape.size() of Unsqueeze is less than 4, then a new Unsqueeze operator needs to be added between Unsqueeze and op2 to raise the output dimension of Unsqueeze to 4 for op2 to use;
[0092] If new operators need to be added before and after Unsqueeze, the model will become op1 -> new_Squeeze -> Unsqueeze -> new_Unsqueeze -> op2;
[0093] Case 3) op1 -> Transpose -> op2:
[0094] Judge the size of perm.size() of Transpose, or the size of op1's output_shape. If perm.size() == 4, no new operators need to be added between op1 and Transpose, and between Transpose and op2;
[0095] If perm.size() < 4, a Squeeze operator needs to be added between op1 and Transpose because the implemented op1 and op2 are 4-dimensional, so the size of op1's output_shape.size() needs to be reduced to be consistent with that of op1 in the deep learning network model before performing Transpose; similarly, an Unsqueeze operator needs to be added between Transpose and op2 to increase the size of Transpose's output_shape.size() to 4 dimensions for op2 to use;
[0096] If new operators need to be added before and after Transpose, the model will become op1 -> new_Squeeze -> Transpose -> new_Unsqueeze -> op2;
[0097] Case 4) op1 -> Reshape -> op2:
[0098] No processing is required between op1 and Reshape because regardless of whether the input is 2D, 3D, or 4D, the output of Reshape follows Reshape's output_shape. Therefore, the part that needs to be processed is between Reshape and op2;
[0099] Judge the size of the output_shape of Reshape. If output_shape.size() < 4, then increase the output_shape of Reshape to 4 dimensions by adding dimensions to h and w. That is, if the output_shape of Reshape is (1, 128), change the output_shape to (1, 1, 1, 128); if the output_shape of Reshape is (1, 2, 128), change the output_shape to (1, 1, 2, 128). Just directly modify the output shape of Reshape to 4 dimensions without adding new operators.
[0100] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, various changes and modifications can be made to the embodiments of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for processing operators in a deep learning model structure, characterized in that, The method changes from 2D or 3D to 4D through operators, enabling the entire model to perform calculations with 4D data, including the following steps: S1. Determine whether the operators in the model are operators that have already implemented 2D, 3D, and 4D functions; The operators that have already implemented 2D, 3D, and 4D functions include: Reshape, Transpose, Squeeze, Unsqueeze, Formatconvert; that is, Reshape, Transpose, Squeeze, Unsqueeze, Formatconvert are all operators that have implemented at least 2D, 3D, and 4D calculation logics; if so, no processing is required; If not, that is, when it is other operators, then go to step S2; S2. Determine whether the other operators belong to one of the following situations. If so, handle them according to the following situations; if not, do not process; Among them, other operators except the Reshape, Transpose, Squeeze, Unsqueeze, Formatconvert operators are collectively called op; the output_shape operator is the output shape; Situation 1) op1->Squeeze->op2: where op1 and op2 represent different operators; If op1's output_shape.size() == 4, then no new operator needs to be added between op1 and Squeeze; If op1's output_shape.size() < 4, since the implemented op1's output_shape.size() is 4, a new Squeeze operator needs to be added first to reduce the size of op1's output_shape to the same as the size of op1's output_shape in the neural network model, and then the original Squeeze in the neural network model is executed; Next, determine Squeeze and output_shape.size(); If Squeeze's output_shape.size() == 4, then no new operator needs to be added between Squeeze and op2; Since the implemented op1 and op2 are 4D, so When Squeeze's output_shape.size() < 4, and because op2 requires a 4D input, an Unsqueeze operator needs to be added between Squeeze and op2 to raise the output dimension of Squeeze to 4D for op2 to use; Then if new operators need to be added before and after Squeeze, the model will become op1->new_Squeeze->Squeeze->new_Unsqueeze->op2; Situation 2) op1->Unsqueeze->op2: Determine the size of op1's output_shape.size(); If the `output_shape.size()` of `op1` is equal to 4, no new operator needs to be added between `op1` and `Unsqueeze`; If the `output_shape.size()` of `op1` is less than 4, since the implemented `output_shape.size()` of `op1` is 4, a new `Squeeze` operator needs to be added first to reduce the size of the `output_shape` of `op1` to be the same as that of `op1` in the neural network model, and then `Unsqueeze` in the neural network model is executed; Judge the size of the `output_shape.size` of `Unsqueeze`, If the `output_shape.size()` of `Unsqueeze` is equal to 4, no new operator needs to be added between `Unsqueeze` and `op2`; If the `output_shape.size()` of `Unsqueeze` is less than 4, a new `Unsqueeze` operator needs to be added between `Unsqueeze` and `op2` to raise the output dimension of `Unsqueeze` to 4D for use by `op2`; Then if new operators need to be added before and after `Unsqueeze`, the model will become `op1 -> new_Squeeze -> Unsqueeze -> new_Unsqueeze -> op2`; Case 3) `op1 -> Transpose -> op2`: Judge the size of `perm.size()` of `Transpose`, or the `output_shape.size()` of `op1` can also be judged. If `perm.size()` is equal to 4, no new operator needs to be added between `op1` and `Transpose`, nor between `Transpose` and `op2`; If `perm.size()` is less than 4, a new `Squeeze` operator needs to be added between `op1` and `Transpose`. Since the implemented `op1` and `op2` are 4D, the `output_shape.size()` of `op1` needs to be reduced to be the same as that of `op1` in the deep learning network model before executing `Transpose`. Similarly, an `Unsqueeze` operator needs to be added between `Transpose` and `op2` to raise the `output_shape.size()` of `Transpose` to 4D for use by `op2`; If new operators need to be added before and after `Transpose`, the model will become `op1 -> new_Squeeze -> Transpose -> new_Unsqueeze -> op2`; Case 4) `op1 -> Reshape -> op2`: There is no need to process the part between op1 and Reshape because regardless of whether the input is 2D, 3D, or 4D, the output of Reshape follows the output_shape of Reshape. Therefore, the part that needs to be processed is between Reshape and op2; Judge the size of output_shape of Reshape. If output_shape.size() < 4, increase the output_shape of Reshape to 4D by adding dimensions to h and w. Just directly modify the output shape of Reshape to 4D, and there is no need to add new operators.
2. The processing method for operators in a deep learning model structure according to claim 1, wherein The step S1 further includes: Other operators except Reshape, Transpose, Squeeze, Unsqueeze, and Formatconvert only support the calculation logic of 4D. So in the code, when encountering operators such as Reshape, Transpose, Squeeze, and Unsqueeze, it will judge the operators connected to their upper and lower layers. Here, the types of operators connected to the upper and lower layers of the encountered Formatconvert operator will not be judged because Formatconvert itself has already implemented dimension conversion and there is no need to add additional new operators. If the operators connected to the upper and lower layers are still Reshape, Transpose, Squeeze, Unsqueeze, or Formatconvert, no processing is required. If not, proceed to step S2; Among them, the function introduction is as follows: Reshape changes the dimension information; Transpose performs transposition; Squeeze reduces dimensions; Unsqueeze increases dimensions; Formatconvert performs data format conversion and mutual conversion between two data formats, NHWC and NDHWC32. Among them, NHWC is a data format in deep learning, where N: batch, H: height, W: width, C: channel; while NDHWC32 is a custom data format that splits the C dimension by 32 times. Here, D: C / 32, and C32: the channel is 32. That is, 1, 3, 3, 64 in the NHWC format becomes 1, 2, 3, 3, 32 in the NDHWC32 format, where 2 is obtained by 64 / 32.
3. The method for processing operators in the deep learning model structure according to claim 2, wherein, The reshape, transpose, squeeze, and unsqueeze are all in the NHWC format; the formats of other operators in the model are both NHWC and NDHWC32.
4. A method for processing operators in a deep learning model structure according to claim 1, characterized in that, The other operators include convolution, pooling, and fully connected.
5. The processing method for operators in a deep learning model structure according to claim 4, characterized in that, The pooling includes max pooling, average pooling, and global pooling.
6. The method for processing operators in a deep learning model structure according to claim 1, wherein In case 4) of step S2, if the output_shape of Reshape is (1, 128), then change the output_shape to (1, 1, 1, 128); if the output_shape of Reshape is (1, 2, 128), then change the output_shape to (1, 1, 2, 128).
7. A method for processing operators in a deep learning model structure according to claim 1, characterized in that In step S2, assume that in the model there is Squeeze(output_shape: 1, 128) -> Quantize(output_shape: 1, 128), then the shape squeezed out from Squeeze is two-dimensional, and the input data of Quantize is also two-dimensional. The function of Quantize is quantization, and this is also an operator here. In order not to increase the implementation of the two-dimensional Quantize function, it is necessary to add an Unsqueeze operator between Squeeze and Quantize to increase the dimension, increasing the output of Squeeze (1, 128) to the dimension (1, 1, 1, 128).
Citation Information
Cited By
Data processing method and device, storage medium and electronic equipment
CN121807315A