Tensor segmentation method and device of operator
By obtaining and correcting the tensor segmentation information of the target operator, the need for single-operator and fusion operator segmentation solutions in the existing technology is solved, the generalization ability and efficiency of tensor segmentation are improved, and the manual labor is reduced. Maintenance costs are reduced, and efficient processing of tensor segmentation is achieved.
Patent Information
- Application Number
- CN202410904707.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-09-27
AI Technical Summary
The tensor segmentation scheme of existing operators requires different segmentation schemes for single operators and fusion operators, resulting in high maintenance costs and poor generalization of the algorithm, and requires manual continuous updating of historical data to update the machine learning model.
By obtaining the segmentation information of the target operator, if there is no fusion operator, tensor binding is performed. If there is a fusion operator, the segmentation information is corrected based on its input and output tensors, and the corrected information is bound. Determining the corresponding tensor of the fusion operator avoids the need to set separate segmentation plans for single operators and fusion operators, reducing manual maintenance costs.
It improves the generalization ability and efficiency of tensor segmentation, reduces manual maintenance costs, and avoids the need for continuous updates of machine learning models.
Smart Images

Figure CN118709809A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of chip technology, and in particular to a tensor segmentation method and device for an operator. Background Art
[0002] Tensor splitting of an operator usually refers to the process of splitting a large tensor into multiple smaller tensors. The multiple smaller tensors after splitting can be processed in parallel, which helps to improve computing efficiency.
[0003] Currently, the tensor segmentation schemes for operators can be divided into two categories: one is to set up two different segmentation schemes for single operators and fusion operators respectively, but this scheme not only requires algorithm maintenance for the two schemes, but also has poor generalization. The second is to use a large amount of historical data to build a machine learning model, and segment the operator's tensor based on the machine learning model, but this scheme requires manual continuous acquisition of updated historical data and continuous update of machine learning model parameters based on the updated historical data, resulting in high manual maintenance costs. Summary of the invention
[0004] The present invention provides a tensor segmentation method and device for an operator, so as to solve the defects existing in the related art.
[0005] The present invention provides a tensor segmentation method of an operator, comprising the following steps.
[0006] Get the segmentation information of the first operator in the target operator; If there is no fusible operator after the first operator, the segmentation information of the first operator is bound to the corresponding tensor, and the fusible operator can be fused with the first operator into one operator; If there is a fusible operator after the first operator, the segmentation information of the first operator is modified based on the input tensor and output tensor of the fusible operator, and the modified segmentation information is bound to the corresponding tensor of the fusible operator.
[0007] According to a tensor segmentation method of an operator provided by the present invention, the segmentation information of the first operator is corrected based on the input tensor and the output tensor of the fusible operator, and the corrected segmentation information is bound to the corresponding tensor of the fusible operator, including: If the fusible operator includes 1 input tensor and 1 output tensor, the segmentation information of the output tensor corresponding to the first operator is bound to the input tensor and the output tensor of the fusible operator; If the fusible operator includes two input tensors, based on the operation type performed by the first operator, the segmentation information of the first operator is modified, and the modified segmentation information is bound to the corresponding tensor of the fusible operator; If the fusible operator includes at least 3 input tensors, the tensors of the fusible operator are not split.
[0008] According to a tensor segmentation method of an operator provided by the present invention, the segmentation information of the first operator is modified based on the operation type performed by the first operator, and the modified segmentation information is bound to the corresponding tensor of the fusible operator, including: Binding the segmentation information of the output tensor corresponding to the first operator to an input tensor in the fusible operator and the output tensor of the fusible operator; Based on the operation type performed by the first operator, the segmentation information of the input tensor corresponding to the first operator is modified, and the modified segmentation information is bound to another input tensor in the fusible operator.
[0009] According to a tensor splitting method of an operator provided by the present invention, based on the operation type performed by the first operator, the splitting information of the input tensor corresponding to the first operator is corrected, and the corrected splitting information is bound to another input tensor in the fusible operator, including: If the operation type performed by the first operator is a matrix multiplication-addition operation, determining whether the batch axis on the input tensor corresponding to the first operator is split; If yes, the batch axis splitting information on the input tensor corresponding to the first operator is modified to not be split, and the modified splitting information is bound to another input tensor in the fusible operator; If not, the segmentation information of the input tensor corresponding to the first operator is bound to another input tensor in the fusible operator.
[0010] According to a tensor splitting method of an operator provided by the present invention, based on the operation type performed by the first operator, the splitting information of the input tensor corresponding to the first operator is corrected, and the corrected splitting information is bound to another input tensor in the fusible operator, including: If the operation type performed by the first operator is not a matrix multiplication-addition operation, the segmentation information of the input tensor corresponding to the first operator is bound to another input tensor in the fusible operator.
[0011] According to a tensor segmentation method of an operator provided by the present invention, the segmentation information of the first operator is determined based on the tensor attribute of the first operator.
[0012] The present invention also provides a tensor segmentation device for an operator, comprising the following modules: An information acquisition unit, used to acquire the segmentation information of the first operator in the target operator; The first segmentation unit is used for binding the segmentation information of the first operator to corresponding tensors if there is no fusible operator after the first operator, so that the fusible operator can be fused with the first operator into one operator; The second segmentation unit is used to modify the segmentation information of the first operator based on the input tensor and output tensor of the fusible operator if there is a fusible operator after the first operator, and bind the modified segmentation information to the corresponding tensor of the fusible operator.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a tensor splitting method of any of the operators described above is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a tensor splitting method for any of the operators described above.
[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the tensor segmentation method of any of the operators described above is implemented.
[0016] The tensor splitting method and device of the operator provided by the present invention, if there is no fusible operator after the first operator, the splitting information of the first operator is bound to the corresponding tensor, thereby realizing the tensor splitting of the single operator. If there is a fusible operator after the first operator, the splitting information of the first operator is corrected based on the input tensor and output tensor of the fusible operator, and the corrected splitting information is bound to the corresponding tensor of the fusible operator, thereby realizing the tensor splitting of the fused operator. It can be seen that the present invention does not need to set different splitting schemes for single operators and fused operators respectively, thereby improving the generalization ability and efficiency of tensor splitting. In addition, the present invention does not need to manually and continuously update historical data to update the machine learning model, thereby reducing the manual maintenance cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a flow chart of the tensor segmentation method of the operator provided by the present invention.
[0019] Figure 2It is a flowchart of another tensor segmentation method of an operator provided by the present invention.
[0020] Figure 3 It is a structural schematic diagram of the tensor segmentation device of the operator provided by the present invention.
[0021] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] At present, the tensor segmentation schemes of operators can be divided into two categories: one is to set two different segmentation schemes for single operators and fusion operators respectively, but this scheme not only requires algorithm maintenance for the two schemes, but also because the single operator and the fusion operator use different segmentation schemes, the reusability of the algorithm is limited, and the existing optimization experience and algorithms cannot be effectively shared and utilized in different situations, thus affecting the overall generalization ability and efficiency. Among them, a single operator refers to an operator with only one single operation, a fusion operator refers to an operator that combines multiple single operations into a larger operation, and a fusion operator is composed of multiple single operators.
[0024] The second is to use a large amount of historical data to build a machine learning model and split the operator's tensor based on the machine learning model. However, this solution requires manual continuous updating of historical data and adjustment of machine learning model parameters based on the updated historical data to adapt to new data and changing needs. In other words, continuous manual intervention and monitoring of historical data updates are required, which increases the complexity and cost of maintenance.
[0025] Figure 1 It is a flow chart of the tensor segmentation method of the operator provided by the present invention, such as Figure 1 As shown, the method includes step 110 , step 120 and step 130 .
[0026] Step 110: Obtain the segmentation information of the first operator in the target operator.
[0027] Here, the target operator refers to the operator to be used for tensor splitting. The target operator is usually bound to its corresponding tensor. The relationship between the target operator and its corresponding tensor can be understood as the target operator is a function or mapping that operates on its tensor. The target operator can be a tensor core (Tcore) operator or a Tcore fusion operator.
[0028] Among them, the main operations performed by the Tcore operator on tensors include matrix multiplication, mixed precision calculations, and dynamic adjustment of computing power. The first operator in the Tcore fusion operator is usually the Tcore operator. There is at least one vector operator (Vector operator) after the Tcore operator. Vector operators refer to operators used to operate tensors in mathematics and physics. Vector operators are usually element-wise operators (Element wise operators). Element wise operators are used to describe arithmetic operations on each element in the tensor. For example, Element wise operators can include addition operators (add operators), multiplication operators (mul operators), etc.
[0029] The first operator can be understood as the first single operator in the target operator. For example, if the target operator is a Tcore fusion operator, the first operator is the Tcore operator. The split information of the first operator can be understood as the parameters involved in splitting the tensor corresponding to the first operator, such as the split dimension, the number of splits corresponding to the split dimension, etc.
[0030] Optionally, the segmentation information of the first operator may be determined according to the shape of the tensor corresponding to the first operator, the dimension of the corresponding tensor, etc. The shape refers to the number of elements in each dimension of the tensor.
[0031] Step 120: If there is no fusible operator after the first operator, the split information of the first operator is bound to the corresponding tensor, and the fusible operator can be fused with the first operator into one operator.
[0032] Specifically, a fusible operator is an operator that can be combined with the first operator to perform a single operation, that is, the operation of the fusible operator on the tensor and the operation of the first operator on the tensor can be fused into a single operation. For example, the convolution operation (Convolution) and the activation function operation (Activation) can be fused into a single fused convolution operation.
[0033] If there is no fusible operator after the first operator, it means that the target operator only includes the first operator, and the first operator is a single operator, which means that the target operator is also a single operator. In this case, the split information of the first operator is bound to the corresponding tensor, that is, the split information of the input tensor in the split information of the first operator is applied to the input tensor to split the input tensor, and the split information of the output tensor is applied to the output tensor to split the output tensor.
[0034] Step 130: If there is a fusible operator after the first operator, the segmentation information of the first operator is corrected based on the input tensor and output tensor of the fusible operator, and the corrected segmentation information is bound to the corresponding tensor of the fusible operator.
[0035] Specifically, if there is a fusible operator after the first operator, it indicates that the target operator includes the first operator and at least one fusible operator, that is, the target operator is a fusion operator. If there are multiple input tensors for the fusible operator, one input tensor is the output tensor of the first operator, and the other input tensor comes from another operator. Since the tensor splitting requirements of the other operator may be different from those of the first operator, the splitting information of the first operator cannot be directly bound to the fusible operator. For example, if the batch axis of the tensor is split in the splitting information of the first operator, but the batch axis of the tensor is not allowed to be split in the other operator, in this case, the splitting information of the first operator cannot be directly applied to the other input tensor.
[0036] In this regard, an embodiment of the present invention corrects the segmentation information of the first operator based on the input tensor and output tensor of the fusible operator, and binds the corrected segmentation information to the corresponding tensor of the fusible operator.
[0037] The tensor splitting method of operators provided in the embodiment of the present invention, if there is no fusible operator after the first operator, the splitting information of the first operator is bound to the corresponding tensor, thereby realizing the tensor splitting of the single operator. If there is a fusible operator after the first operator, the splitting information of the first operator is corrected based on the input tensor and output tensor of the fusible operator, and the corrected splitting information is bound to the corresponding tensor of the fusible operator, thereby realizing the tensor splitting of the fused operator. It can be seen that the embodiment of the present invention does not need to set different splitting schemes for single operators and fused operators respectively, thereby improving the generalization ability and efficiency of tensor splitting. In addition, the embodiment of the present invention does not need to manually and continuously update historical data to update the machine learning model, thereby reducing the manual maintenance cost.
[0038] As an optional embodiment, the target operator can be an operator in a neural network model. After tensor splitting is performed using the above-mentioned embodiment method, the tensors obtained after splitting are assigned to corresponding computing cores for parallel computing. The obtained calculation results can be applied to model reasoning to obtain model reasoning results.
[0039] Furthermore, the neural network model can be a text generation model, a text graph model, a computer vision model (such as an image classification model, a target detection model, a semantic segmentation model, etc.), etc. Taking the text generation model as an example, the input tensor of the target operator can be determined based on the input text. After the tensor is segmented using the method of the above embodiment, each tensor obtained after the segmentation is assigned to the corresponding computing core for parallel computing, and the obtained calculation results can be applied to model reasoning to obtain the output text corresponding to the input text. Since the above method can improve the computing efficiency, it can improve the reasoning speed of the model, and then improve the generation efficiency of the output text.
[0040] Based on the above embodiment, based on the input tensor and output tensor of the fusible operator, the segmentation information of the first operator is corrected, and the corrected segmentation information is bound to the corresponding tensor of the fusible operator, including: If the fusible operator includes 1 input tensor and 1 output tensor, the segmentation information of the output tensor corresponding to the first operator is bound to the input tensor and output tensor of the fusible operator; If the fusible operator includes two input tensors, the segmentation information of the first operator is modified based on the operation type performed by the first operator, and the modified segmentation information is bound to the corresponding tensor of the fusible operator; If a fusible operator includes at least 3 input tensors, the tensors of the fusible operator are not split.
[0041] Specifically, if the fusible operator has only one input tensor and one output tensor, in order to maximize the computing efficiency, the split information of the output tensor corresponding to the first operator is bound to the input tensor and output tensor of the fusible operator, that is, the input tensor and output tensor of the fusible operator are split according to the split information of the output tensor of the first operator. Among them, the storage operator (stm operator, i.e. store operator) and the type conversion operator (typecast operator) have only one input tensor and one output tensor.
[0042] For example, the output tensor of the target operator is divided into four parts along a certain axis, namely, tensor A, tensor B, tensor C and tensor D. The input tensor of the fusible operator is the output tensor of the target operator, that is, the input tensor of the fusible operator is also divided into four parts along a certain axis, namely, tensor A, tensor B, tensor C and tensor D are the input tensors of the fusible operator.
[0043] If the output tensor of the fusible operator is also divided into four parts according to the segmentation information of the output tensor of the target operator, it indicates that the computing tasks of the fusible operator will be assigned to four independent computing cores, and then the computing tasks of tensor A, tensor B, tensor C and tensor D are processed on the above four independent computing cores respectively, with complementary interference, that is, the computing tasks of tensor A, tensor B, tensor C and tensor D can be executed in parallel, thereby maximizing the computing efficiency.
[0044] If the output tensor of the fusible operator is split into two parts, it means that the computing tasks of the fusible operator will be assigned to two independent computing cores, which means that the computing tasks of tensors A, B, C, and D are assigned to two independent computing cores for processing. There must be at least one computing core that will be assigned multiple computing tasks. For example, one computing core is responsible for processing the computing tasks of tensors A and B, and the other computing core is responsible for processing the computing tasks of tensors C and D. After the calculation of tensor A is completed, it is necessary to wait for the calculation of tensor B to be completed before the final result can be output on the corresponding computing core, which affects the computing efficiency.
[0045] If a fusible operator includes two input tensors, it means that one input tensor of the fusible operator is the output tensor of the first operator, and the other input tensor comes from the output of another operator. If the other operator's requirements for the segmentation of each dimension (i.e., each axis) of the tensor are different from those of the first operator, the segmentation information of the first operator cannot be directly applied to the other input tensor. Among them, the add_bias operator and the addition operator (add operator) all include two input tensors.
[0046] For example, if the split information of the first operator splits the batch axis of the tensor, but another operator does not allow the batch axis of the tensor to be split, in this case, the split information of the first operator cannot be directly applied to the other input tensor.
[0047] In this regard, the embodiment of the present invention modifies the segmentation information of the first operator based on the operation type performed by the first operator, and binds the modified segmentation information to the corresponding tensor of the fusible operator. The operation type performed by the first operator is used to characterize the type of computing task performed by the first operator, and the operation type may include matrix multiplication and addition operations, matrix operations, etc.
[0048] In addition, considering that as the number of input tensors increases, the complexity of the splitting strategy will also increase significantly, which will cause the logic of data rearrangement to become too complicated. In addition, if too many tensors are split, operations that could have been processed in parallel may have to be executed serially, thereby increasing the calculation time. Therefore, if a fusible operator includes at least 3 input tensors, it means that there are too many input tensors. In order to avoid the segmentation strategy being too complicated and not affecting the calculation efficiency, the embodiment of the present invention does not split the tensors of the fusible operator in this case.
[0049] Based on any of the above embodiments, based on the operation type performed by the first operator, the segmentation information of the first operator is modified, and the modified segmentation information is bound to the corresponding tensor of the fusible operator, including: Bind the split information of the output tensor corresponding to the first operator to an input tensor in the fusible operator and the output tensor of the fusible operator; Based on the operation type performed by the first operator, the split information of the input tensor corresponding to the first operator is modified, and the modified split information is bound to another input tensor in the fusible operator.
[0050] Specifically, if a fusible operator includes two input tensors, it indicates that one input tensor of the fusible operator is the output tensor of the first operator, and the other input tensor comes from the output of another operator. Therefore, one input tensor and output tensor in the fusible operator can apply the segmentation information of the output tensor of the first operator.
[0051] For another input tensor in the fusible operator, since it comes from another operator, considering that the segmentation requirements of the other operator for each dimension of the tensor are different from those of the first operator, based on the operation type performed by the first operator, the segmentation information of the corresponding input tensor of the first operator is corrected, and the corrected segmentation information is bound to another input tensor in the fusible operator.
[0052] Based on any of the above embodiments, based on the operation type performed by the first operator, the segmentation information of the input tensor corresponding to the first operator is modified, and the modified segmentation information is bound to another input tensor in the fusible operator, including: If the operation type performed by the first operator is a matrix multiply-add operation, determine whether the batch axis on the input tensor corresponding to the first operator is split; If yes, the batch axis splitting information on the input tensor corresponding to the first operator is corrected to not be split, and the corrected splitting information is bound to another input tensor in the fusible operator; If not, the split information of the corresponding input tensor of the first operator is bound to another input tensor in the fusible operator.
[0053] Specifically, the output result of the matrix multiply-accumulate (MMA) operation is usually calculated based on all elements of the input matrix. This operation requires the participation of each element in the matrix. Therefore, if subsequent operators want to continue to perform further processing or fusion based on the results of the matrix multiply-accumulate operation, they need to ensure that these elements are available, that is, they need to input the complete batch axis data.
[0054] If the operation type performed by the first operator is a matrix multiplication-addition operation, and the batch axis on the input tensor of the first operator is split, since the fusible operator is the subsequent operator of the first operator, the complete batch axis data is input into the fusible operator, that is, the batch axis of another input tensor in the fusible operator cannot be split. In this case, the batch axis split information on the input tensor corresponding to the first operator is corrected to not be split, and the corrected split information is bound to another input tensor in the fusible operator to ensure that the complete batch axis data is input into the fusible operator.
[0055] If the batch axis on the input tensor of the first operator is not split, when the split information of the corresponding input tensor of the first operator is bound to another input tensor in the fusible operator, the other input tensor of the fusible operator will not split the batch axis, so that the fusible operator can obtain the complete batch axis data.
[0056] Based on any of the above embodiments, based on the operation type performed by the first operator, the segmentation information of the input tensor corresponding to the first operator is modified, and the modified segmentation information is bound to another input tensor in the fusible operator, including: If the operation type performed by the first operator is not a matrix multiplication-addition operation, the split information of the input tensor corresponding to the first operator is bound to another input tensor in the fusible operator.
[0057] Specifically, if the operation type performed by the first operator is not a matrix multiplication-addition operation, it indicates that the fusible operator does not need to input the complete batch axis data, and then the other input tensor of the fusible operator can be split according to the splitting information of the input tensor corresponding to the first operator, that is, the splitting information of the input tensor corresponding to the first operator is bound to another input tensor in the fusible operator.
[0058] As an optional embodiment, it is assumed that the target operator is a Tcore fusion operator, the first operator is a Tcore operator (the input tensors include input0 and input1, and the output tensor is output), and the fusible operator is an add_bias operator.
[0059] If the operation type performed by the Tcore operator is MMA, and the batch axis is split on input1, the split information of output is bound to an input tensor and output tensor of the add_bias operator, the batch axis split information on input1 is corrected to not be split, and the corrected split information is bound to another input tensor in the add_bias operator.
[0060] If the operation type performed by the Tcore operator is not MMA, the split information of output is bound to an input tensor and output tensor of the add_bias operator, and the split information of input1 is bound to another input tensor in the add_bias operator.
[0061] Based on any of the above embodiments, the segmentation information of the first operator is determined based on the tensor attribute of the first operator.
[0062] Specifically, the tensor attributes of the first operator may include the dimension and shape size of the tensor, where the dimension refers to the number of independent directions of the target tensor. When determining the splitting information of the input tensor of the first operator, it is determined based on the dimension and shape size of the input tensor; when determining the splitting information of the output tensor of the first operator, it is determined based on the dimension and shape size of the output tensor.
[0063] For example, a two-dimensional tensor S has a shape of (1000, 100). The tensor S can be evenly split into four sub-tensors along the first dimension, and the shape of each sub-tensor is (250, 100).
[0064] Based on any of the above embodiments, Figure 2 It is a flowchart of another tensor segmentation method of the operator provided by the present invention, such as Figure 2 As shown, the method includes: Get the segmentation information of the Tcore operator in the Tcore fusion operator.
[0065] Traverse the subsequent fusible operators of the Tcore operator, and determine whether the segmentation information of the Tcore operator needs to be corrected based on the input tensor and output tensor of each fusible operator.
[0066] If yes, the segmentation information of the Tcore operator is modified by the method of the above embodiment, and the modified segmentation information is bound to the corresponding tensor of the fusible operator. If no, the segmentation information of the Tcore operator is bound to the corresponding tensor of the fusible operator by the method of the above embodiment.
[0067] The tensor slicing device of the operator provided by the present invention is described below. The tensor slicing device of the operator described below and the tensor slicing method of the operator described above can be referred to each other.
[0068] Based on any of the above embodiments, Figure 3 is a flow chart of the tensor segmentation device of the operator provided by the present invention, such as Figure 3 As shown, the device comprises: An information acquisition unit 310 is used to acquire the segmentation information of the first operator in the target operator; The first segmentation unit 320 is used to bind the segmentation information of the first operator to the corresponding tensor if there is no fusible operator after the first operator, so that the fusible operator can be fused with the first operator into one operator; The second segmentation unit 330 is used to modify the segmentation information of the first operator based on the input tensor and output tensor of the fusible operator if there is a fusible operator after the first operator, and bind the modified segmentation information to the corresponding tensor of the fusible operator.
[0069] Based on any of the above embodiments, based on the input tensor and the output tensor of the fusible operator, the segmentation information of the first operator is corrected, and the corrected segmentation information is bound to the corresponding tensor of the fusible operator, including: If the fusible operator includes 1 input tensor and 1 output tensor, the segmentation information of the output tensor corresponding to the first operator is bound to the input tensor and output tensor of the fusible operator; If the fusible operator includes two input tensors, the segmentation information of the first operator is modified based on the operation type performed by the first operator, and the modified segmentation information is bound to the corresponding tensor of the fusible operator; If a fusible operator includes at least 3 input tensors, the tensors of the fusible operator are not split.
[0070] Based on any of the above embodiments, based on the operation type performed by the first operator, the segmentation information of the first operator is modified, and the modified segmentation information is bound to the corresponding tensor of the fusible operator, including: Bind the split information of the output tensor corresponding to the first operator to an input tensor in the fusible operator and the output tensor of the fusible operator; Based on the operation type performed by the first operator, the split information of the input tensor corresponding to the first operator is modified, and the modified split information is bound to another input tensor in the fusible operator.
[0071] Based on any of the above embodiments, based on the operation type performed by the first operator, the segmentation information of the input tensor corresponding to the first operator is modified, and the modified segmentation information is bound to another input tensor in the fusible operator, including: If the operation type performed by the first operator is a matrix multiply-add operation, determine whether the batch axis on the input tensor corresponding to the first operator is split; If yes, the batch axis splitting information on the input tensor corresponding to the first operator is corrected to not be split, and the corrected splitting information is bound to another input tensor in the fusible operator; If not, the split information of the corresponding input tensor of the first operator is bound to another input tensor in the fusible operator.
[0072] Based on any of the above embodiments, based on the operation type performed by the first operator, the segmentation information of the input tensor corresponding to the first operator is modified, and the modified segmentation information is bound to another input tensor in the fusible operator, including: If the operation type performed by the first operator is not a matrix multiplication-addition operation, the split information of the input tensor corresponding to the first operator is bound to another input tensor in the fusible operator.
[0073] Based on any of the above embodiments, the segmentation information of the first operator is determined based on the tensor attribute of the first operator.
[0074] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the tensor segmentation method of the operator, the method comprising: obtaining the segmentation information of the first operator in the target operator; if there is no fusible operator after the first operator, the segmentation information of the first operator is bound to the corresponding tensor, and the fusible operator can be fused with the first operator into one operator; if there is a fusible operator after the first operator, the segmentation information of the first operator is corrected based on the input tensor and output tensor of the fusible operator, and the corrected segmentation information is bound to the corresponding tensor of the fusible operator.
[0075] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. 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.
[0076] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the tensor splitting method of the operators provided by the above methods, and the method includes: obtaining the splitting information of the first operator in the target operator; if there is no fusible operator after the first operator, binding the splitting information of the first operator to the corresponding tensor, and the fusible operator can be fused with the first operator into one operator; if there is a fusible operator after the first operator, based on the input tensor and output tensor of the fusible operator, correcting the splitting information of the first operator, and binding the corrected splitting information to the corresponding tensor of the fusible operator.
[0077] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the tensor splitting method of the operators provided by the above-mentioned methods, the method comprising: obtaining the splitting information of the first operator in the target operator; if there is no fusible operator after the first operator, binding the splitting information of the first operator to the corresponding tensor, and the fusible operator can be fused with the first operator into one operator; if there is a fusible operator after the first operator, correcting the splitting information of the first operator based on the input tensor and output tensor of the fusible operator, and binding the corrected splitting information to the corresponding tensor of the fusible operator.
[0078] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0079] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.
[0080] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A tensor segmentation method for an operator, characterized in that: include: Get the segmentation information of the first operator in the target operator; If there is no fusible operator after the first operator, the segmentation information of the first operator is bound to the corresponding tensor, and the fusible operator can be fused with the first operator into one operator; If there is a fusible operator after the first operator, the segmentation information of the first operator is modified based on the input tensor and output tensor of the fusible operator, and the modified segmentation information is bound to the corresponding tensor of the fusible operator.
2. The operator tensor segmentation method according to claim 1, characterized in that: The step of modifying the segmentation information of the first operator based on the input tensor and the output tensor of the fusible operator, and binding the modified segmentation information to the corresponding tensor of the fusible operator includes: If the fusible operator includes 1 input tensor and 1 output tensor, the segmentation information of the output tensor corresponding to the first operator is bound to the input tensor and the output tensor of the fusible operator; If the fusible operator includes two input tensors, based on the operation type performed by the first operator, the segmentation information of the first operator is modified, and the modified segmentation information is bound to the corresponding tensor of the fusible operator; If the fusible operator includes at least 3 input tensors, the tensors of the fusible operator are not split.
3. The operator tensor segmentation method according to claim 2, characterized in that: The step of modifying the segmentation information of the first operator based on the operation type performed by the first operator, and binding the modified segmentation information to the corresponding tensor of the fusible operator includes: Binding the segmentation information of the output tensor corresponding to the first operator to an input tensor in the fusible operator and the output tensor of the fusible operator; Based on the operation type performed by the first operator, the segmentation information of the input tensor corresponding to the first operator is modified, and the modified segmentation information is bound to another input tensor in the fusible operator.
4. The operator tensor segmentation method according to claim 3, characterized in that: The step of modifying the segmentation information of the input tensor corresponding to the first operator based on the operation type performed by the first operator, and binding the modified segmentation information to another input tensor in the fusible operator includes: If the operation type performed by the first operator is a matrix multiplication-addition operation, determining whether the batch axis on the input tensor corresponding to the first operator is split; If yes, the batch axis splitting information on the input tensor corresponding to the first operator is modified to not be split, and the modified splitting information is bound to another input tensor in the fusible operator; If not, the segmentation information of the input tensor corresponding to the first operator is bound to another input tensor in the fusible operator.
5. The operator tensor segmentation method according to claim 3, characterized in that: The step of modifying the segmentation information of the input tensor corresponding to the first operator based on the operation type performed by the first operator, and binding the modified segmentation information to another input tensor in the fusible operator includes: If the operation type performed by the first operator is not a matrix multiplication-addition operation, the segmentation information of the input tensor corresponding to the first operator is bound to another input tensor in the fusible operator.
6. The operator tensor segmentation method according to any one of claims 1 to 5, characterized in that: The segmentation information of the first operator is determined based on a tensor attribute of the first operator.
7. A tensor splitting device for an operator, characterized in that: include: An information acquisition unit, used to acquire the segmentation information of the first operator in the target operator; The first segmentation unit is used for binding the segmentation information of the first operator to corresponding tensors if there is no fusible operator after the first operator, so that the fusible operator can be fused with the first operator into one operator; The second segmentation unit is used to modify the segmentation information of the first operator based on the input tensor and output tensor of the fusible operator if there is a fusible operator after the first operator, and bind the modified segmentation information to the corresponding tensor of the fusible operator.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the tensor splitting method of the operator according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the tensor segmentation method of the operator according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the tensor segmentation method of the operator according to any one of claims 1 to 6 is implemented.
