Tensor segmentation method, electronic equipment, storage medium and computer program product

By automatically determining the tensor segmentation mode, the problem of insufficient utilization of computing cores and high manual configuration costs in tensor segmentation is solved, and efficient and generalized computing resource utilization is achieved, which is suitable for a variety of computing tasks.

CN118607609APending Publication Date: 2024-09-06SHANGHAI BIREN TECH CO LTD

Patent Information

Application Number
CN202410842460.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing tensor segmentation methods have problems such as insufficient utilization of computing cores and high manual configuration costs in high-performance computing and deep learning model training. In particular, single-axis segmentation cannot make full use of computing cores, while multi-axis segmentation requires Manually configure strategies and have poor generalization.

Method used

Multiple candidate segmentation modes are automatically determined based on the properties of the target tensor and the number of computing cores, and the optimal segmentation mode is selected through a scoring mechanism to ensure full utilization of computing cores, avoid manual configuration strategies, and improve generalization.

Benefits of technology

It realizes full utilization of computing cores in high-performance computing, reduces manual configuration costs, improves computing efficiency and generalization, avoids idle computing cores, and is suitable for tensor segmentation of different tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118607609A
    Figure CN118607609A
Patent Text Reader

Abstract

The invention provides a tensor segmentation method, electronic equipment, a storage medium and a computer program product, and the method comprises the steps: determining a plurality of candidate segmentation modes of a target tensor based on the attribute of the target tensor and a calculation kernel number; based on the score of each candidate segmentation mode, determining a target segmentation mode from each candidate segmentation mode; and based on the target segmentation mode, segmenting the target tensor. According to the tensor segmentation method, the electronic equipment, the storage medium and the computer program product provided by the invention, tensor segmentation can be carried out on the basis of fully utilizing all the calculation cores, the calculation cores are prevented from being idle, the tensor segmentation can be carried out on the target tensors corresponding to different tasks by adopting the tensor segmentation method, and the generalization is relatively high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of chip technology, and in particular to a tensor segmentation method, electronic equipment, storage medium and computer program product. Background Art

[0002] In modern high-performance computing and deep learning model training, data parallelism and model parallelism are common strategies for accelerating computing tasks. Existing parallel computing solutions mainly rely on tensor splitting, which has an important impact on performance optimization.

[0003] Current tensor splitting schemes can be divided into two categories: single-axis splitting and multi-axis splitting. Single-axis splitting refers to automatically selecting the axis to be split according to the dimension and shape size of the tensor (the axis here can be understood as the dimension to be split), and splitting along one axis of the tensor. However, since it can only be split along one axis, when the shape size is unbalanced or large, all computing cores cannot be fully utilized, resulting in some computing cores being idle. Multi-axis splitting refers to splitting along multiple axes at the same time, so as to allocate computing tasks more flexibly, but multi-axis splitting requires manual configuration of specific splitting strategies, which requires additional high labor costs and has poor generalization. Summary of the invention

[0004] The present invention provides a tensor segmentation method, electronic equipment, storage medium and computer program product to solve the defects existing in the related technology.

[0005] The present invention provides a tensor segmentation method, comprising the following steps.

[0006] Determine multiple candidate segmentation modes of the target tensor based on the properties of the target tensor and the number of computing cores; Based on the scores of the candidate segmentation modes, determine the target segmentation mode from the candidate segmentation modes; The target tensor is segmented based on the target segmentation mode.

[0007] According to a tensor splitting method provided by the present invention, the method of determining multiple candidate splitting modes of the target tensor based on the properties of the target tensor and the number of computing cores includes: Enumeration step: under the current number of computing cores, based on the properties of the target tensor, determining whether the target tensor has at least one splitting mode; If so, the at least one segmentation mode is used as the candidate segmentation mode; if not, the current number of computing cores is reduced and the enumeration step is returned to execute.

[0008] According to a tensor splitting method provided by the present invention, the first number of computing cores is the maximum number of available computing cores.

[0009] According to a tensor segmentation method provided by the present invention, the step of determining a target segmentation mode from each candidate segmentation mode based on the scores of each candidate segmentation mode includes: If there is only one highest score, the candidate segmentation mode corresponding to the highest score is used as the target segmentation mode; if there are multiple highest scores, the candidate segmentation mode with the largest number of segmentations of the batch processing axis among the highest scores is used as the target segmentation mode.

[0010] According to a tensor segmentation method provided by the present invention, the step of determining a target segmentation mode from each candidate segmentation mode further includes: If the number of computing cores corresponding to the target split mode is the maximum number of available computing cores, determine whether the target tensor is a weight tensor. If so, after enabling weight tensor broadcasting, bind the target split mode to the target tensor. If the number of computing cores corresponding to the target split mode is not the maximum number of available computing cores, weight tensor broadcasting is not enabled, and the target split mode is bound to the target tensor.

[0011] According to a tensor splitting method provided by the present invention, the method of determining multiple candidate splitting modes of the target tensor based on the properties of the target tensor and the number of computing cores includes: Based on the properties of the target tensor, the minimum segmentation granularity of each axis in the target tensor, and the number of computing cores, multiple candidate segmentation modes of the target tensor are determined.

[0012] According to a tensor segmentation method provided by the present invention, the score of each candidate segmentation mode is determined based on the shape and size of each candidate segmentation tensor, and each candidate segmentation tensor refers to a tensor after the target tensor is segmented based on each candidate segmentation mode.

[0013] The present invention also provides a tensor segmentation device, comprising the following modules.

[0014] A determination unit, configured to determine a plurality of candidate segmentation modes of the target tensor based on the properties of the target tensor and the number of computing cores; A scoring unit, configured to determine a target segmentation mode from among the candidate segmentation modes based on the scores of the candidate segmentation modes; A segmentation unit is used to segment the target tensor based on the target segmentation mode.

[0015] 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, any of the tensor splitting methods described above is implemented.

[0016] 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 any of the tensor splitting methods described above.

[0017] 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 described above is implemented.

[0018] The tensor segmentation method, electronic device, storage medium and computer program product provided by the present invention take into account the number of computing cores when determining the candidate segmentation mode, thereby achieving the determination of the candidate segmentation mode on the basis of fully utilizing all computing cores, and determining the optimal target segmentation mode from each candidate segmentation mode, maximizing the utilization of computing cores and avoiding idle computing cores. In addition, the present invention automatically determines the candidate segmentation mode based on the properties of different target tensors and the number of computing cores, without the need to manually configure the segmentation strategy, thereby reducing labor costs, and the target tensors corresponding to different tasks in the present invention can all use this method for tensor segmentation, with strong generalization. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] 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.

[0020] Figure 1 It is a flow chart of the tensor segmentation method provided by the present invention.

[0021] Figure 2 It is a flow chart of another tensor segmentation method provided by the present invention.

[0022] Figure 3 It is a structural schematic diagram of the tensor segmentation device provided by the present invention.

[0023] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0024] 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.

[0025] Single-axis slicing only allows slicing along one axis of the tensor. The advantage of this method is that it is relatively simple to implement and can automatically select the axis to be sliced ​​according to the specific shape size. However, since it can only be sliced ​​along one axis, when the shape size is uneven or large, all computing cores cannot be fully utilized, resulting in some computing cores being idle and failing to maximize the use of computing resources.

[0026] Multi-axis segmentation allows segmentation along multiple axes simultaneously, thus allocating computing tasks more flexibly. Although this method can better balance the computing load and improve the utilization of computing cores, multi-axis segmentation requires manual configuration of specific segmentation strategies, which places high demands on users. Not only do they need to understand the specific shape and size, but they also need to design a reasonable segmentation plan. This manual configuration process is time-consuming, laborious, and prone to errors. In addition, since the segmentation strategy needs to be reconfigured according to the specific shape and size each time, the generalization is poor and it is difficult to be used across different tasks.

[0027] Figure 1 It is a flow chart of the tensor segmentation method provided by the present invention, such as Figure 1 As shown, the method includes step 110 , step 120 and step 130 .

[0028] Step 110: Based on the properties of the target tensor and the number of computing cores, determine multiple candidate segmentation modes for the target tensor.

[0029] Here, the target tensor refers to the tensor to be split. The target tensor is usually bound to the target operator. The relationship between the target tensor and the target operator can be understood as the target operator is a function or mapping that operates on the target tensor. Among them, the target operator can be a Tensor Core operator (Tcore operator). The main operations performed by the Tcore operator on the target tensor include matrix multiplication, mixed precision calculation, and dynamic adjustment of computing power.

[0030] In addition, the properties of the target tensor can include the dimension and shape size of the target tensor. The dimension refers to the number of independent directions of the target tensor. For example, a scalar (zero-dimensional tensor) has a dimension of 0, a vector (one-dimensional tensor) has a dimension of 1, and a matrix (two-dimensional tensor) has a dimension of 2. The shape size is the number of elements in each dimension, which can be understood as the shape of the target tensor. For example, a tensor with a shape of (5) represents a one-dimensional vector containing 5 elements, a tensor with a shape of (3,4) represents a matrix with 3 rows and 4 columns, and a tensor with a shape of (2,3,4) represents 2 layers, each layer is a matrix with 3 rows and 4 columns.

[0031] A computing core usually refers to the physical core of an AI chip, that is, an independent computing unit inside an AI chip. Each computing core can independently execute the computing tasks corresponding to the operation of the operator on the tensor to achieve parallel computing. Correspondingly, the number of computing cores refers to the number of independent computing units inside the CPU, that is, the number of computing cores can be understood as the number of computing tasks processed in parallel. Among them, AI chips can include graphics processing units (GPU), general-purpose graphics processing units (GPGPU), tensor processing units (TPU), etc.

[0032] The candidate splitting mode can be understood as the splitting strategy of the target tensor into multiple sub-tensors. Based on the properties of the target tensor and the number of computing cores, there may be multiple splitting strategies, that is, corresponding to multiple candidate splitting modes.

[0033] Optionally, the corresponding splitting strategy can be determined according to the dimension of the target tensor and the number of computing cores. For example, a three-dimensional tensor T has a shape of (100, 100, 100) and has 2 computing cores. It can be split according to the following dimensions: ① Split by the first dimension: split the tensor T into two sub-tensors, each with a shape of (50, 100, 100). ② Split by the second dimension: split the tensor T into two sub-tensors, each with a shape of (100, 50, 100). ③ Split by the third dimension: split the tensor T into two sub-tensors, each with a shape of (100, 100, 50).

[0034] Optionally, the corresponding splitting strategy can be determined according to the shape and size of the target tensor and the number of computing cores. For example, a two-dimensional tensor S has a shape of (1000, 100) and has 4 computing cores. It can be split according to the following shapes: ① Uniform splitting: The tensor S is evenly split into four sub-tensors, each of which has a shape of (250, 100). ② Non-uniform splitting: A two-dimensional tensor A has a shape of (10000, 100) and has 4 computing cores, two of which have higher performance than the other two. In order to fully utilize the computing power of high-performance computing cores, tensor A can be split into 4 sub-tensors, two of which have high-performance computing cores each process 3750 rows (i.e., the corresponding sub-tensor shape is (3750, 100)), and the other two low-performance computing cores each process 1250 rows (i.e., the corresponding sub-tensor shape is (1250, 100)).

[0035] Step 120: Determine a target segmentation pattern from among the candidate segmentation patterns based on the scores of the candidate segmentation patterns.

[0036] Specifically, taking into account the different efficiencies, performances, and costs corresponding to various candidate splitting modes in parallel computing, an embodiment of the present invention determines the optimal splitting mode (i.e., the target splitting mode) from among the candidate modes based on the scores of each candidate splitting mode, so as to ensure that the target splitting mode achieves high efficiency, high performance, and low cost in parallel computing.

[0037] The score of each candidate segmentation mode is used to characterize the performance of each candidate segmentation mode in different aspects (such as computing efficiency, communication cost, load balancing, implementation complexity, etc.). Optionally, the score of each candidate segmentation mode can be determined according to different evaluation criteria (such as computing efficiency evaluation criteria, communication cost evaluation criteria, load balancing evaluation criteria, implementation complexity evaluation criteria, etc.), and the candidate segmentation mode with the highest score is used as the target segmentation mode.

[0038] Step 130: Split the target tensor based on the target segmentation mode.

[0039] Specifically, after determining the target segmentation mode, the target tensor is segmented into multiple sub-tensors according to the target segmentation mode. Optionally, after segmenting the target tensor, the sub-tensors obtained after segmentation are assigned to corresponding computing cores for parallel computing to improve computing speed and efficiency. After each computing core completes the corresponding computing task, the results obtained by each computing core can be merged to form the final computing result.

[0040] The tensor splitting method provided in the embodiment of the present invention takes into account the number of computing cores when determining the candidate splitting mode, thereby achieving the determination of the candidate splitting mode on the basis of fully utilizing all computing cores, and determining the optimal target splitting mode from each candidate splitting mode, maximizing the utilization of computing cores and avoiding idle computing cores. In addition, the embodiment of the present invention automatically determines the candidate splitting mode based on the properties of different target tensors and the number of computing cores, without the need to manually configure the splitting strategy, thereby reducing labor costs, and the target tensors corresponding to different tasks in the embodiment of the present invention can all use this method for tensor splitting, which has strong generalization.

[0041] As an optional embodiment, the target tensor can be a tensor in a neural network model. After the tensor is split using the method of the above embodiment, the sub-tensors obtained after the split are assigned to corresponding computing cores for parallel computing. The obtained calculation results can be applied to model reasoning to obtain model reasoning results.

[0042] 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 target tensor can be determined based on the input text. After the tensor is segmented using the above embodiment method, the sub-tensors obtained after the segmentation are assigned to the corresponding computing cores for parallel computing. 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.

[0043] Based on the above embodiment, multiple candidate splitting modes of the target tensor are determined based on the properties of the target tensor and the number of computing cores, including: Enumeration step: Under the current number of computing cores, based on the properties of the target tensor, determine whether the target tensor has at least one split mode; If so, at least one segmentation mode is used as a candidate segmentation mode; if not, the current number of computing cores is reduced and the enumeration step is returned to be executed.

[0044] Specifically, the current number of computing cores refers to the number of computing cores currently available when the target tensor is split, which can be equal to the maximum number of available computing cores or less than the maximum number of available computing cores. When it is equal to the maximum number of available computing cores, it can maximize the use of computing cores and avoid idle computing cores. The split mode refers to the splitting strategy of splitting the target tensor into multiple sub-tensors under the current number of computing cores.

[0045] Under the current number of computing cores, according to the properties of the target tensor (such as dimension, shape size, etc.), enumerate whether there is at least one splitting mode. If so, it indicates that under the current number of computing cores, there is at least one splitting strategy to effectively split the target tensor into multiple small pieces to maximize the use of the current computing cores, so at least one splitting mode is used as a candidate splitting mode. If not, it indicates that under the current number of computing cores, there is no splitting strategy to effectively split the target tensor into multiple small pieces. At this time, it is necessary to adjust the current number of computing cores, that is, reduce the current number of computing cores, such as reducing the current number of computing cores by 1, and return to execute the enumeration step until a candidate splitting mode is found or the current number of computing cores reaches the minimum value (such as the current number of computing cores is 1). It should be noted that in order to maximize the use of computing cores, the maximum number of computing cores is usually used as the current number of computing cores. If there is no splitting mode under the maximum number of computing cores, the current number of computing cores is reduced.

[0046] The embodiment of the present invention continuously adjusts the current number of computing cores and enumerates different segmentation modes based on the current number of computing cores to achieve parallel computing on the basis of maximizing the utilization of computing cores, thereby improving computing efficiency and maximizing the utilization of computing cores.

[0047] Among them, when looking for the optimal splitting mode, in order to maximize the utilization of computing cores, the first number of computing cores in the embodiment of the present invention is the maximum number of available computing cores. If there is no splitting mode under the maximum number of available computing cores, the number of computing cores is reduced based on the maximum number of available computing cores, and the optimal splitting mode is continued to be found based on the reduced number of computing cores.

[0048] Based on any of the above embodiments, determining a target segmentation mode from each candidate segmentation mode based on the scores of each candidate segmentation mode includes: If there is only one highest score, the candidate segmentation mode corresponding to the highest score is used as the target segmentation mode; If there are multiple highest scores, the candidate split mode with the largest number of splits on the batch axis among the highest scores is used as the target split mode.

[0049] Specifically, there is only one highest score, which can be understood as that among all candidate segmentation patterns, only one candidate segmentation pattern has a score higher than the scores of all other patterns, which means that the candidate segmentation pattern with the highest score is the optimal segmentation pattern, and the candidate segmentation pattern with the highest score can be used as the target segmentation pattern.

[0050] The existence of multiple highest scores can be understood as the existence of multiple candidate splitting modes that have obtained the same highest score, and it is necessary to further consider other factors to determine the final target splitting mode from the candidate splitting modes with the highest scores. Considering that a larger number of splits on the batch processing axis can bring higher parallelism and computing efficiency, when there are multiple candidate splitting modes that have obtained the highest score, the candidate splitting mode with the largest number of splits on the batch processing axis is selected as the target splitting mode.

[0051] The batch axis usually refers to the first axis in the target tensor. For example, if the shape of the target tensor is (32, 224, 224, 3), "32" represents the batch axis.

[0052] It can be seen that the embodiment of the present invention combines the scores of each candidate segmentation mode and the decision-making mechanism considering a specific segmentation dimension (batch processing axis) to find the segmentation mode that best suits the current computing task from multiple candidate segmentation modes.

[0053] Based on any of the above embodiments, a target segmentation mode is determined from each candidate segmentation mode, and then the method further includes: If the number of computing cores corresponding to the target split mode is the maximum number of available computing cores, determine whether the target tensor is a weight tensor. If so, enable weight tensor broadcasting and bind the target split mode to the target tensor. If the number of computing cores corresponding to the target split mode is not the maximum number of available computing cores, weight tensor broadcasting is not enabled, and the target split mode is bound to the target tensor.

[0054] Specifically, if the number of computing cores corresponding to the target split mode is the maximum number of available computing cores, it means that all computing cores are involved in parallel computing. During the parallel computing process, all computing cores may need to frequently exchange data, and this frequent data exchange has high requirements for network bandwidth. Without using weight tensor broadcast, each computing core needs to store a complete set of weight vector copies and access and read the weight vector for calculation. Under the premise that all computing cores are involved in parallel computing, network bandwidth may become a performance bottleneck.

[0055] If the target tensor is a weight tensor, when weight tensor broadcasting is turned on, all computing cores can share the weight vector from the weight tensor broadcasting, without the need for each computing core to read a copy of the weight vector separately, reducing the amount of data transmission and the demand for network bandwidth.

[0056] If the number of computing cores corresponding to the target split mode is not the maximum number of available computing cores, it means that not all computing cores participate in parallel computing. In this case, since all computing cores will receive the weight vectors in the broadcast when the weight tensor is broadcast, including the computing cores that do not participate in parallel computing, these computing cores that do not participate in parallel computing not only occupy network bandwidth, but also occupy memory resources. Therefore, in this case, weight tensor broadcasting is not enabled to avoid occupying network bandwidth and causing unnecessary waste of resources.

[0057] In addition, binding the target splitting mode to the target tensor can be understood as applying the target splitting mode to the target tensor.

[0058] Based on any of the above embodiments, based on the properties of the target tensor and the number of computing cores, multiple candidate splitting modes of the target tensor are determined, including: Based on the properties of the target tensor, the minimum segmentation granularity of each axis in the target tensor, and the number of computing cores, multiple candidate segmentation modes of the target tensor are determined.

[0059] Specifically, if the segmentation granularity of any axis on the target tensor is too small, too many small tensors may be generated, which will not only increase the complexity of parallel processing, but also reduce the computational efficiency. Therefore, it is necessary to set a reasonable minimum segmentation granularity for each axis on the target tensor. Among them, the minimum segmentation granularity of each axis in the target tensor can be understood as the minimum segmentation size on each axis in the target tensor. In this regard, when determining the candidate segmentation mode, the embodiment of the present invention not only considers the properties of the target tensor and the number of computing cores, but also considers the minimum segmentation granularity of each axis in the target tensor.

[0060] For example, the shape size of the target tensor is (2,64,32,32), where "2" (the first axis) represents the batch axis, "64" (the second axis) represents the channel axis, "32" (the third axis) represents the row axis, and "32" (the fourth axis) represents the column axis. If the minimum splitting granularity of the batch axis is 1, it means that the batch axis can be split into 2 / 1=2 parts at most; if the minimum splitting granularity of the channel axis is 64, it means that the channel axis can be split into 64 / 64=1 part at most; if the minimum splitting granularity of the row axis is 8, it means that the row axis can be split into 32 / 8=4 parts at most; if the minimum splitting granularity of the column axis is 8, it means that the column axis can be split into 32 / 8=4 parts at most.

[0061] Based on any of the above embodiments, the score of each candidate segmentation mode is determined based on the shape and size of each candidate segmentation tensor, and each candidate segmentation tensor refers to a tensor after the target tensor is segmented based on each candidate segmentation mode.

[0062] Specifically, the score of each candidate segmentation mode is used to characterize the performance of each candidate segmentation mode in different aspects (such as computing efficiency, communication cost, load balancing, implementation complexity, etc.). The higher the score, the better the performance of the corresponding candidate segmentation mode in various aspects, and the greater the probability that the corresponding candidate segmentation mode is the optimal segmentation mode.

[0063] The score of each candidate splitting mode can be determined based on the shape and size of each candidate splitting tensor. For example, the Tcore operator corresponds to two input tensors, namely input tensor 1 and input tensor 2. The shape and size of input tensor 1 are (2, 64, 64, 64), and the shape and size of input tensor 2 are (512, 64, 1, 1). The candidate splitting mode corresponding to input tensor 1 is: split the batch axis (the first axis) into 2 parts, and split the row axis (the third axis) into 8 parts. After splitting according to this candidate splitting mode, the shape and size of the candidate splitting tensor corresponding to input tensor 1 is (1, 64, 8, 64). The candidate splitting mode corresponding to input tensor 2 is: split the channel axis (the second axis) into 8 parts. After splitting according to this candidate splitting mode, the shape and size of the candidate splitting tensor corresponding to input tensor 2 is (512, 8, 1, 1). On this basis, the score of the candidate segmentation pattern is │1×64×8×64-512×8×1×1│=28672. The lower the score of the candidate segmentation pattern, the better the corresponding candidate segmentation pattern.

[0064] Based on any of the above embodiments, Figure 2 is a flow chart of another tensor segmentation method provided by the present invention, such as Figure 2 As shown, the method includes: Get the properties of the target tensor and enumerate all the splitting modes of the target tensor based on the properties of the target tensor under the current number of computing cores.

[0065] Determine whether there is a split mode under the current number of computing cores. If so, use the split mode as a candidate split mode; if not, reduce the current number of computing cores by 1 and return to execute "enumerate all split modes of the target tensor based on the properties of the target tensor under the current number of computing cores" until a split mode exists under the current number of computing cores. Among them, the first current number of computing cores is the maximum number of available computing cores.

[0066] Next, the score of each candidate split mode is determined based on the shape and size of each candidate split tensor. If there is only one highest score, the candidate split mode corresponding to the highest score is used as the target split mode; if there are multiple highest scores, the candidate split mode with the largest number of batch axis splits among the highest scores is used as the target split mode. Among them, each candidate split tensor refers to the tensor after the target tensor is split based on each candidate split mode.

[0067] After determining the target split mode, if the number of computing cores corresponding to the target split mode is the maximum number of available computing cores, determine whether the target tensor is a weight tensor. If so, enable weight tensor broadcasting and bind the target split mode to the target tensor. If the number of computing cores corresponding to the target split mode is not the maximum number of available computing cores, do not enable weight tensor broadcasting and bind the target split mode to the target tensor.

[0068] The tensor slicing device provided by the present invention is described below. The tensor slicing device described below and the tensor slicing method described above can be referenced to each other.

[0069] Based on any of the above embodiments, Figure 3 is a schematic diagram of the structure of the tensor segmentation device provided by the present invention, such as Figure 3 As shown, the device comprises: The determination unit 310 is used to determine multiple candidate segmentation modes of the target tensor based on the properties of the target tensor and the number of computing cores; the scoring unit 320 is used to determine the target segmentation mode from each candidate segmentation mode based on the score of each candidate segmentation mode; the segmentation unit 330 is used to segment the target tensor based on the target segmentation mode.

[0070] Based on any of the above embodiments, based on the properties of the target tensor and the number of computing cores, multiple candidate splitting modes of the target tensor are determined, including: Enumeration step: Under the current number of computing cores, based on the properties of the target tensor, determine whether the target tensor has at least one split mode; If so, at least one segmentation mode is used as a candidate segmentation mode; if not, the current number of computing cores is reduced and the enumeration step is returned to be executed.

[0071] Based on any of the above embodiments, the first number of computing cores is the maximum number of available computing cores.

[0072] Based on any of the above embodiments, determining a target segmentation mode from each candidate segmentation mode based on the scores of each candidate segmentation mode includes: If there is only one highest score, the candidate segmentation mode corresponding to the highest score is used as the target segmentation mode; If there are multiple highest scores, the candidate split mode with the largest number of splits on the batch axis among the highest scores is used as the target split mode.

[0073] Based on any of the above embodiments, a target segmentation mode is determined from each candidate segmentation mode, and then the method further includes: If the number of computing cores corresponding to the target split mode is the maximum number of available computing cores, determine whether the target tensor is a weight tensor. If so, enable weight tensor broadcasting and bind the target split mode to the target tensor. If the number of computing cores corresponding to the target split mode is not the maximum number of available computing cores, weight tensor broadcasting is not enabled, and the target split mode is bound to the target tensor.

[0074] Based on any of the above embodiments, based on the properties of the target tensor and the number of computing cores, multiple candidate splitting modes of the target tensor are determined, including: Based on the properties of the target tensor, the minimum segmentation granularity of each axis in the target tensor, and the number of computing cores, multiple candidate segmentation modes of the target tensor are determined.

[0075] Based on any of the above embodiments, the score of each candidate segmentation mode is determined based on the shape and size of each candidate segmentation tensor, and each candidate segmentation tensor refers to a tensor after the target tensor is segmented based on each candidate segmentation mode.

[0076] 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, which includes: determining multiple candidate segmentation modes of the target tensor based on the properties of the target tensor and the number of computing cores; determining a target segmentation mode from each candidate segmentation mode based on the score of each candidate segmentation mode; and segmenting the target tensor based on the target segmentation mode.

[0077] 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 such an 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 for 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.

[0078] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program 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 provided by the above methods, which method includes: determining multiple candidate splitting modes of the target tensor based on the properties of the target tensor and the number of computing cores; determining a target splitting mode from each candidate splitting mode based on the score of each candidate splitting mode; and splitting the target tensor based on the target splitting mode.

[0079] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the tensor splitting method provided by the above-mentioned methods. The method includes: determining multiple candidate splitting modes of the target tensor based on the properties of the target tensor and the number of computing cores; determining a target splitting mode from each candidate splitting mode based on the score of each candidate splitting mode; and splitting the target tensor based on the target splitting mode.

[0080] 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.

[0081] 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, by hardware. Based on this understanding, the above technical solution can be essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which 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.

[0082] 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, characterized in that: include: Determine multiple candidate segmentation modes of the target tensor based on the properties of the target tensor and the number of computing cores; Based on the scores of the candidate segmentation modes, determine the target segmentation mode from the candidate segmentation modes; The target tensor is segmented based on the target segmentation mode.

2. The tensor segmentation method according to claim 1, characterized in that: The determining of a plurality of candidate splitting modes of the target tensor based on the properties of the target tensor and the number of computing cores includes: Enumeration step: under the current number of computing cores, based on the properties of the target tensor, determining whether the target tensor has at least one splitting mode; If so, the at least one segmentation mode is used as the candidate segmentation mode; if not, the current number of computing cores is reduced and the enumeration step is returned to execute.

3. The tensor segmentation method according to claim 2, characterized in that: The first number of computing cores is the maximum number of available computing cores.

4. The tensor segmentation method according to any one of claims 1 to 3, characterized in that: The step of determining a target segmentation mode from each candidate segmentation mode based on the scores of each candidate segmentation mode includes: If there is only one highest score, the candidate segmentation mode corresponding to the highest score is used as the target segmentation mode; if there are multiple highest scores, the candidate segmentation mode with the largest number of segmentations of the batch processing axis among the highest scores is used as the target segmentation mode.

5. The tensor segmentation method according to any one of claims 1 to 3, characterized in that: The step of determining a target segmentation mode from each candidate segmentation mode further includes: If the number of computing cores corresponding to the target split mode is the maximum number of available computing cores, determine whether the target tensor is a weight tensor. If so, after enabling weight tensor broadcasting, bind the target split mode to the target tensor. If the number of computing cores corresponding to the target split mode is not the maximum number of available computing cores, weight tensor broadcasting is not enabled, and the target split mode is bound to the target tensor.

6. The tensor segmentation method according to any one of claims 1 to 3, characterized in that: The determining of a plurality of candidate splitting modes of the target tensor based on the properties of the target tensor and the number of computing cores includes: Based on the properties of the target tensor, the minimum segmentation granularity of each axis in the target tensor, and the number of computing cores, multiple candidate segmentation modes of the target tensor are determined.

7. The tensor segmentation method according to any one of claims 1 to 3, characterized in that: The score of each candidate segmentation mode is determined based on the shape and size of each candidate segmentation tensor, and each candidate segmentation tensor refers to a tensor after the target tensor is segmented based on each candidate segmentation mode.

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 according to any one of claims 1 to 7 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 according to any one of claims 1 to 7 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 according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Neural network computing-oriented distributed data routing modeling method and device

    CN114598631A

  • Automatic operator fusion method and device

    CN117076129A

  • Tensor dimension segmentation method, system, equipment and medium

    CN117634711A

Cited By

  • Tensor slice implementation method on TPU (thermoplastic polyurethane) and TPU

    CN122332132A

  • Tensor slicing implementation method on tpu and tpu

    CN122332132B