Data model adjustment method and device and model construction method and device

By exchanging and adjusting the operation sequence of the target tensor reset operator and the target tensor transpose operator in the data model, the computational efficiency problem caused by the interleaving use of these operators in the prior art is solved, and more efficient data model operations are achieved.

CN119923647APending Publication Date: 2025-05-02VERISILICON MICROELECTRONICS (CHENGDU) CO LTD +4
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202380010743.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-28
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In the existing data model, the target tensor transpose operator and the target tensor reset operator are used interleaved, resulting in inefficient operation of the data model.

Method used

By obtaining the target tensor reset operator and the target tensor transpose operator in the target data model, we judge whether they meet the exchange conditions. If they are satisfied, exchange their operation order in the data model, and adjust the operator expression of the tensor transpose operator to ensure that the operation result does not change.

Benefits of technology

By exchanging and adjusting the operation order of operators, the operation orders of two tensor reset operators are adjacent or the operation orders of two tensor transpose operators are adjacent, thereby improving the overall operation efficiency of the data model and reducing the impact on the data model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119923647A_ABST
    Figure CN119923647A_ABST
Patent Text Reader

Abstract

The invention discloses a data model adjustment method and device, a model construction method and device, electronic equipment and a computer readable storage medium. The data model adjustment method comprises the following steps: acquiring a target tensor reset operator and a target tensor transpose operator in a target data model; judging whether the target tensor reset operator and the target tensor transpose operator meet an exchange condition or not; if the target tensor reset operator and the target tensor transpose operator meet the exchange condition, exchanging the operation sequence of the target tensor reset operator and the target tensor transpose operator in the target data model; and adjusting the operator expression of the tensor transpose operator.
Need to check novelty before this filing date? Find Prior Art

Description

Data model adjustment method and device, model construction method and device Technical Field

[0001] The present application relates to the field of data processing, and more specifically, to a data model adjustment method and device, a model building method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] At present, with the rise of artificial intelligence, various data models are increasingly used in scenarios such as speech recognition, image recognition, and face recognition. In various data models, target tensor transposition operators and target tensor reset operators are widely used as common operator types. However, in various data models in the prior art, a large number of target tensor transposition operators and target tensor reset operators are used interchangeably, which seriously affects the computational efficiency of the data model.

[0003] Summary of the invention

[0004] The purpose of the present application is to provide a data model adjustment method and device, a model construction method and device, an electronic device and a computer-readable storage medium, which can adjust the data model, have a small impact on the data model and improve the computing efficiency of the data model.

[0005] [Corrected 10.10.2023 in accordance with Rule 91] In a first aspect, the present application provides a data model adjustment method, comprising: obtaining a target tensor reset operator and a target tensor transposition operator in a target data model, wherein the target tensor reset operator is a tensor reset operator whose operation order is between two tensor transposition operators, and the target tensor transposition operator is any one of the two tensor transposition operators, or the target tensor transposition operator is a tensor transposition operator whose operation order is between two tensor reset operators, and the target tensor reset operator is any one of the two tensor reset operators; determining whether the target tensor reset operator and the target tensor transposition operator satisfy an exchange condition; if the target tensor reset operator and the target tensor transposition operator satisfy the exchange condition, exchanging the operation order of the target tensor reset operator and the target tensor transposition operator in the target data model; adjusting the operator expression of the tensor transposition operator so that the operation results of the target tensor reset operator and the target tensor transposition operator do not change before and after the operation order is exchanged.

[0006] Compared with the prior art, in the data model adjustment method provided in the embodiment of the present application, when a tensor reset operator in the target data model is located directly between two tensor transposition operators, or a tensor transposition operator is located between two tensor reset operators, the target tensor reset operator and the target tensor transposition operator are obtained, and it is determined whether the target tensor reset operator and the target tensor transposition operator meet the exchange condition. If the target tensor reset operator and the target tensor transposition operator meet the exchange condition, the operation order of the target tensor reset operator and the target tensor transposition operator in the target data model is exchanged, so that the operation order of the two tensor reset operators is adjacent or the operation order of the two tensor transposition operators is adjacent, which is more convenient for the calculation of the tensor reset operator and the tensor transposition operator, and improves the overall operation efficiency of the data model; in addition, after exchanging the operation order of the target tensor reset operator and the target tensor transposition operator, the operator expression of the tensor transposition operator is adjusted so that the operation result does not change, thereby reducing the impact of exchanging the operation order of the target tensor reset operator and the target tensor transposition operator on the data model.

[0007] In an optional embodiment, the judging whether the target tensor reset operator and the target tensor transpose operator satisfy the exchange condition includes: obtaining the input tensor and the output tensor of the target tensor reset operator, the input tensor including multiple input tensor dimension values, and the output tensor including multiple output tensor dimension values; determining multiple data dimension mapping groups corresponding to the target tensor reset operator according to the input tensor and the output tensor, each of the data dimension mapping groups including a correspondence between several of the input tensor dimension values ​​and several of the output tensor dimension values; judging whether the target tensor reset operator and the target tensor transpose operator satisfy the exchange condition according to the multiple data dimension mapping groups and the target tensor transpose operator.

[0008] In an optional embodiment, judging whether the target tensor reset operator and the target tensor transposition operator satisfy the exchange condition according to the multiple data dimension mapping groups and the target tensor transposition operator includes: judging whether the tensor transposition operation corresponding to the target tensor transposition operator is the transposition operation of the multiple data dimension mapping groups between groups; if the tensor transposition operation corresponding to the target tensor transposition operator is the transposition operation of the multiple data dimension mapping groups between groups, determining that the target tensor reset operator and the target tensor transposition operator satisfy the exchange condition; if the tensor transposition operation corresponding to the target tensor transposition operator is not the transposition operation of the multiple data dimension mapping groups between groups, determining that the target tensor reset operator and the target tensor transposition operator do not satisfy the exchange condition.

[0009] In an optional implementation, the adjusting the operator expression of the target tensor transpose operator includes: adjusting the operator expression of the target tensor transpose operator according to the multiple data dimension mapping groups.

[0010] In an optional implementation, the adjusting the operator expression of the target tensor transpose operator according to the multiple data dimension mapping groups includes: the operator expression of the target tensor transpose operator includes multiple transposition dimension values; if the operation order of the target tensor reset operator is before the target tensor transpose operator, the multiple transposition dimension values ​​correspond one-to-one to the output tensor dimension values, and according to the data dimension mapping group, the multiple transposition dimension values ​​are changed to input tensor dimension values ​​corresponding to the multiple transposition dimension values.

[0011] In an optional implementation, the adjusting the operator expression of the target tensor transpose operator according to the multiple data dimension mapping groups further includes: if the operation order of the target tensor reset operator is after the target tensor transpose operator, the multiple transposition dimension values ​​correspond one-to-one to the input tensor dimension values, and according to the data dimension mapping group, the multiple transposition dimension values ​​are changed to output tensor dimension values ​​corresponding to the multiple transposition dimension values.

[0012] In an optional implementation, determining the multiple data dimension mapping groups corresponding to the target tensor reset operator based on the input tensor and the output tensor includes: performing an Euclidean division operation on the multiple input tensor dimension values ​​and the multiple output tensor dimension values ​​to obtain the multiple data dimension mapping groups.

[0013] In an optional implementation, the target data model includes a neural network model, a machine learning model, or a decision tree model.

[0014] In a second aspect, the present application provides a data model construction method, comprising: constructing a target data model according to a preset model framework, the target data model including multiple tensor transposition operators and multiple tensor reset operators; sequentially adjusting the multiple tensor transposition operators and tensor reset operators according to a data model adjustment method as described in any of the aforementioned embodiments.

[0015] [Corrected on 10.10.2023 according to Rule 91] In a third aspect, the present application provides a data model adjustment device, comprising: an operator acquisition module, the operator acquisition module is used to acquire a target tensor reset operator and a target tensor transposition operator in a target data model, the target tensor reset operator is a tensor reset operator whose operation order is between two tensor transposition operators, the target tensor transposition operator is any one of the two tensor transposition operators, or the target tensor transposition operator is a tensor transposition operator whose operation order is between two tensor reset operators, the target tensor reset operator is any one of the two tensor reset operators; a judgment module, The judgment module is used to judge whether the target tensor reset operator and the target tensor transposition operator meet the exchange condition; the data model adjustment module is used to exchange the operation order of the target tensor reset operator and the target tensor transposition operator in the target data model when the target tensor reset operator and the target tensor transposition operator meet the exchange condition; the data model adjustment module is also used to adjust the operator expression of the tensor transposition operator so that the operation result of the target tensor reset operator and the target tensor transposition operator does not change after the operation order of the target tensor reset operator and the target tensor transposition operator is exchanged.

[0016] In a fourth aspect, the present application provides a data model construction device, comprising: a model construction module, wherein the model construction module is used to construct a target data model according to a preset model framework, wherein the target data model includes multiple tensor transposition operators and multiple tensor reset operators; a model adjustment module, wherein the model adjustment module is used to sequentially adjust the multiple tensor transposition operators and tensor reset operators according to the data model adjustment method described in any one of the aforementioned embodiments.

[0017] In a fifth aspect, the present application provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor is used to execute the data model adjustment method as described in any one of the aforementioned embodiments or the data model construction method as described in the aforementioned embodiments.

[0018] In a sixth aspect, the present application provides a computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the data model adjustment method described in any one of the aforementioned embodiments or the data model construction method described in the aforementioned embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0020] FIG1 is a schematic diagram of a flow chart of a data model adjustment method provided in Embodiment 1 of the present application;

[0021] 2 is a schematic diagram of a flow chart of determining whether a target tensor reset operator and a target tensor transposition operator satisfy an exchange condition in a data model adjustment method provided in Embodiment 1 of the present application;

[0022] FIG3 is a schematic diagram of several tensors in the data model adjustment method provided in the first embodiment of the present application;

[0023] FIG4 is a flow chart of a method for constructing a data model according to a second embodiment of the present application;

[0024] FIG5 is a schematic diagram of the structure of a data model adjustment device provided in Embodiment 3 of the present application;

[0025] FIG6 is a schematic diagram of the structure of a data model building device provided in Embodiment 4 of the present application;

[0026] FIG. 7 is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present application. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0028] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0029] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0030] In the description of the present application, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the drawings, or are the orientation or position relationship in which the product of the application is usually placed when used. This is only for the convenience of describing the present application and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application.

[0031] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.

[0032] It should be noted that, in the absence of conflict, the features in the embodiments of the present application may be combined with each other.

[0033] A tensor is a multidimensional array that can be used for data access. The tensor transpose operator is used to perform dimensional transposition operations on tensor data, which can modify the order of data in the memory. The tensor reshape operator can modify the shape of tensor data without modifying the order of data in the memory. In actual applications, data is stored in storage devices, and the stored data can be adjusted according to different usage requirements. For example, the data distribution of stored data can be adjusted by adjusting the tensor, and the adjustment of the tensor can be achieved using a data model composed of a tensor transpose operator and a tensor reshape operator. However, in order to complete complex data distribution adjustments, existing data models may include multiple tensor transposition operators and multiple tensor reset operators, and the operation order between the multiple tensor transposition operators and the multiple tensor reset operators is intertwined. The operation process for a tensor includes repeated tensor transposition and tensor reset operations. For example, for a tensor, the tensor transposition operator is first performed, then the tensor reset operator is performed, and then the tensor transposition operator is performed again. Subsequently, it may include multiple intertwined tensor transposition and tensor reset operations, which reduces the computational efficiency of the data model.

[0034] In order to solve the aforementioned problem of reduced computing efficiency caused by interleaving operations between multiple tensor transposition operators and multiple tensor reset operators, the first embodiment of the present application provides a data model adjustment method for adjusting operators in a data model, while having little impact on the computing results of the data model, while improving the computing efficiency of the data model. The specific data model adjustment method is shown in FIG1, and includes:

[0035] Step S101: Obtain a target tensor reset operator and a target tensor transpose operator in a target data model.

[0036] In this step, the target data model is the data model that needs to be adjusted. In different embodiments of the present application, the target data model can be a model that is initially created without data training, or a model that has completed data training.

[0037] Furthermore, in different embodiments of the present application, the target data model may be any one of a variety of different data models, such as a neural network model, a machine learning model, a decision tree model, etc.

[0038] The target data model includes multiple tensor transposition operators and multiple tensor reset operators, and the multiple tensor transposition operators and the multiple tensor reset operators are interlaced with each other.

[0039] [Corrected on 10.10.2023 according to Rule 91] In this step, the target tensor reset operator and the target tensor transposition operator are the tensor reset operator and the tensor transposition operator in the target data model. In some embodiments of the present application, the target tensor reset operator is a tensor reset operator whose operation order is between two tensor transposition operators, and the target tensor transposition operator is any one of the two tensor transposition operators. Taking the tensor transposition operator A and the tensor reset operator B as an example, if the operation order between the tensor transposition operator A and the tensor reset operator B is ABA, then the target tensor reset operator is the tensor reset operator B located between the two tensor transposition operators A, and the target tensor transposition operator is any one of the two tensor transposition operators A. After the target tensor transposition operator and the target tensor reset operator are exchanged, the tensor transposition operator and the tensor reset operator whose original operation order is ABA are changed to AAB or BAA. At this time, the two tensor transposition operators A are adjacent in the operation order and can be merged to form a new tensor transposition operator or the two can cancel each other out. Alternatively, in other embodiments of the present application, the target tensor transposition operator is a tensor transposition operator whose operation order is between the two tensor reset operators, and the target tensor reset operator is any one of the two tensor reset operators. Similarly, taking the tensor transposition operator as A and the tensor reset operator as B as an example, if the operation order between the tensor transposition operator A and the tensor reset operator B is BAB, then the target tensor transposition operator is the tensor transposition operator A located between the two tensor reset operators B, and the target tensor reset operator is any one of the two tensor reset operators B. Similarly, after the target tensor transposition operator and the target tensor reset operator are exchanged, the tensor transposition operator and the tensor reset operator whose original operation order is BAB are changed to ABB or BBA. At this time, the two tensor reset operators B are adjacent in the operation order and can be merged to form a new tensor reset operator or the two can cancel each other out.

[0040] In some embodiments of the present application, the aforementioned tensor transposition operator and tensor reset operator may be the tensor transposition operator and tensor reset operator originally existing in the data model, or may be the tensor transposition operator and tensor reset operator obtained after adjustment by the data model adjustment method provided in the embodiments of the present application. For example, the original multiple tensor transposition operators and multiple tensor reset operators are ABABA, wherein "ABA" is changed to BAA after sequence adjustment by the data model adjustment method provided in the embodiments of the present application, and the adjacent tensor transposition operators AA can be merged into one tensor transposition operator A, then the original ABABA is changed to BAABA, which is BABA after merging, and further, the "BAB" therein can be further sequence adjusted and the operators merged or offset.

[0041] In addition, in some embodiments of the present application, the target tensor resetting operator and the target tensor transposing operator may be two directly adjacent operators.

[0042] Step S102: Determine whether the target tensor reset operator and the target tensor transpose operator meet the exchange condition. If so, execute step S103; if not, execute step S101.

[0043] As shown in FIG. 2 , this step may include several sub-steps as shown in FIG. 2 , specifically including:

[0044] Step S201: Obtain the input tensor and output tensor of the target tensor reset operator.

[0045] In this step, the input tensor is the tensor that the target tensor reset operator needs to reset, and the input tensor may include multiple input tensor dimension values, and the output tensor is the tensor obtained after the target tensor reset operator resets the input tensor, and the output tensor may include multiple output tensor dimension values. As shown in Figure 3, tensor A (2, 6) is obtained after the tensor transpose operator is operated to obtain tensor B (6, 2), and tensor B (6, 2) is obtained after the tensor reset operator is operated to obtain tensor C (2, 3, 2). Taking Figure 3 as an example, the input tensor can be, for example, tensor B (6, 2) in Figure 3, then the input tensor dimensions are 6, 2, and the output tensor can be, for example, tensor C (2, 3, 2) in Figure 3, then the output tensor dimensions are 2, 3, 2.

[0046] Step S202: Determine multiple data dimension mapping groups corresponding to the target tensor reset operator according to the input tensor and the output tensor.

[0047] In this step, the data resetting operator semantically rearranges the data dimensions of the input tensor, thereby changing the spatial information of data access and obtaining the output tensor. The data dimension mapping group is used to define the transformation relationship between the dimensions of the input tensor and the output tensor. There may be the following mapping relationships between the multiple input tensor dimension values ​​of the input tensor and the multiple output tensor dimension values ​​of the output tensor:

[0048] Direct mapping: does not involve tensor resetting and maintains the dimension information. For example, between the input tensor (2, 2, 100, 128) and the output tensor (4, 10, 10, 128), the direct mapping relationship is that the input tensor dimension value is 128 and the output tensor dimension value is 128.

[0049] Merge mapping: merge multiple dimensions into one output dimension. For example, between the input tensor (2, 2, 100, 128) and the output tensor (4, 10, 10, 128), the input tensor dimension value is 2, 2 and the output tensor dimension value is 4.

[0050] Split mapping: Split one dimension into multiple output dimensions. For example, between the input tensor (2, 2, 100, 128) and the output tensor (4, 10, 10, 128), the input tensor dimension value is 100 and the output tensor dimension value is 10, 10.

[0051] Merge plus split mapping: There are multiple mapping relationships between multiple dimensions. For example, between the input tensor (3, 5, 7, 11) and the output tensor (21, 5, 11), the split mapping relationship is that the input tensor dimension values ​​are 3, 5, 7 and the output tensor dimension values ​​are 21, 5.

[0052] In this step, each data dimension mapping group includes the mapping relationships between a number of input tensor dimension values and a number of output tensor dimension values. That is, the mapping relationships between the input tensor dimension values and the output tensor dimension values that conform to the above mapping relationships are constructed as the data dimension mapping groups. For example, between the input tensor (2, 2, 100, 128) and the output tensor (4, 10, 10, 128), it includes the data dimension mapping group G0 = (in: {0, 1}, out: {0}), the data dimension mapping group G1 = (in: {2}, out: {1, 2}), and the data dimension mapping group G2 = (in: {3}, out: {3}). Among them, the data dimension mapping group G0 = (in: {0, 1}, out: {0}) is the mapping relationship between the first input tensor dimension value (labeled 0) and the second input tensor dimension value (labeled 1) in the input tensor and the first output tensor dimension value (labeled 0) in the output tensor; the data dimension mapping group G1 = (in: {2}, out: {1, 2}) is the mapping relationship between the third input tensor dimension value (labeled 2) in the input tensor and the second output tensor dimension value (labeled 1) and the third output tensor dimension value (labeled 2) in the output tensor; the data dimension mapping group G2 = (in: {3}, out: {3}) is the mapping relationship between the fourth input tensor dimension value (labeled 3) in the input tensor and the fourth output tensor dimension value (labeled 3) in the output tensor.

[0053] In some embodiments of the present application, the辗转相除运算 (Euclidean algorithm) can be performed on multiple input tensor dimension values and multiple output tensor dimension values to obtain multiple data dimension mapping groups. Among them, for the input tensor (K1, K2, K3, K4, K5) and the output tensor (R1, R2, R3), the Euclidean algorithm can include the following steps:

[0054] s1: Obtain the first input tensor dimension value K1 in the input tensor and the first output tensor dimension value R1 in the output tensor. Take the larger value of K1 and R1 as the numerator and the smaller value as the denominator, and calculate the quotient value Q1 and the remainder value W1 between K1 and R1. Taking K1 < R1 as an example, that is, R1 ÷ K1 = Q1...W1.

[0055] s2: If the remainder value W1 is 0 and the quotient value Q1 is not equal to 1, obtain the second tensor dimension value in the tensor to which the tensor dimension value serving as the denominator belongs. If the numerator is R1 and the denominator is K1, obtain the second input tensor dimension value K2 in the input tensor. Conversely, if the numerator is K1 and the denominator is R1, obtain the second output tensor dimension value R2 in the output tensor. Taking the example of obtaining the second input tensor dimension value K2 in the input tensor, in this step, continue to take the larger value of K2 and Q1 as the numerator and the smaller value as the denominator, and calculate the quotient value Q2 and the remainder value W2 between K2 and Q1. It should be noted that the term "辗转相除运算" is usually translated as "Euclidean algorithm" in the context of mathematics. If there is a more specific or accurate translation requirement for this term in your field, you can adjust it accordingly.

[0056] s3: If the remainder value W1 is not 0 and the quotient value Q1 is not equal to 1. At this time, obtain the second input tensor dimension value K2 and the second output tensor dimension value R2, and calculate the quotient value Q2 and the remainder value W2 between K1*K2 and R1*R2.

[0057] s4: If the remainder value W1 is not 0 and the quotient value Q1 is equal to 1. At this time, calculate the product K1*R1 between the numerator K1 and the denominator R1, and obtain the dimension value of the tensor to which the denominator belongs. Taking K1<R1 as an example, that is, obtain the second output tensor dimension value R2, and calculate the quotient value Q2 and the remainder value W2 of K1*R1 and R2.

[0058] s5: Repeatedly execute s2 to s4 until the quotient value is 1 and the remainder value is 0, and output a data dimension mapping group G0 = (in: {0, 1...}, out: {0, 1...}), where 0, 1... are the sequence numbers of the input tensor dimension values and output tensor dimension values that have been obtained.

[0059] s6: Obtain new input tensor dimension values and output tensor dimension values in sequence, and continue to execute s2 to s5 until all input tensor dimension values and output tensor dimension values are calculated.

[0060] Taking the division algorithm operation between the input tensor (2, 2, 10, 10, 128) and the output tensor (4, 100, 128) as an example, first execute s1, calculate the quotient value 2 and the remainder value 0 between the input tensor dimension value 2 and the output tensor dimension value 4, and continue to execute s2, calculate the quotient value 1 and the remainder value 0 between the quotient value 2 and the second input tensor dimension value 2. At this time, execute s5, and output the data dimension mapping group G0 = (in: {0, 1}, out: {0}); then obtain the new input tensor dimension value 10 and the output tensor dimension value 100... in sequence, and output the data dimension mapping group G1 = (in: {2, 3}, out: {1}) and the data dimension mapping group G2 = (in: {4}, out: {2}).

[0061] Taking the Euclidean operation between the input tensor (3, 5, 7, 11) and the output tensor (21, 5, 11) as an example, first execute s1 to calculate the quotient 7 and the remainder 0 between the input tensor dimension value 2 and the output tensor dimension value 21, then continue to execute s2 to calculate the quotient 1 and remainder 2 between the quotient 7 and the second input tensor dimension value 5, then continue to execute s4 to calculate the product 35 between the quotient 7 and the second input tensor dimension value 5, and obtain the second output tensor dimension value 5. The quotient value 7 and the remainder value 0 between the product 35 and the second output tensor dimension value 5 are calculated, and s2 is continued to be executed. The quotient value 1 and the remainder value 0 between the quotient value 7 and the third input tensor dimension value 7 are calculated, and s5 is continued to be executed. The output data dimension mapping group G0 = (in: {0, 1, 2}, out: {0, 1}) is output, and then the new input tensor dimension value 11 and the output tensor dimension value 11 are re-obtained in turn..., and the output data dimension mapping group G1 = (in: {3}, out: {2}).

[0062] Step S203: judging whether the target tensor reset operator and the target tensor transpose operator satisfy the exchange condition according to the multiple data dimension mapping groups and the target tensor transpose operator.

[0063] In this step, the target tensor transposition operator can be used to determine whether the tensor transposition operation corresponding to the target tensor transposition operator is a transposition operation between multiple data dimension mapping groups. If the tensor transposition operation corresponding to the target tensor transposition operator is a transposition operation between multiple data dimension mapping groups, it is determined that the target tensor reset operator and the target tensor transposition operator meet the exchange condition. Conversely, if the tensor transposition operation corresponding to the target tensor transposition operator is not a transposition operation between multiple data dimension mapping groups, it is determined that the target tensor reset operator and the target tensor transposition operator do not meet the exchange condition.

[0064] Among them, the transposition operation between multiple data dimension mapping groups is the overall transposition operation between the input tensor dimension values ​​corresponding to each data dimension mapping group. Taking the target tensor transposition operator {2, 3, 0, 1, 4} as an example, the target tensor transposition operator {2, 3, 0, 1, 4} is to transform the order of tensor dimension values ​​in the tensor {0, 1, 2, 3, 4} into the order of the target tensor transposition operator {2, 3, 0, 1, 4}, that is, the first tensor dimension value is transformed to the third, the second tensor dimension value is transformed to the fourth, the third tensor dimension value is transformed to the first, the fourth tensor dimension value is transformed to the second, and the fifth tensor dimension value remains unchanged. That is, the first tensor dimension value and the second tensor dimension value are taken as a whole, and the third tensor dimension value and the fourth tensor dimension value are transformed as a whole.

[0065] If the corresponding data dimension mapping group at this time is G0 = (in: {0, 1}, out: {0}), G1 = (in: {2, 3}, out: {1}), G2 = (in: {4}, out: {2}), then the input tensor dimension values ​​corresponding to the data dimension mapping group G0 are the first tensor dimension value and the second tensor dimension value, and the input tensor dimension values ​​corresponding to the data dimension mapping group G1 are the third tensor dimension value and the fourth tensor dimension value. At this time, the tensor transposition operation corresponding to the target tensor transposition operator {2, 3, 0, 1, 4} is the transposition operation between the data dimension mapping groups G0 and G1, and it is determined that the target tensor reset operator and the target tensor transposition operator meet the exchange conditions.

[0066] If the corresponding data dimension mapping group at this time is G0 = (in: {0, 1}, out: {0}), G1 = (in: {2}, out: {1, 2}), G2 = (in: {4}, out: {3}), then the input tensor dimension values ​​corresponding to the data dimension mapping group G0 are the first tensor dimension value and the second tensor dimension value, and the input tensor dimension value corresponding to the data dimension mapping group G1 is the third tensor dimension value. At this time, the tensor transposition operation corresponding to the target tensor transposition operator {2, 3, 0, 1, 4} is not a transposition operation between groups of the data dimension mapping groups G0, G1, and G2, and it is determined that the target tensor reset operator and the target tensor transposition operator do not meet the exchange conditions.

[0067] Step S103: swapping the operation order of the target tensor reset operator and the target tensor transpose operator in the target data model.

[0068] Step S104: Adjust the operator expression of the tensor transpose operator.

[0069] In this step, the purpose of adjusting the operator expression of the tensor transposition operator is to ensure that the operation result of the target tensor reset operator and the target tensor transposition operator does not change after the operation order of the target tensor reset operator and the target tensor transposition operator is exchanged. Specifically, the operator expression of the target tensor transposition operator can be adjusted according to multiple data dimension mapping groups.

[0070] Furthermore, in some embodiments of the present application, the operator expression of the target tensor transposition operator includes multiple transposition dimension values. For example, in the aforementioned target tensor transposition operator {2, 3, 0, 1, 4}, 2, 3, 0, 1, 4 are transposition dimension values.

[0071] If the operation order of the target tensor reset operator is before the target tensor transpose operator, that is, the target tensor reset operator is performed first and then the target tensor transpose operator is performed, at this time, the multiple transposition dimension values ​​correspond to the output tensor dimension values ​​one by one, and according to the data dimension mapping group, the multiple transposition dimension values ​​are changed to the input tensor dimension values ​​corresponding to the multiple transposition dimension values. For example, for the tensor (10, 10, 2, 2, 128), the target tensor reset operator is first performed on it to obtain the tensor (100, 4, 128), and then the target tensor transpose operator is performed on the tensor (100, 4, 128) to obtain the tensor (4, 100, 128), wherein the multiple data dimension mapping groups corresponding to the target tensor reset operator are G0=(in: {0, 1}, out: {0}), G1=(in: {2, 3}, out: {1}), G2=(in: {4}, out: {2}); the output tensor dimension values ​​corresponding to the target tensor reset operator are 100, 4, and 128; the target tensor transpose operator is {1, 0, 2}, and the transposed dimension values ​​are 1, 0, and 2. According to the data dimension mapping group, multiple transposed dimension values ​​are changed into input tensor dimension values ​​corresponding to the multiple transposed dimension values, that is, the transposed dimension value 1 is converted into the corresponding input tensor dimension values ​​2 and 3 in the data dimension mapping group G1 = (in: {2, 3}, out: {1}), the transposed dimension value 0 is converted into the corresponding input tensor dimension values ​​0 and 1 in the data dimension mapping group G0 = (in: {0, 1}, out: {0}), and the transposed dimension value 2 is converted into the corresponding input tensor dimension value 4 in the data dimension mapping group G2 = (in: {4}, out: {2}). The operator expression after the target tensor transpose operator {1, 0, 2} is rewritten is {2, 3, 0, 1, 4}.

[0072] If the operation order of the target tensor reset operator is after the target tensor transpose operator, that is, the target tensor transpose operator is performed first and then the target tensor reset operator is performed, at this time, the multiple transposition dimension values ​​correspond to the input tensor dimension values ​​one by one, and according to the data dimension mapping group, the multiple transposition dimension values ​​are changed to output tensor dimension values ​​corresponding to the multiple transposition dimension values. For example, for the tensor (10, 10, 2, 2, 128), the target tensor transpose operator is first performed on it to obtain the tensor (2, 2, 10, 10, 128), and then the target tensor reset operator is performed on the tensor (2, 2, 10, 10, 128) to obtain the tensor (4, 100, 128), wherein the multiple data dimension mapping groups corresponding to the target tensor transpose operator are G0=(in: {0, 1}, out: {0}), G1=(in: {2, 3}, out: {1}), G2=(in: {4}, out: {2}); the input tensor dimension values ​​corresponding to the target tensor reset operator are 2, 2, 10, 10, 128; the target tensor transpose operator is {2, 3, 0, 1, 4}, and the transposed dimension values ​​are 2, 3, 0, 1, 4. According to the data dimension mapping group, multiple transposed dimension values ​​are changed into output tensor dimension values ​​corresponding to the multiple transposed dimension values, that is, the transposed dimension values ​​2, 3 are converted into the corresponding output tensor dimension value 1 in the data dimension mapping group G1 = (in: {2, 3}, out: {1}), the transposed dimension values ​​0, 1 are converted into the corresponding output tensor dimension value 0 in the data dimension mapping group G0 = (in: {0, 1}, out: {0}), and the transposed dimension value 2 is converted into the corresponding output tensor dimension value 4 in the data dimension mapping group G2 = (in: {4}, out: {2}). The operator expression after the target tensor transpose operator {2, 3, 0, 1, 4} is rewritten is {1, 0, 2}.

[0073] Compared with the prior art, in the data model adjustment method provided in the embodiment of the present application, when a tensor reset operator in the target data model is located between two tensor transposition operators, or a tensor transposition operator is located between two tensor reset operators, the target tensor reset operator and the target tensor transposition operator are obtained, and it is determined whether the target tensor reset operator and the target tensor transposition operator meet the exchange condition. If the target tensor reset operator and the target tensor transposition operator meet the exchange condition, the operation order of the target tensor reset operator and the target tensor transposition operator in the target data model is exchanged, so that the operation order of the two tensor reset operators is adjacent or the operation order of the two tensor transposition operators is adjacent, which is more convenient for the calculation of the tensor reset operator and the tensor transposition operator, and improves the overall operation efficiency of the data model; in addition, after exchanging the operation order of the target tensor reset operator and the target tensor transposition operator, the operator expression of the tensor transposition operator is adjusted so that the operation result does not change, thereby reducing the impact of exchanging the operation order of the target tensor reset operator and the target tensor transposition operator on the data model.

[0074] Embodiment 2 of the present application relates to a data model construction method, as shown in FIG4 , including:

[0075] Step S301: construct a target data model according to a preset model framework, wherein the target data model includes multiple tensor transposition operators and multiple tensor resetting operators.

[0076] In this step, the corresponding preset model framework can be used according to the model type of the target data model. For example, if the target data model is a neural network model, the target data model can be constructed using the corresponding neural network model framework including an input layer, multiple hidden layers and an output layer.

[0077] Step S302: sequentially adjust multiple tensor transposition operators and tensor resetting operators.

[0078] In this step, the data model adjustment method in the aforementioned embodiment may be used to sequentially adjust multiple tensor transposition operators and multiple tensor resetting operators in the target data model.

[0079] Compared with the prior art, in the data model construction method provided in the embodiment of the present application, after the target data model is constructed using a preset model framework, the data model adjustment method in the aforementioned embodiment is used to sequentially adjust multiple tensor transposition operators and multiple tensor reset operators in the target data model, so that the computational efficiency of the constructed target data model can be improved.

[0080] [Corrected on 10.10.2023 according to Rule 91] Embodiment 3 of the present application relates to a data model adjustment device, as shown in FIG5 , comprising: an operator acquisition module 401, the operator acquisition module 401 is used to acquire a target tensor reset operator and a target tensor transposition operator in a target data model, the target tensor reset operator is a tensor reset operator whose operation order is between two tensor transposition operators, the target tensor transposition operator is any one of the two tensor transposition operators, or the target tensor transposition operator is a tensor transposition operator whose operation order is between two tensor reset operators, the target tensor reset operator is any one of the two tensor reset operators. The module 402 is used for judging whether the target tensor reset operator and the target tensor transposition operator satisfy the exchange condition; the data model adjustment module 403 is used for exchanging the operation order of the target tensor reset operator and the target tensor transposition operator in the target data model when the target tensor reset operator and the target tensor transposition operator satisfy the exchange condition; the data model adjustment module is also used for adjusting the operator expression of the tensor transposition operator so that the operation result of the target tensor reset operator and the target tensor transposition operator does not change after the operation order of the target tensor reset operator and the target tensor transposition operator is exchanged.

[0081] Compared with the prior art, in the data model adjustment device provided in the embodiment of the present application, when a tensor reset operator in the target data model is located directly between two tensor transposition operators, or a tensor transposition operator is located between two tensor reset operators, the operator acquisition module 401 acquires the target tensor reset operator and the target tensor transposition operator, and the judgment module 402 judges whether the target tensor reset operator and the target tensor transposition operator meet the exchange condition. If the target tensor reset operator and the target tensor transposition operator meet the exchange condition, the data model adjustment module 403 exchanges the target tensor reset operator. and the order of operations of the target tensor transposition operator in the target data model, so that the order of operations of the two tensor reset operators are adjacent or the order of operations of the two tensor transposition operators are adjacent, which is more convenient for the calculation of the tensor reset operator and the tensor transposition operator, and improves the overall operation efficiency of the data model; in addition, after exchanging the order of operations of the target tensor reset operator and the target tensor transposition operator, the data model adjustment module 403 also adjusts the operator expression of the tensor transposition operator so that the operation result does not change, thereby reducing the impact of exchanging the order of operations of the target tensor reset operator and the target tensor transposition operator on the data model.

[0082] Embodiment 4 of the present application relates to a data model construction device, as shown in FIG6 , comprising: a model construction module 501, the model construction module 501 is used to construct a target data model according to a preset model framework, the target data model includes multiple tensor transposition operators and multiple tensor reset operators; a model adjustment module 502, the model adjustment module 502 is used to sequentially adjust multiple tensor transposition operators and tensor reset operators according to the data model adjustment method provided in the above-mentioned embodiment.

[0083] Compared with the prior art, in the data model construction device provided in the embodiment of the present application, after the model construction module 501 uses the preset model framework to construct the target data model, the model adjustment module 502 uses the data model adjustment method in the aforementioned embodiment to sequentially adjust multiple tensor transposition operators and multiple tensor reset operators in the target data model, thereby improving the computational efficiency of the constructed target data model.

[0084] Regarding the data model in the above embodiments, in some embodiments, the data model may be a model for performing corresponding tasks in different fields, and the data model may be applied to a variety of different fields, including but not limited to the fields of image processing, speech processing, NLP (Natural Language Processing), etc.

[0085] Correspondingly, the input tensor in the above embodiment may be the corresponding data to be processed in the relevant field. For example, the input tensor may include but is not limited to images to be processed, voices to be processed, texts to be processed, etc.

[0086] Embodiment 5 of the present application relates to an electronic device, as shown in FIG7 , comprising: at least one processor 601; and a memory 602 communicatively connected to the at least one processor 601; wherein the memory 602 stores instructions executable by the at least one processor 601, and the instructions are executed by the at least one processor 601 so that the at least one processor 601 can execute the data model adjustment method or the data model construction method in the above-mentioned embodiments.

[0087] Among them, the memory and the processor are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor.

[0088] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor when performing operations.

[0089] Embodiment 6 of the present application relates to a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the above method embodiment is implemented.

[0090] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0091] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed in the present application should be covered within the protection scope of the present application.

Claims

[Corrected 10.10.2023 in accordance with Rule 91] A data model adjustment method, characterized in that: include: Obtain a target tensor reset operator and a target tensor transposition operator in a target data model, wherein the target tensor reset operator is a tensor reset operator whose operation order is between two tensor transposition operators, and the target tensor transposition operator is any one of the two tensor transposition operators, or the target tensor transposition operator is a tensor transposition operator whose operation order is between two tensor reset operators, and the target tensor reset operator is any one of the two tensor reset operators; determine whether the target tensor reset operator and the target tensor transposition operator satisfy an exchange condition; If the target tensor resetting operator and the target tensor transposing operator satisfy the exchange condition, exchanging the operation order of the target tensor resetting operator and the target tensor transposing operator in the target data model; The operator expression of the tensor transposition operator is adjusted so that the operation results of the target tensor reset operator and the target tensor transposition operator do not change before and after the operation order is exchanged. The data model adjustment method according to claim 1, characterized in that: The judging whether the target tensor reset operator and the target tensor transpose operator satisfy the exchange condition includes: obtaining the input tensor and the output tensor of the target tensor reset operator, the input tensor including multiple input tensor dimension values, and the output tensor including multiple output tensor dimension values; determining multiple data dimension mapping groups corresponding to the target tensor reset operator according to the input tensor and the output tensor, each of the data dimension mapping groups including a correspondence between several input tensor dimension values ​​and several output tensor dimension values; judging whether the target tensor reset operator and the target tensor transpose operator satisfy the exchange condition according to the multiple data dimension mapping groups and the target tensor transpose operator. The data model adjustment method according to claim 2 is characterized in that: The determining whether the target tensor reset operator and the target tensor transposition operator satisfy the exchange condition according to the multiple data dimension mapping groups and the target tensor transposition operator includes: determining whether the tensor transposition operation corresponding to the target tensor transposition operator is the transposition operation of the multiple data dimension mapping groups between groups; if the tensor transposition operation corresponding to the target tensor transposition operator is the transposition operation of the multiple data dimension mapping groups between groups, determining that the target tensor reset operator and the target tensor transposition operator satisfy the exchange condition; if the tensor transposition operation corresponding to the target tensor transposition operator is not the transposition operation of the multiple data dimension mapping groups between groups, determining that the target tensor reset operator and the target tensor transposition operator do not satisfy the exchange condition. The data model adjustment method according to claim 2 is characterized in that: The adjusting the operator expression of the target tensor transpose operator includes: adjusting the operator expression of the target tensor transpose operator according to the multiple data dimension mapping groups. The data model adjustment method according to claim 4 is characterized in that: The adjusting the operator expression of the target tensor transpose operator according to the multiple data dimension mapping groups includes: the operator expression of the target tensor transpose operator includes multiple transposition dimension values; if the operation order of the target tensor reset operator is before the target tensor transpose operator, the multiple transposition dimension values ​​correspond to the output tensor dimension values ​​one by one, and according to the data dimension mapping group, the multiple transposition dimension values ​​are changed to input tensor dimension values ​​corresponding to the multiple transposition dimension values. The data model adjustment method according to claim 5 is characterized in that: The adjusting the operator expression of the target tensor transposition operator according to the multiple data dimension mapping groups also includes: if the operation order of the target tensor reset operator is after the target tensor transposition operator, the multiple transposition dimension values ​​correspond one-to-one to the input tensor dimension values, and according to the data dimension mapping group, the multiple transposition dimension values ​​are changed to output tensor dimension values ​​corresponding to the multiple transposition dimension values. The data model adjustment method according to claim 2 is characterized in that: The method of determining the multiple data dimension mapping groups corresponding to the target tensor reset operator according to the input tensor and the output tensor includes: performing Euclidean division operations on the multiple input tensor dimension values ​​and the multiple output tensor dimension values ​​to obtain the multiple data dimension mapping groups. The data model adjustment method according to any one of claims 1 to 7, characterized in that: The target data model includes a neural network model, a machine learning model, and a decision tree model; the target data model is used to adjust the data layout. A data model construction method, characterized in that: include: Constructing a target data model according to a preset model framework, wherein the target data model includes a plurality of tensor transposition operators and a plurality of tensor resetting operators; The multiple tensor transposition operators and tensor reset operators are sequentially adjusted according to the data model adjustment method according to any one of claims 1 to 8. [Corrected 10.10.2023 according to Rule 91] A data model adjustment device, characterized in that, include: An operator acquisition module, the operator acquisition module is used to acquire a target tensor reset operator and a target tensor transposition operator in a target data model, the target tensor reset operator is a tensor reset operator whose operation order is between two tensor transposition operators, the target tensor transposition operator is any one of the two tensor transposition operators, or the target tensor transposition operator is a tensor transposition operator whose operation order is between two tensor reset operators, the target tensor reset operator is any one of the two tensor reset operators; a judgment module, the judgment module is used to judge whether the target tensor reset operator and the target tensor transposition operator meet the exchange condition; A data model adjustment module, wherein the data model adjustment module is used to exchange the operation order of the target tensor reset operator and the target tensor transposition operator in the target data model when the target tensor reset operator and the target tensor transposition operator meet the exchange condition; the data model adjustment module is also used to adjust the operator expression of the tensor transposition operator so that the operation result of the target tensor reset operator and the target tensor transposition operator does not change after the operation order of the target tensor reset operator and the target tensor transposition operator is exchanged. A data model building device, characterized in that: include: A model building module, wherein the model building module is used to build a target data model according to a preset model framework, wherein the target data model includes a plurality of tensor transposition operators and a plurality of tensor resetting operators; A model adjustment module, wherein the model adjustment module is used to sequentially adjust the multiple tensor transposition operators and tensor resetting operators according to the data model adjustment method according to any one of claims 1 to 8. An electronic device, characterized in that: include: at least one processor; And, a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor is used to execute the data model adjustment method as described in any one of claims 1 to 8 or the data model construction method as described in claim 9. A computer-readable storage medium storing a computer program, characterized in that: The computer program is executed by a processor to implement the data model adjustment method described in any one of claims 1 to 8 or the data model construction method described in claim 9.