Correctness testing methods for vectorization processing, electronic devices and storage media

By automatically enumerating the parameter combinations of test condition terms, generating input tensors and comparing vectorized processing with sequential loop processing, the problem of inaccurate determination of the correctness of element-wise operator vectorized processing is solved, achieving more accurate vectorized processing verification and ensuring the computational accuracy of deep learning models.

CN122309361APending Publication Date: 2026-06-30ZHONGKE SHUGUANG (NANJING) COMPUTING TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHONGKE SHUGUANG (NANJING) COMPUTING TECH CO LTD
Filing Date
2026-03-12
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

In the existing technology, the vectorization of element-wise operators is difficult to fully cover input tensors under different test conditions, resulting in inaccurate determination of the correctness of vectorization and failure to detect boundary errors and numerical instability.

Method used

By automatically enumerating various parameter combinations of test condition terms related to the type of operator to be tested, the input tensor is automatically generated and then processed by vectorization and sequential looping. The output differences between the two processing methods are compared to systematically verify the correctness of the vectorization processing.

Benefits of technology

It enables efficient and automatic detection of boundary errors and numerical instability, ensuring the accuracy of vectorization processing and providing a reliable guarantee for the computational accuracy of deep learning models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122309361A_ABST
    Figure CN122309361A_ABST
Patent Text Reader

Abstract

This application provides a method, electronic device, and storage medium for testing the correctness of vectorization processing. The method includes: automatically enumerating multiple parameter combinations of test condition items (such as data type, broadcast rules, transpose state, etc.) related to the type of the operator to be tested; automatically generating a corresponding input tensor for each parameter combination; and performing vectorization processing and sequential loop processing respectively. By comparing the differences in the outputs of the two processing methods, the correctness of vectorization processing under all parameter combinations can be systematically verified. This overcomes the limitation of manually writing test cases that cannot fully cover multi-dimensional test conditions, and can efficiently and automatically discover boundary errors and numerical instability problems caused by different parameter combinations, thereby more accurately and reliably determining the correctness of vectorization processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method for testing the correctness of vectorization processing, an electronic device, and a storage medium. Background Technology

[0002] In deep learning models, vectorization of element-wise operators is a key technique for improving computational efficiency. However, the correctness of vectorization of element-wise operators affects the numerical accuracy of the model's results. Therefore, it is necessary to determine the correctness of vectorization of element-wise operators to ensure the numerical accuracy of the model's results.

[0003] In related technologies, developers rely on writing test cases for vectorized processing and test cases for sequential loop processing for each element-wise operator. The numerical precision of the results of the two test cases in the forward processing is compared to determine the correctness of the vectorized processing of each element-wise operator.

[0004] However, the input tensors that the element-wise operators need to process are complex and varied. Manually writing test cases makes it difficult to fully cover the testing of input tensors under different test conditions. That is, it can only cover scenarios with one combination of parameters for multiple test conditions (such as the dimension of the input tensor, the data type of the input tensor, and whether the input tensor is transposed before the operator is calculated), and cannot cover scenarios with multiple combinations of parameters at the same time. This makes it difficult to find boundary errors and numerical instability caused by other parameter combinations, resulting in inaccurate determination of the correctness of the vectorized implementation. Summary of the Invention

[0005] This application provides a method, electronic device, and storage medium for testing the correctness of vectorization processing, in order to improve the accuracy of determining the correctness of vectorization implementation.

[0006] Firstly, this application provides a method for testing the correctness of vectorization processing, including:

[0007] Obtain the operator to be tested from the preset list of element-wise operators;

[0008] Based on the type of the operator to be tested, multiple parameter combinations of the test condition terms are determined, and the test condition terms are associated with the type of the operator to be tested;

[0009] Based on the combination of parameters, determine the input tensor corresponding to each parameter combination;

[0010] For any combination of parameters, the input tensor is vectorized based on the operator to be tested to obtain the first output tensor of the operator to be tested, and the input tensor is sequentially looped based on the operator to be tested to obtain the second output tensor of the operator to be tested.

[0011] Based on the first and second output tensors corresponding to each parameter combination, the target correctness of the vectorization processing of the operator to be tested under each parameter combination is determined.

[0012] In this scheme, multiple parameter combinations of test condition items (such as data type, broadcast rules, transpose state, etc.) related to the type of operator to be tested are automatically enumerated. For each parameter combination, a corresponding input tensor is automatically generated and vectorized and sequentially looped. By comparing the differences in the outputs of the two processing methods, the correctness of vectorization processing under all parameter combinations can be systematically verified. This overcomes the limitation of manually writing test cases that cannot fully cover multi-dimensional test conditions. It can efficiently and automatically discover boundary errors and numerical instability caused by different parameter combinations, thereby more accurately and reliably determining the correctness of vectorization processing and providing a strong guarantee for the computational accuracy of deep learning models.

[0013] In some embodiments, when the type of the operator to be tested is a unary element-wise operator, the test condition includes the data type of the input tensor and a transpose flag, wherein the transpose flag indicates whether the input tensor is transposed.

[0014] When the type of the operator to be tested is a binary element-wise operator, the test condition includes the data type of the input tensor, the broadcast rules of the two sub-tensors in the input tensor, and the transpose flag of each sub-tensor in the input tensor. The broadcast rules are used to trigger the tensor broadcasting mechanism of the operator to be tested.

[0015] In some embodiments, for any combination of parameters, based on the first and second output tensors corresponding to each parameter combination, the target correctness of the vectorization processing of the operator under test under each parameter combination is determined, including:

[0016] Based on the first and second output tensors corresponding to the parameter combinations, the first correctness of the vectorization processing of the operator under the parameter combinations in the forward processing is determined;

[0017] Based on the first and second output tensors corresponding to the parameter combinations, the second correctness of the vectorization processing of the operator under the parameter combinations in gradient calculation is determined.

[0018] When the first correctness is normal and the second correctness is normal, the target correctness is determined to be normal.

[0019] When the first correctness is abnormal and / or the second correctness is abnormal, the target correctness is determined to be abnormal.

[0020] This scheme not only verifies the correctness of vectorization in forward computation but also in backpropagation gradient computation. It can comprehensively evaluate the numerical accuracy of vectorization and ensure that vectorization optimization will not introduce errors in the key step of model training—gradient computation. This provides a double guarantee for the stability and convergence reliability of deep learning models during the training phase.

[0021] In some embodiments, based on the first and second output tensors corresponding to the parameter combinations, determining the first correctness of the vectorization processing of the operator under the parameter combination in the forward processing includes:

[0022] Determine the first error between the first output tensor and the second output tensor;

[0023] When the first error is less than the preset output error threshold, the first correctness is determined to be normal;

[0024] When the first error is greater than or equal to the output error threshold, the first correctness is determined to be abnormal.

[0025] In this scheme, by comparing the results of vectorized processing with the results of sequential cyclic processing of the benchmark with precise numerical errors, and making a judgment based on a preset output error threshold that is adaptable to different data types, an objective, quantifiable and easy-to-implement judgment standard is provided for the correctness of forward processing, ensuring the accuracy of determining the correctness of forward processing.

[0026] In some embodiments, based on the first and second output tensors corresponding to the parameter combinations, determining the second correctness of the vectorization processing of the operator under the parameter combination in gradient calculation includes:

[0027] Perform backpropagation on the first output tensor to obtain the first gradient tensor under vectorization;

[0028] Perform backpropagation on the second output tensor to obtain the second gradient tensor under sequential loop processing;

[0029] The second correctness is determined based on the first gradient tensor and the second gradient tensor.

[0030] In this scheme, the gradient result of sequential loop processing is used as a benchmark and compared with the gradient result of vectorized processing. This allows the verification of the correctness of gradient calculation to directly reuse the forward comparison process and relies on a recognized and reliable reference system. This provides a simple and effective method for evaluating whether vectorized processing has violated the gradient propagation logic of the operator.

[0031] In some embodiments, determining the second correctness based on the first gradient tensor and the second gradient tensor includes:

[0032] Determine the second error between the first gradient tensor and the second gradient tensor;

[0033] When the second error is greater than or equal to the preset gradient error threshold, the second correctness is determined to be abnormal;

[0034] When the second error is less than the gradient error threshold, the second correctness is determined to be normal.

[0035] In this scheme, by comparing the numerical error between the vectorized gradient and the baseline gradient, and providing a clear gradient error threshold determination mechanism, the deviation introduced by vectorization in gradient calculation can be clearly and automatically identified, thereby effectively discovering potential problems that may lead to unstable model training and ensuring the numerical reliability of gradient propagation.

[0036] In some embodiments, determining the second correctness based on the first gradient tensor and the second gradient tensor includes:

[0037] Based on numerical differentiation, the gradient truth tensor of the input tensor of the operator to be tested is determined.

[0038] Determine the first gradient error between the first gradient tensor and the gradient truth tensor, and determine the second gradient error between the second gradient tensor and the gradient truth tensor;

[0039] If the first gradient error is less than the preset gradient error threshold when the second gradient error is less than the gradient error threshold, then the second correctness is determined to be normal; if the first gradient error is greater than or equal to the gradient error threshold, then the second correctness is determined to be abnormal.

[0040] When the second gradient error is greater than or equal to the gradient error threshold, a test failure alarm text is generated, indicating that the correctness of the gradient calculation in the sequential loop processing is abnormal.

[0041] In this scheme, the gradient truth tensor based on numerical differentiation is introduced as an objective reference in the verification of gradient correctness. By comparing the vectorized first gradient tensor with the gradient truth tensor, and also comparing the second gradient tensor, which is used as the benchmark and processed sequentially, with the gradient truth tensor, the credibility of the benchmark itself and the correctness of the vectorized gradient calculation can be cross-verified. This dual verification mechanism not only enhances the reliability of gradient correctness determination and avoids misjudgment caused by potential errors in the benchmark implementation, but also accurately locates the problem through clear test failure alarm text when the benchmark verification fails, effectively improving the robustness of the entire gradient correctness testing process.

[0042] Secondly, this application provides a correctness testing device for vectorization processing, comprising:

[0043] The first processing module is used to obtain the operator to be tested from a preset list of element-wise operators;

[0044] The second processing module is used to determine multiple parameter combinations of test condition items based on the type of the operator to be tested. The test condition items are associated with the type of the operator to be tested.

[0045] The third processing module is used to determine the input tensor corresponding to each parameter combination based on the parameter combinations.

[0046] The fourth processing module is used to vectorize the input tensor based on the operator to be tested for any combination of parameters, to obtain the first output tensor of the operator to be tested, and to perform sequential loop processing on the input tensor based on the operator to be tested, to obtain the second output tensor of the operator to be tested.

[0047] The fifth processing module is used to determine the target correctness of the vectorization processing of the operator to be tested under each parameter combination based on the first and second output tensors corresponding to each parameter combination.

[0048] The correctness testing device for vectorization processing provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be repeated here.

[0049] In some embodiments, when the type of the operator to be tested is a unary element-wise operator, the test condition includes the data type of the input tensor and a transpose flag, wherein the transpose flag indicates whether the input tensor is transposed.

[0050] When the type of the operator to be tested is a binary element-wise operator, the test condition includes the data type of the input tensor, the broadcast rules of the two sub-tensors in the input tensor, and the transpose flag of each sub-tensor in the input tensor. The broadcast rules are used to trigger the tensor broadcasting mechanism of the operator to be tested.

[0051] In some embodiments, for any combination of parameters; the fifth processing module is specifically used for:

[0052] Based on the first and second output tensors corresponding to the parameter combinations, the first correctness of the vectorization processing of the operator under the parameter combinations in the forward processing is determined;

[0053] Based on the first and second output tensors corresponding to the parameter combinations, the second correctness of the vectorization processing of the operator under the parameter combinations in gradient calculation is determined.

[0054] When the first correctness is normal and the second correctness is normal, the target correctness is determined to be normal.

[0055] When the first correctness is abnormal and / or the second correctness is abnormal, the target correctness is determined to be abnormal.

[0056] In some embodiments, the fifth processing module is specifically used for:

[0057] Determine the first error between the first output tensor and the second output tensor;

[0058] When the first error is less than the preset output error threshold, the first correctness is determined to be normal;

[0059] When the first error is greater than or equal to the output error threshold, the first correctness is determined to be abnormal.

[0060] In some embodiments, the fifth processing module is specifically used for:

[0061] Perform backpropagation on the first output tensor to obtain the first gradient tensor under vectorization;

[0062] Perform backpropagation on the second output tensor to obtain the second gradient tensor under sequential loop processing;

[0063] The second correctness is determined based on the first gradient tensor and the second gradient tensor.

[0064] In some embodiments, the fifth processing module is specifically used for:

[0065] Determine the second error between the first gradient tensor and the second gradient tensor;

[0066] When the second error is greater than or equal to the preset gradient error threshold, the second correctness is determined to be abnormal;

[0067] When the second error is less than the gradient error threshold, the second correctness is determined to be normal.

[0068] In some embodiments, the fifth processing module is specifically used for:

[0069] Based on numerical differentiation, the gradient truth tensor of the input tensor of the operator to be tested is determined.

[0070] Determine the first gradient error between the first gradient tensor and the gradient truth tensor, and determine the second gradient error between the second gradient tensor and the gradient truth tensor;

[0071] If the first gradient error is less than the preset gradient error threshold when the second gradient error is less than the gradient error threshold, then the second correctness is determined to be normal; if the first gradient error is greater than or equal to the gradient error threshold, then the second correctness is determined to be abnormal.

[0072] When the second gradient error is greater than or equal to the gradient error threshold, a test failure alarm text is generated, indicating that the correctness of the gradient calculation in the sequential loop processing is abnormal.

[0073] The correctness testing device for vectorization processing provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be repeated here.

[0074] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0075] The memory stores the instructions that the computer executes;

[0076] The processor executes computer-executable instructions stored in memory to implement the method as described in the first aspect.

[0077] The electronic device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be repeated here.

[0078] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method as described in the first aspect.

[0079] When the computer-executable instructions in the computer-readable storage medium provided in this application are executed by a processor, the technical solutions shown in the above method embodiments can be implemented. The implementation principle and beneficial effects are similar, and will not be repeated here.

[0080] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method of the first aspect.

[0081] When the computer program in the computer program product provided in this application is executed by a processor, it can implement the technical solution shown in the above method embodiments. The implementation principle and beneficial effects are similar, and will not be repeated here.

[0082] The present application provides a method, electronic device, and storage medium for testing the correctness of vectorization processing. The method includes: obtaining an operator to be tested from a preset list of element-wise operators; determining multiple parameter combinations of test conditions based on the type of the operator to be tested, wherein the test conditions are associated with the type of the operator to be tested; determining the input tensor corresponding to each parameter combination; for any given parameter combination, vectorizing the input tensor based on the operator to be tested to obtain a first output tensor of the operator to be tested; and performing sequential loop processing on the input tensor based on the operator to be tested to obtain a second output tensor of the operator to be tested; and determining the target correctness of the vectorization processing of the operator to be tested under each parameter combination based on the first and second output tensors corresponding to each parameter combination. In the above method, multiple parameter combinations of test condition items (such as data type, broadcast rules, transpose state, etc.) related to the type of operator to be tested are automatically enumerated. For each set of parameter combinations, a corresponding input tensor is automatically generated and vectorized and sequentially looped respectively. By comparing the differences in the output of the two processing methods, the correctness of vectorization processing under all parameter combinations can be systematically verified. This overcomes the limitation that manually writing test cases is difficult to fully cover multi-dimensional test conditions. It can efficiently and automatically discover boundary errors and numerical instability problems caused by different parameter combinations, thereby more accurately and reliably determining the correctness of vectorization processing. Attached Figure Description

[0083] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0084] Figure 1 A flowchart illustrating a correctness testing method for vectorization processing provided in an embodiment of this application;

[0085] Figure 2 A flowchart illustrating a method for determining the correctness of a target, provided in an embodiment of this application;

[0086] Figure 3 A flowchart illustrating a method for determining second correctness provided in an embodiment of this application;

[0087] Figure 4 A schematic diagram of the structure of a vectorization processing correctness testing device provided in an embodiment of this application;

[0088] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0089] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0090] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0091] In deep learning models (such as TensorFlow and PyTorch), vectorization of element-wise operators (e.g., trigonometric functions, matrix multiplication, Cholesky decomposition) is a key technique for improving computational efficiency. Vectorization of element-wise operators significantly improves computational efficiency by converting element-wise computations into vectorized instructions. However, the correctness of the vectorization of element-wise operators affects the numerical accuracy of the model's results. Therefore, it is necessary to ensure the correctness of the vectorization of element-wise operators to guarantee the numerical accuracy of the model's results.

[0092] In related technologies, developers rely on writing test cases for vectorized processing and test cases for sequential loop processing for each element-wise operator. The numerical precision of the results of the two test cases in the forward processing is compared to determine the correctness of the vectorized processing of each element-wise operator.

[0093] However, the input tensors that the element-wise operators need to process are complex and varied. Manually writing test cases makes it difficult to fully cover the testing of input tensors under different test conditions. That is, it can only cover scenarios with one combination of parameters for multiple test conditions (such as the dimension of the input tensor, the data type of the input tensor, and whether the input tensor is transposed before the operator is calculated), and cannot cover scenarios with multiple combinations of parameters at the same time. This makes it difficult to find boundary errors and numerical instability caused by other parameter combinations, resulting in inaccurate determination of the correctness of the vectorized implementation.

[0094] Based on the above-mentioned technical problems, the technical concept of the embodiments of this application is as follows:

[0095] From a pre-defined list of element-wise operators, obtain the operator to be tested; based on the type of the operator to be tested, determine multiple parameter combinations of test condition terms, which are associated with the type of the operator to be tested; based on each parameter combination, determine the input tensor corresponding to each parameter combination; for any parameter combination, based on the operator to be tested, vectorize the input tensor to obtain the first output tensor of the operator to be tested, and based on the operator to be tested, perform sequential loop processing on the input tensor to obtain the second output tensor of the operator to be tested; based on the first and second output tensors corresponding to each parameter combination, determine the target correctness of the vectorization processing of the operator to be tested under each parameter combination. In the above method, multiple parameter combinations of test condition items (such as data type, broadcast rules, transpose state, etc.) related to the type of operator to be tested are automatically enumerated. For each set of parameter combinations, a corresponding input tensor is automatically generated and vectorized and sequentially looped. By comparing the differences in the output of the two processing methods, the correctness of vectorization processing under all parameter combinations can be systematically verified. This overcomes the limitation of manually writing test cases that cannot fully cover multi-dimensional test conditions. It can efficiently and automatically discover boundary errors and numerical instability caused by different parameter combinations, thereby more accurately and reliably determining the correctness of vectorization processing and providing a strong guarantee for the computational accuracy of deep learning models.

[0096] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0097] Figure 1 A flowchart illustrating a correctness testing method for vectorization processing provided in this application embodiment is shown below. Figure 1 As shown, the method includes:

[0098] S101. Obtain the operator to be tested from the preset list of element-wise operators.

[0099] The list of element-wise operators is a pre-stored set of element-wise operators that need to be tested in deep learning frameworks.

[0100] It is understood that the element-wise operator list has scalability. By adding element-wise operators to be tested to this list, the test coverage of this application embodiment can be flexibly expanded to adapt to the element-wise operators added after the iteration of the deep learning model. Alternatively, for specific business scenarios, element-wise operators in the list can be set to complete the adaptability test for the business scenario, thereby improving the universality and adaptability of the vectorization processing correctness testing method.

[0101] It is understood that the embodiments of this application support batch verification of operators in the element-wise operator list: select a single element-wise operator from the preset element-wise operator list as the current operator to be tested, execute the subsequent test process S102 to S105 for the operator to be tested, and after completing the target correctness determination of an element-wise operator, continue to select the next element-wise operator in the element-wise operator list and repeat the above process until all element-wise operators in the element-wise operator list have been traversed, and finally obtain the vectorized processing target correctness results of all element-wise operators in the element-wise operator list under various parameter combinations.

[0102] S102. Based on the type of the operator to be tested, determine multiple parameter combinations of the test condition terms, wherein the test condition terms are associated with the type of the operator to be tested.

[0103] Understandably, the type of the operator to be tested is the same as the type of the element-wise operator.

[0104] In some embodiments, the type of operator to be tested may include unary element-wise operators and binary element-wise operators.

[0105] In some embodiments, when the type of the operator to be tested is a unary element-wise operator, the test condition includes the data type of the input tensor and a transpose flag, wherein the transpose flag indicates whether the input tensor is transposed;

[0106] When the type of the operator to be tested is a binary element-wise operator, the test condition includes the data type of the input tensor, the broadcast rules of the two sub-tensors in the input tensor, and the transpose flag of each sub-tensor in the input tensor. The broadcast rules are used to trigger the tensor broadcasting mechanism of the operator to be tested.

[0107] Data types include, but are not limited to, single-precision floating-point numbers (FP32), double-precision floating-point numbers (FP64), single-precision complex numbers (Complex64), double-precision complex numbers (Complex128), 32-bit integers (INT32), and 64-bit integers (INT64).

[0108] The transpose flag can be True or False. When the transpose flag is True, it indicates that the input tensor should be transposed before being processed by the operator under test; when the transpose flag is False, it indicates that the input tensor should not be transposed before being processed by the operator under test.

[0109] The following example, using an input tensor comprising sub-tensor A and sub-tensor B, illustrates the broadcast rule:

[0110] Subtensor A has dimension A and subtensor B has dimension B. The broadcast rules include rule A, rule B and rule C. Rule A indicates that dimension A is less than dimension B (e.g., if dimension A is (3,) and dimension B is (2,3), subtensor A needs to be expanded to dimension (2,3) to match subtensor B). Rule B indicates that dimension A is equal to dimension B (e.g., if dimension A is (2,3) and dimension B is (2,3), no broadcast is needed and the operation can be performed directly). Rule C indicates that dimension A is greater than dimension B (e.g., if dimension A is (2,3) and dimension B is (3,), subtensor B needs to be expanded to dimension (2,3) to match subtensor A).

[0111] For example, dimension A (3,) indicates that subtensor A is a one-dimensional tensor and contains only the element 3. Dimension B (2,3) indicates that subtensor B is a two-dimensional tensor and has 3 rows and 1 column.

[0112] For example, if the type of the operator to be tested is a unary element-wise operator, when the data type includes FP32 and FP64 and the transpose flag includes True and False, multiple parameter combinations include combination A1 (data type is FP32, transpose flag is True), combination A2 (data type is FP64, transpose flag is True), combination A3 (data type is FP32, transpose flag is False), and combination A4 (data type is FP64, transpose flag is False). Multiple parameter combinations cover all combination scenarios of different data types and transpose states.

[0113] It should be noted that for other data types (such as Complex64, INT32, etc.) of unary element-wise operators and multiple parameter combinations with transpose flags, or for multiple parameter combinations of multiple test condition terms of binary element-wise operators, the corresponding multiple parameter combinations can be generated by referring to the above enumeration logic, and will not be listed one by one here.

[0114] Furthermore, the embodiments of this application can also support the correctness testing of vectorization processing of sparse segment operators and complex linear algebra operators. Specifically, the test conditions for sparse segment operators (such as the sparse_segment_ series operators) and complex linear algebra operators (such as the Cholesky decomposition operator, Einsum operator, etc.) are different, while other processes are similar to those for binary element-wise operators, and will not be described in detail here.

[0115] The test condition terms for sparse segment operators and complex linear algebra operators are determined based on the actual application scenario, and are not specifically limited by the instrument itself.

[0116] S103. Based on each parameter combination, determine the input tensor corresponding to each parameter combination.

[0117] The following provides an example of how to determine the input tensor corresponding to each parameter combination:

[0118] When the parameter combination is of data type FP32 and the transpose flag is True, first determine the tensor shape, for example, the preset (4,5), and generate a 4-row, 5-column random tensor that conforms to FP32. The element value range of the random tensor is, for example, [-10.0, 10.0] (covering typical values ​​such as positive and negative values ​​and zero). Then, according to the condition that the transpose flag is True, transpose the random tensor to (5,4) to obtain the input tensor corresponding to the parameter combination.

[0119] When the parameter combination is data type FP32, sub-tensor A transpose flag is True, sub-tensor B transpose flag is False, and broadcast rule is rule A, sub-tensor A is generated with a random shape (3,) and FP32 data type. Then, according to the condition that the transpose flag is True, the random tensor is transposed to (3,) (the shape of a one-dimensional tensor remains unchanged after transposition). Sub-tensor B is generated with a random shape (2,3). A 2x3 random tensor conforming to FP32 is generated, and the element value range of the random tensor is, for example, [-5.0, 5.0]. If the transpose flag is False, the shape remains unchanged, and the input tensor corresponding to this parameter combination is obtained.

[0120] Understandably, the shape of the tensor and the range of element values ​​for the random tensor are preset.

[0121] S104. For any combination of parameters, based on the operator to be tested, the input tensor is vectorized to obtain the first output tensor of the operator to be tested, and based on the operator to be tested, the input tensor is sequentially looped to obtain the second output tensor of the operator to be tested.

[0122] Specifically, for any combination of parameters, based on the operator to be tested, the input tensor corresponding to the combination of parameters is vectorized to obtain the first output tensor of the operator to be tested corresponding to the combination of parameters, and based on the operator to be tested, the input tensor corresponding to the combination of parameters is processed sequentially to obtain the second output tensor of the operator to be tested corresponding to the combination of parameters.

[0123] Vectorization processing involves feeding the input tensor as a whole into the operator to be tested, and performing operations on all elements at once through the vectorization operation interface of the deep learning framework. The operation process is optimized in parallel by the underlying framework, eliminating the need for manual element splitting.

[0124] The sequential loop processing involves splitting the input tensor element by element dimension (e.g., flattening a multidimensional tensor into a one-dimensional tensor, or splitting it row by row / column by index), feeding each element into the operator to be tested for operation, recording the result of each element's operation, and finally concatenating all the single-element results into a complete output tensor according to the original tensor shape. This processing method has no parallel optimization, the operation process is executed serially, and the result can be used as a baseline truth reference for vectorization processing.

[0125] In some embodiments, before performing vectorization processing and sequential loop processing, two test sessions, graph execution mode and dynamic graph execution mode, can be registered at once; vectorization processing and sequential loop processing are performed in the two test sessions respectively to verify that the vectorization processing of the operator under test meets the correctness requirements in both the graph compilation execution stage and the just-in-time execution stage.

[0126] S105. Based on the first and second output tensors corresponding to each parameter combination, determine the target correctness of the vectorization processing of the operator to be tested under each parameter combination.

[0127] In some embodiments, for any combination of parameters, determining the target correctness of the vectorization processing of the operator under test under each parameter combination, based on the first output tensor and the second output tensor corresponding to each parameter combination, may include:

[0128] Determine the first error between the first output tensor and the second output tensor;

[0129] When the first error is less than the preset output error threshold, the first correctness is determined to be normal;

[0130] When the first error is greater than or equal to the output error threshold, the first correctness is determined to be abnormal.

[0131] The first error is the difference between the first output tensor and the second output tensor, that is, the difference obtained by subtracting the second output tensor from the first output tensor. In actual calculation, the maximum value of the element-wise absolute error is taken as the first error. For example, if the first output tensor is [[1.1,2.0],[3.0,4.0]] and the second output tensor is [[1.0,2.01],[3.0,4.0]], then the element-wise absolute error is [[0.1,0.01],[0.0,0.0]], and the first error is 0.01.

[0132] The output error threshold is, for example, 1e-6. This threshold can be adjusted according to the data type (for example, the output error threshold for FP32 is 1e-6, the output error threshold for FP64 is 1e-9, and the output error threshold for integer tensors is 0).

[0133] The target correctness is normal, indicating that the vectorization processing of the operator under test under this parameter combination is reliable. This means that the operation result of the vectorization processing is consistent with the result of the sequential loop processing in the serial manner within the numerical precision range. The vectorization processing under this parameter combination can be used safely and will not cause result deviation due to parallel optimization.

[0134] An abnormal target correctness indicates that the vectorization processing of the operator under test is unreliable under this parameter combination. This means that the deviation between the result of vectorization processing and the result of sequential loop processing exceeds the accuracy threshold. Vectorization processing should be disabled under this parameter combination, or the implementation logic of vectorization processing should be modified to avoid affecting the final result of the deep learning model due to incorrect results.

[0135] The beneficial effects of this application's embodiments are as follows: In this application's embodiments, the operator to be tested is obtained from a preset list of element-wise operators; based on the type of the operator to be tested, multiple parameter combinations of test condition items are determined, and the test condition items are associated with the type of the operator to be tested; based on each parameter combination, the input tensor corresponding to each parameter combination is determined; for any parameter combination, based on the operator to be tested, the input tensor is vectorized to obtain the first output tensor of the operator to be tested, and based on the operator to be tested, the input tensor is sequentially looped to obtain the second output tensor of the operator to be tested; based on the first output tensor and the second output tensor corresponding to each parameter combination, the target correctness of the vectorization processing of the operator to be tested under each parameter combination is determined. In the above method, multiple parameter combinations of test condition items (such as data type, broadcast rules, transpose state, etc.) related to the type of operator to be tested are automatically enumerated. For each set of parameter combinations, a corresponding input tensor is automatically generated and vectorized and sequentially looped. By comparing the differences in the output of the two processing methods, the correctness of vectorization processing under all parameter combinations can be systematically verified. This overcomes the limitation of manually writing test cases that cannot fully cover multi-dimensional test conditions. It can efficiently and automatically discover boundary errors and numerical instability caused by different parameter combinations, thereby more accurately and reliably determining the correctness of vectorization processing and providing a strong guarantee for the computational accuracy of deep learning models.

[0136] In addition, the scalable list of element-wise operators allows for automatic inclusion in the testing scope simply by adding the new element-wise operator to the list, avoiding the need to write corresponding test cases for every new element-wise operator in related technologies, thus improving development efficiency.

[0137] exist Figure 1 Based on the embodiments, the following is combined Figure 2For any combination of parameters, a detailed explanation is given on "determining the target correctness of the vectorization processing of the operator to be tested under each parameter combination based on the first and second output tensors corresponding to each parameter combination".

[0138] Figure 2 A flowchart illustrating a method for determining the correctness of a target, as provided in an embodiment of this application, is shown below. Figure 2 As shown, the method includes:

[0139] S201. Based on the first and second output tensors corresponding to the parameter combination, determine the first correctness of the vectorization processing of the operator under test in the forward processing under the parameter combination.

[0140] In some embodiments, based on the first and second output tensors corresponding to the parameter combinations, determining the first correctness of the vectorization processing of the operator under the parameter combination in the forward processing includes:

[0141] Determine the first error between the first output tensor and the second output tensor;

[0142] When the first error is less than the preset output error threshold, the first correctness is determined to be normal;

[0143] When the first error is greater than or equal to the output error threshold, the first correctness is determined to be abnormal.

[0144] S202. Based on the first and second output tensors corresponding to the parameter combinations, determine the second correctness of the vectorization processing of the operator under the parameter combinations in gradient calculation.

[0145] In some embodiments, based on the first and second output tensors corresponding to the parameter combinations, determining the second correctness of the vectorization processing of the operator under the parameter combination in gradient calculation includes:

[0146] Perform backpropagation on the first output tensor to obtain the first gradient tensor under vectorization;

[0147] Perform backpropagation on the second output tensor to obtain the second gradient tensor under sequential loop processing;

[0148] The second correctness is determined based on the first gradient tensor and the second gradient tensor.

[0149] Understandably, gradient tracking and gradient recording need to be enabled and persisted before backpropagation is performed. This allows us to obtain the first gradient tensor under vectorization when performing backpropagation on the first output tensor, and the second gradient tensor under sequential loop processing when performing backpropagation on the second output tensor.

[0150] In some embodiments, determining the second correctness based on the first gradient tensor and the second gradient tensor includes:

[0151] Determine the second error between the first gradient tensor and the second gradient tensor;

[0152] When the second error is greater than or equal to the preset gradient error threshold, the second correctness is determined to be abnormal;

[0153] When the second error is less than the gradient error threshold, the second correctness is determined to be normal.

[0154] It should be noted that the determination of the second error can refer to the determination of the first error, which will not be repeated here.

[0155] The gradient error threshold can also be, for example, 1e-6. The gradient error threshold can be adapted and adjusted according to the order of the derivative during backpropagation: for example, the gradient error threshold for the first derivative is 1e-6, and the gradient error threshold for the second and higher derivatives is relaxed to 1e-5.

[0156] S203. When the first correctness is normal and the second correctness is normal, the target correctness is determined to be normal.

[0157] Specifically, this means that under this parameter combination, the vectorization processing of the operator under test is consistent with the result of the benchmark sequential loop processing in both the forward computation and gradient computation, and the numerical accuracy of the vectorization processing and the gradient propagation logic are reliable.

[0158] S204. When the first correctness is abnormal and / or the second correctness is abnormal, determine that the target correctness is abnormal.

[0159] That is, when the first correctness and / or the second correctness are abnormal, the target correctness is determined to be abnormal. This means that under this parameter combination, the vectorization processing of the operator under test has an unacceptable numerical deviation in at least one core dimension (forward computation or gradient computation).

[0160] The beneficial effects of this application's embodiments are as follows: In this application's embodiments, based on the first and second output tensors corresponding to the parameter combinations, the first correctness of the vectorization processing of the operator under test in the forward processing under the parameter combinations is determined; based on the first and second output tensors corresponding to the parameter combinations, the second correctness of the vectorization processing of the operator under test in gradient calculation under the parameter combinations is determined; when the first correctness is normal and the second correctness is normal, the target correctness is determined to be normal; when the first correctness is abnormal and / or the second correctness is abnormal, the target correctness is determined to be abnormal. Through the above method, not only is the correctness of the vectorization processing in the forward calculation verified, but its correctness in the backpropagation gradient calculation is also verified.

[0161] exist Figure 2 Based on the embodiments, the following is combined Figure 3 The document provides a detailed explanation of "determining the second correctness based on the first gradient tensor and the second gradient tensor".

[0162] Figure 3 A flowchart illustrating a method for determining second correctness provided in an embodiment of this application is shown below. Figure 3 As shown, the method includes:

[0163] S301. Based on numerical differentiation, determine the gradient truth tensor of the input tensor of the operator to be tested.

[0164] In some embodiments, the gradient truth tensor of the input tensor of the operator to be tested is determined based on numerical differentiation.

[0165] Numerical differentiation is a numerical calculation method that approximates the true gradient tensor by applying a preset small perturbation to the input tensor and calculating the ratio of the change in the output of the operator under test before and after the perturbation to the perturbation value.

[0166] For example, the central difference method can be used: apply a perturbation Δx to each element x in the input tensor (Δx can be 1e-5 to adapt to the precision characteristics of the FP32 data type), calculate (f(x+Δx)-f(x-Δx)) / (2Δx) as the gradient truth tensor of that element, where f is the operation logic of the operator to be tested, and finally concatenate the gradient truth tensors of all elements into the gradient truth tensor.

[0167] S302. Determine the first gradient error between the first gradient tensor and the true gradient tensor, and determine the second gradient error between the second gradient tensor and the true gradient tensor.

[0168] It should be noted that the determination of the first gradient error and the second gradient error can refer to the determination of the first error, and will not be repeated here.

[0169] S303. Determine whether the second gradient error is less than the gradient error threshold.

[0170] If so, execute S304;

[0171] Otherwise, execute S307.

[0172] S304. Determine whether the first gradient error is less than the gradient error threshold.

[0173] If so, execute S305;

[0174] Otherwise, execute S306.

[0175] S305, Determine the second correctness as normal.

[0176] This indicates that the result of gradient calculation in sequential loop processing is consistent with the true gradient tensor (the second gradient error is less than the gradient error threshold, which means the baseline is reliable), and the result of gradient calculation in vectorized processing is also consistent with the true gradient tensor (the first gradient error is less than the gradient error threshold). Therefore, the vectorized processing of the operator under test has no deviation in gradient calculation, and the gradient propagation logic is reliable.

[0177] S306. Determine the second correctness as abnormal.

[0178] The gradient calculation results of sequential loop processing are consistent with the true gradient value (the second gradient error is less than the gradient error threshold, which means the baseline is reliable). However, the gradient calculation results of vectorized processing deviate from the true gradient value by more than the threshold (the first gradient error is greater than or equal to the gradient error threshold). The vectorized processing of the operator under test has a deviation in gradient calculation, and the gradient propagation logic is unreliable.

[0179] S307. Generate test failure alarm text, wherein the test failure alarm text indicates that the correctness of the sequential loop processing in gradient calculation is abnormal.

[0180] Test failure alarm text may include, but is not limited to, one or more of the following: the name of the operator to be tested, the current parameter combination (data type, transpose flag, broadcast rule), the second gradient error value, and / or the gradient error threshold.

[0181] Specifically, the test failure alarm text indicates that the correctness of the gradient calculation under the current parameter combination in the sequential loop processing is abnormal.

[0182] The beneficial effects of this application's embodiments are as follows: In this application's embodiments, based on numerical differentiation, the gradient truth tensor of the input tensor of the operator to be tested is determined; the first gradient error between the first gradient tensor and the gradient truth tensor is determined, and the second gradient error between the second gradient tensor and the gradient truth tensor is determined; when the second gradient error is less than a preset gradient error threshold, if the first gradient error is less than the gradient error threshold, then the second correctness is determined to be normal; if the first gradient error is greater than or equal to the gradient error threshold, then the second correctness is determined to be abnormal; when the second gradient error is greater than or equal to the gradient error threshold, a test failure alarm text is generated, and the test failure alarm text indicates that the correctness of the sequential loop processing in gradient calculation is abnormal. In the above method, the gradient truth tensor based on numerical differentiation is introduced as an objective reference in the verification of gradient correctness. By comparing the vectorized first gradient tensor with the gradient truth tensor, and also comparing the second gradient tensor, which is used as the benchmark and processed sequentially, with the gradient truth tensor, the credibility of the benchmark itself and the correctness of the vectorized gradient calculation can be cross-verified. This dual verification mechanism not only enhances the reliability of gradient correctness judgment and avoids misjudgment caused by potential errors in the benchmark implementation, but also accurately locates the problem through clear test failure alarm text when the benchmark verification fails, effectively improving the robustness of the entire gradient correctness testing process.

[0183] Figure 4 This is a schematic diagram of the structure of a vectorization processing correctness testing device provided in an embodiment of this application. Figure 4 As shown, the vectorization processing correctness testing device 40 includes a first processing module 401, a second processing module 402, a third processing module 403, a fourth processing module 404, and a fifth processing module 405.

[0184] The first processing module 401 is used to obtain the operator to be tested from a preset list of element-wise operators;

[0185] The second processing module 402 is used to determine multiple parameter combinations of test condition items based on the type of the operator to be tested, wherein the test condition items are associated with the type of the operator to be tested.

[0186] The third processing module 403 is used to determine the input tensor corresponding to each parameter combination based on the parameter combinations.

[0187] The fourth processing module 404 is used to vectorize the input tensor based on the operator to be tested for any combination of parameters to obtain the first output tensor of the operator to be tested, and to perform sequential loop processing on the input tensor based on the operator to be tested to obtain the second output tensor of the operator to be tested.

[0188] The fifth processing module 405 is used to determine the target correctness of the vectorization processing of the operator to be tested under each parameter combination based on the first output tensor and the second output tensor corresponding to each parameter combination.

[0189] The vectorization processing correctness testing device 40 provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be repeated here.

[0190] In some embodiments, when the type of the operator to be tested is a unary element-wise operator, the test condition includes the data type of the input tensor and a transpose flag, wherein the transpose flag indicates whether the input tensor is transposed.

[0191] When the type of the operator to be tested is a binary element-wise operator, the test condition includes the data type of the input tensor, the broadcast rules of the two sub-tensors in the input tensor, and the transpose flag of each sub-tensor in the input tensor. The broadcast rules are used to trigger the tensor broadcasting mechanism of the operator to be tested.

[0192] In some embodiments, for any combination of parameters; the fifth processing module 405 is specifically used for:

[0193] Based on the first and second output tensors corresponding to the parameter combinations, the first correctness of the vectorization processing of the operator under the parameter combinations in the forward processing is determined;

[0194] Based on the first and second output tensors corresponding to the parameter combinations, the second correctness of the vectorization processing of the operator under the parameter combinations in gradient calculation is determined.

[0195] When the first correctness is normal and the second correctness is normal, the target correctness is determined to be normal.

[0196] When the first correctness is abnormal and / or the second correctness is abnormal, the target correctness is determined to be abnormal.

[0197] In some embodiments, the fifth processing module 405 is specifically used for:

[0198] Determine the first error between the first output tensor and the second output tensor;

[0199] When the first error is less than the preset output error threshold, the first correctness is determined to be normal;

[0200] When the first error is greater than or equal to the output error threshold, the first correctness is determined to be abnormal.

[0201] In some embodiments, the fifth processing module 405 is specifically used for:

[0202] Perform backpropagation on the first output tensor to obtain the first gradient tensor under vectorization;

[0203] Perform backpropagation on the second output tensor to obtain the second gradient tensor under sequential loop processing;

[0204] The second correctness is determined based on the first gradient tensor and the second gradient tensor.

[0205] In some embodiments, the fifth processing module 405 is specifically used for:

[0206] Determine the second error between the first gradient tensor and the second gradient tensor;

[0207] When the second error is greater than or equal to the preset gradient error threshold, the second correctness is determined to be abnormal;

[0208] When the second error is less than the gradient error threshold, the second correctness is determined to be normal.

[0209] In some embodiments, the fifth processing module 405 is specifically used for:

[0210] Based on numerical differentiation, the gradient truth tensor of the input tensor of the operator to be tested is determined.

[0211] Determine the first gradient error between the first gradient tensor and the gradient truth tensor, and determine the second gradient error between the second gradient tensor and the gradient truth tensor;

[0212] If the first gradient error is less than the preset gradient error threshold when the second gradient error is less than the gradient error threshold, then the second correctness is determined to be normal; if the first gradient error is greater than or equal to the gradient error threshold, then the second correctness is determined to be abnormal.

[0213] When the second gradient error is greater than or equal to the gradient error threshold, a test failure alarm text is generated, indicating that the correctness of the gradient calculation in the sequential loop processing is abnormal.

[0214] The vectorization processing correctness testing device 40 provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be repeated here.

[0215] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device 50 includes a processor 501 and a memory 502. The processor 501 is communicatively connected to the memory 502, which stores computer execution instructions. The processor 501 is configured to execute the technical solutions in any of the aforementioned method embodiments by executing the computer execution instructions stored in the memory 502.

[0216] Optionally, the memory 502 can be either independent or integrated with the processor 501. Optionally, when the memory 502 is a device independent of the processor 501, the electronic device 50 may further include a bus 503 for connecting the aforementioned devices.

[0217] The electronic device is used to execute the technical solutions in any of the foregoing method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.

[0218] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the technical solutions provided in any of the foregoing method embodiments.

[0219] This application also provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the technical solutions provided in the foregoing method embodiments.

[0220] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0221] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0222] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.

[0223] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.

[0224] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.

[0225] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0226] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.

[0227] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0228] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A method of testing the correctness of a vectorized process, characterized in that, The method includes: Obtain the operator to be tested from the preset list of element-wise operators; Based on the type of the operator to be tested, multiple parameter combinations of test condition items are determined, and the test condition items are associated with the type of the operator to be tested; Based on each parameter combination, determine the input tensor corresponding to each parameter combination; For any combination of parameters, based on the operator to be tested, the input tensor is vectorized to obtain the first output tensor of the operator to be tested, and based on the operator to be tested, the input tensor is sequentially looped to obtain the second output tensor of the operator to be tested. Based on the first output tensor and the second output tensor corresponding to each parameter combination, the target correctness of the vectorization processing of the operator to be tested under each parameter combination is determined.

2. The method of claim 1, wherein, When the type of the operator to be tested is a unary element-wise operator, the test condition includes the data type of the input tensor and a transpose flag, wherein the transpose flag indicates whether the input tensor is transposed; When the type of the operator to be tested is a binary element-wise operator, the test condition includes the data type of the input tensor, the broadcast rules of the two sub-tensors in the input tensor, and the transpose flag of each sub-tensor in the input tensor. The broadcast rules are used to trigger the tensor broadcast mechanism of the operator to be tested.

3. The method of claim 1, wherein, For any combination of parameters; determining the target correctness of the vectorization processing of the operator under test under each parameter combination based on the first output tensor and the second output tensor corresponding to each parameter combination includes: Based on the first output tensor and the second output tensor corresponding to the parameter combination, determine the first correctness of the vectorization processing of the operator under test under the parameter combination in the forward processing; Based on the first output tensor and the second output tensor corresponding to the parameter combination, determine the second correctness of the vectorization processing of the operator under the parameter combination in gradient calculation; When the first correctness is normal and the second correctness is normal, the target correctness is determined to be normal; The target correctness is determined to be abnormal when the first correctness is abnormal and / or the second correctness is abnormal.

4. The method of claim 3, wherein, The step of determining the first correctness of the vectorization processing of the operator under test under the parameter combination in the forward processing based on the first output tensor and the second output tensor corresponding to the parameter combination includes: Determine the first error between the first output tensor and the second output tensor; When the first error is less than a preset output error threshold, the first correctness is determined to be normal; When the first error is greater than or equal to the output error threshold, the first correctness is determined to be abnormal.

5. The method of claim 3, wherein, The step of determining the second correctness of the vectorization processing of the operator under the parameter combination in gradient calculation based on the first output tensor and the second output tensor corresponding to the parameter combination includes: Perform backpropagation on the first output tensor to obtain the first gradient tensor under vectorization; Perform backpropagation on the second output tensor to obtain the second gradient tensor under sequential loop processing; The second correctness is determined based on the first gradient tensor and the second gradient tensor.

6. The method of claim 5, wherein, The determination of the second correctness based on the first gradient tensor and the second gradient tensor includes: Determine the second error between the first gradient tensor and the second gradient tensor; When the second error is greater than or equal to a preset gradient error threshold, the second correctness is determined to be abnormal; When the second error is less than the gradient error threshold, the second correctness is determined to be normal.

7. The method of claim 5, wherein, The determination of the second correctness based on the first gradient tensor and the second gradient tensor includes: Based on numerical differentiation, the gradient truth tensor of the input tensor of the operator to be tested is determined. Determine a first gradient error between the first gradient tensor and the true gradient tensor, and determine a second gradient error between the second gradient tensor and the true gradient tensor; When the second gradient error is less than a preset gradient error threshold, if the first gradient error is less than the gradient error threshold, then the second correctness is determined to be normal; if the first gradient error is greater than or equal to the gradient error threshold, then the second correctness is determined to be abnormal. When the second gradient error is greater than or equal to the gradient error threshold, a test failure alarm text is generated, indicating that the correctness of the sequential loop processing in gradient calculation is abnormal.

8. An apparatus for testing the correctness of a vector processing, characterized by, The device includes: The first processing module is used to obtain the operator to be tested from a preset list of element-wise operators; The second processing module is used to determine multiple parameter combinations of test condition items based on the type of the operator to be tested, wherein the test condition items are associated with the type of the operator to be tested; The third processing module is used to determine the input tensor corresponding to each parameter combination based on the parameter combinations. The fourth processing module is used to perform vectorization processing on the input tensor based on the operator to be tested for any combination of parameters, to obtain the first output tensor of the operator to be tested, and to perform sequential loop processing on the input tensor based on the operator to be tested, to obtain the second output tensor of the operator to be tested. The fifth processing module is used to determine the target correctness of the vectorization processing of the operator to be tested under each parameter combination based on the first output tensor and the second output tensor corresponding to each parameter combination.

9. An electronic device, comprising: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-7.