Methods and apparatus for data format conversion and matrix processing
By converting the matrix calculation data format of artificial intelligence models to xfp16, the problems of high computational resource consumption and insufficient precision are solved, achieving efficient data format conversion and precision improvement, which is suitable for improving the peak performance of artificial intelligence chips.
Patent Information
- Application Number
- CN202210946170.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-08
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2042-08-08
AI Technical Summary
Computationally intensive operators in artificial intelligence models suffer from high computational resource consumption and insufficient precision during data format conversion, especially when using single-precision and half-precision floating-point data types, making it difficult to balance computational performance and precision requirements.
By determining the maximum value of the target matrix, dividing the numerical intervals, and based on the correspondence between elements and intervals, the original data format is converted into the target data format, and a more suitable 16-bit half-precision data format (xfp16) is adopted to reduce the amount of computation and improve the quantization accuracy.
It significantly improves matrix operation performance, reduces hardware resource consumption, shortens the training and inference calculation time of artificial intelligence models, and maintains a high-precision data representation range.
Smart Images

Figure CN115237992B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to the fields of artificial intelligence, deep learning, and chips. Background Technology
[0002] Artificial intelligence models contain a large number of computationally intensive operators, mainly including matrix computation, convolution, pooling, and activation operations. The precision requirements for computation in artificial intelligence models are lower than those of traditional high-performance computing applications. Traditional high-performance computing applications primarily use double-precision data types, while artificial intelligence applications mostly use single-precision and half-precision floating-point data types, or fixed-point data types. Summary of the Invention
[0003] This disclosure provides a method and apparatus for data format conversion, as well as a method and apparatus for matrix processing.
[0004] According to one aspect of this disclosure, a method for data format conversion is provided, comprising:
[0005] Determine the maximum value of the target matrix based on each element in the target matrix;
[0006] Based on the digit width of the exponent in the target data format and the maximum value of the target matrix, determine multiple consecutive numerical intervals; and
[0007] Based on the correspondence between each element and multiple numerical intervals, and the correspondence between multiple numerical intervals and the target data format, the original data format of the target matrix is converted into the target data format.
[0008] According to another aspect of this disclosure, a method for matrix processing is provided, comprising:
[0009] A third matrix is obtained by multiplying the first target matrix and the second target matrix; wherein the data formats of the first target matrix and the second target matrix are both target data formats, and the target data formats are obtained according to the data format conversion method of any embodiment of this disclosure; and
[0010] The data format of the third matrix is converted to the preset standard data format.
[0011] According to another aspect of this disclosure, an apparatus for data format conversion is provided, comprising:
[0012] The first determining module is used to determine the maximum value of the target matrix based on each element in the target matrix;
[0013] The second determining module is used to determine multiple consecutive numerical intervals based on the digit width of the exponent in the target data format and the maximum value of the target matrix; and
[0014] The first conversion module is used to convert the original data format of the target matrix into the target data format based on the correspondence between each element and multiple numerical intervals, and the correspondence between multiple numerical intervals and the target data format.
[0015] According to another aspect of this disclosure, an apparatus for matrix processing is provided, comprising:
[0016] The calculation module is used to perform multiplication operations on the first target matrix and the second target matrix to obtain a third matrix; wherein the data formats of the first target matrix and the second target matrix are both target data formats, and the target data formats are obtained according to the data format conversion method of any embodiment of this disclosure; and
[0017] The second conversion module is used to convert the data format of the third matrix into a preset standard data format according to the preset standard data format.
[0018] According to another aspect of this disclosure, an electronic device is provided, comprising:
[0019] At least one processor; and
[0020] The memory is communicatively connected to the at least one processor; wherein,
[0021] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the methods of any embodiment of the present disclosure.
[0022] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform a method according to any embodiment of this disclosure.
[0023] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a method according to any embodiment of this disclosure.
[0024] According to another aspect of this disclosure, an artificial intelligence chip is provided, comprising: an execution device for performing the methods of any embodiment of this disclosure.
[0025] According to the scheme disclosed herein, the computational load of data format conversion can be reduced, and the quantization accuracy of each element in the target matrix can be improved while taking into account the numerical range that each element can represent.
[0026] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0027] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0028] Figure 1 This is a flowchart illustrating a data format conversion method according to an embodiment of the present disclosure;
[0029] Figure 2 This is a schematic diagram of the target data format according to an embodiment of the present disclosure;
[0030] Figure 3 This is a schematic diagram of numerical line segments according to an embodiment of the present disclosure;
[0031] Figure 4 This is a flowchart illustrating a matrix processing method according to an embodiment of the present disclosure;
[0032] Figure 5 This is a schematic diagram illustrating the application of a matrix processing method according to an embodiment of the present disclosure;
[0033] Figure 6 This is a schematic diagram of the structure of a data format conversion apparatus according to an embodiment of the present disclosure;
[0034] Figure 7 This is a schematic diagram of the structure of a matrix processing apparatus according to an embodiment of the present disclosure;
[0035] Figure 8 This is a schematic diagram illustrating an application scenario of the data format conversion method and / or matrix processing method according to embodiments of this disclosure;
[0036] Figure 9 This is a schematic diagram of the structure of an artificial intelligence chip according to an embodiment of the present disclosure;
[0037] Figure 10 This is a block diagram of an electronic device used to implement the data format conversion method and / or matrix processing method of the embodiments of this disclosure. Detailed Implementation
[0038] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0039] According to embodiments of this disclosure, such as Figure 1 As shown, a method for data format conversion is provided, including:
[0040] Step S100: Determine the maximum value of the target matrix based on each element in the target matrix.
[0041] Step S101: Determine multiple consecutive numerical intervals based on the digit width of the exponent in the target data format and the maximum value of the target matrix.
[0042] Step S102: Based on the correspondence between each element and multiple numerical intervals, and the correspondence between multiple numerical intervals and the target data format, convert the original data format of the target matrix into the target data format.
[0043] Based on the above embodiments of this disclosure, it should be noted that:
[0044] The target matrix can be a matrix of any dimension.
[0045] An element can be understood as data or vectors located in different rows and columns of the target matrix. For example, if the target matrix is a 2x2 matrix, then the target matrix contains 4 elements.
[0046] The maximum value of the target data can be understood as the largest absolute value among all elements.
[0047] The correspondence between each element and multiple numerical intervals can be understood as the mapping relationship between the absolute value of each element and multiple numerical intervals, that is, in which numerical interval the absolute value of each element is located.
[0048] The correspondence between multiple numerical intervals and target data formats can be understood as the calculation method of the exponent and mantissa of the target data format corresponding to each numerical interval. Different numerical intervals may have different calculation methods for the exponent and mantissa of their corresponding target data formats.
[0049] Converting the original data format of the target matrix to the target data format can be understood as converting the original data format of each element in the target matrix to the target data format, thereby achieving the conversion of the original data format of the target matrix to the target data format.
[0050] According to the embodiments of this disclosure, the computational load of data format conversion can be reduced, and the quantization accuracy of each element in the target matrix can be improved while taking into account the numerical range that each element can represent.
[0051] The data format conversion method of this disclosure can be applied to computationally intensive operators in artificial intelligence models. This method enables the conversion of the data format of the input target matrix, thereby reducing the computational resource consumption of the operator. The computationally intensive operators described in this disclosure can be operators used during model training or operators used during inference after training. That is, the data format conversion method of this disclosure can be applied to both the model training process and the actual model inference process.
[0052] The data format conversion method of this disclosure can be applied to artificial intelligence chips, thereby improving their peak performance. When the artificial intelligence chip is used for artificial intelligence model training and inference calculations, it can significantly shorten the training and inference calculation times.
[0053] In one example, the target matrix is the matrix used by operators in a deep learning framework. Operators in a deep learning framework can be high-precision operators used during model training, or operators used by the trained model during computation.
[0054] According to embodiments of this disclosure, using the target matrix after data format conversion for calculation can improve the computational efficiency of operators in the deep learning framework while saving computational resources.
[0055] In one example, each element in the target matrix is data obtained by feature extraction from image information, speech information, or text information.
[0056] According to the embodiments of this disclosure, feature data extracted from image information, voice information, or text information can be converted into data formats, and the converted feature data can be used for post-processing, which can effectively improve the processing speed of image information, voice information, or text information.
[0057] In one implementation, such as Figure 2 As shown, the target data format has a digit width of 16 bits (Binarydigit), including a 1-bit sign bit, a 2-bit exponent bit, and a 13-bit mantissa bit.
[0058] It should be noted that, for the sake of convenience in describing the embodiments of this disclosure, the 16-bit half-precision target data format of the embodiments of this disclosure is referred to as xfp16.
[0059] The digit width used in the calculation formulas of the embodiments of this disclosure can be understood as a specific numerical value of the digit width. For example, dividing the numerical line segment into continuous 2... NThere are several numerical ranges, where N is the digit width of the exponent in the target data format (2 bits), i.e., N is 2.
[0060] According to embodiments of this disclosure, the xfp16 of this disclosure is more adapted to matrix operation processing, and can significantly improve computational performance and accuracy. The computational performance of the existing float (floating-point data type) data format is 19.5T (terabyte, TB), and the computational performance of the existing tf32 (TensorFlow) data format is 156T. However, the xfp16 of this disclosure can achieve a computational performance of 312T when performing matrix calculations, which is 16 times faster than float and 2 times faster than tf32, respectively, resulting in a significant improvement in computational performance.
[0061] Traditional fp16 (floating point) and bfloat16 (brain floating point) have more exponent bits and fewer mantissa bits, allowing them to represent a wide range of values. However, the calculation of the exponent bits is complex, resulting in higher hardware resource consumption. Traditional int16 (fixed point, integer) does not have an exponent, making calculation simpler and consuming fewer hardware resources. However, its representable value range is relatively small, leading to decreased precision in matrix calculations for some artificial intelligence models. The xfp16 data type of this disclosure uses a different data type than traditional fp16, bfloat16, and int16, with more mantissa bits and fewer exponent bits. For AI scenarios, it can represent a wider range than int16, while the fewer exponent bits result in lower hardware resource consumption (at least 30% reduction). With the same area (16 bits), it performs better than standard fp16 and bfloat16, better representing artificial intelligence models and matrix data.
[0062] In one embodiment, the data format conversion method of this disclosure includes steps S100 to S102, wherein step S100: determining the maximum value of the target matrix based on each element in the target matrix, specifically may include:
[0063] Determine the absolute value of each element based on its floating-point number.
[0064] The largest absolute value among all elements is determined as the maximum value of the target matrix.
[0065] It should be noted that the absolute value of each element can be determined by converting the floating-point numbers of each element to a different base.
[0066] According to embodiments of this disclosure, the maximum value of the target matrix can be accurately determined using the floating-point numbers of each element in the target matrix.
[0067] In one embodiment, the data format conversion method of this disclosure includes steps S100 to S102, wherein step S101: determining a plurality of consecutive numerical intervals based on the bit width of the exponent of the target data format and the maximum value of the target matrix, specifically including:
[0068] The numerical line segment is determined by using the maximum value of the target matrix as the maximum endpoint value and 0 as the minimum endpoint value.
[0069] Based on the digit width of the exponent in the target data format, the numerical line segment is divided into continuous 2... N A range of values.
[0070] Based on the digit width of the mantissa in the target data format, use the formula Determine 2 respectively N The minimum endpoint value of each of the intervals.
[0071] Where N is the digit width of the exponent in the target data format, and max a The maximum endpoint value for each numerical interval, max b M represents the minimum endpoint value for each numerical interval, and M represents the mantissa width of the target data format.
[0072] According to embodiments of this disclosure, by utilizing the digit width of the exponent and the digit width of the mantissa of the target data format, numerical segments adapted to the target matrix can be defined. Furthermore, the maximum and minimum endpoint values of each numerical interval within the numerical segments that best fits the values of each element in the target matrix can be determined.
[0073] In a specific example, the target data format has a 16-bit (binary digit) width, including a 1-bit sign bit, a 2-bit exponent bit, and a 13-bit mantissa bit. The maximum value of the target matrix is taken as the maximum endpoint, max0. Based on the 2-bit width of the exponent bit in the target data format, the numerical segments are divided into four consecutive numerical intervals, such as... Figure 3 As shown, it specifically includes:
[0074] The four numerical intervals are [0, max3], [max3, max2], [max2, max1], and [max1, max0].
[0075] In one embodiment, the data format conversion method of this disclosure includes steps S100 to S102, wherein step S102: based on the correspondence between each element and multiple numerical intervals, and the correspondence between the multiple numerical intervals and the target data format, the original data format of the target matrix is converted into the target data format, which may specifically include:
[0076] Step S1021: Based on the correspondence between the floating-point numbers of each element and multiple numerical ranges, and the correspondence between multiple numerical ranges and the target data format, determine the exponent bits of the target data format corresponding to each element.
[0077] Step S1022: Based on the correspondence between the floating-point numbers of each element and multiple numerical ranges, and the correspondence between multiple numerical ranges and the target data format, determine the mantissa of the target data format corresponding to each element.
[0078] Step S1023: Determine the sign bit of the target data format corresponding to each element based on the floating-point number of each element.
[0079] Step S1024: Convert the original data format of the target matrix into the target data format according to the sign bit, exponent bit, and mantissa bit of each element in the target data format.
[0080] According to the embodiments of this disclosure, by utilizing the correspondence between the floating-point numbers of each element and multiple numerical ranges, as well as the correspondence between multiple numerical ranges and the target data format, the mantissa and exponent of the target data format corresponding to each element can be accurately calculated, thereby realizing the conversion of the original data format of the target matrix into a target data format with high precision and a wide range of represented values.
[0081] In one embodiment, the data format conversion method of this disclosure includes steps S100 to S102, wherein step S1021: determining the exponent bits of the target data format corresponding to each element based on the correspondence between the floating-point numbers of each element and multiple numerical ranges, and the correspondence between the multiple numerical ranges and the target data format, specifically including:
[0082] Determine the absolute value of each element based on its floating-point number.
[0083] Based on the absolute value of each element, determine the corresponding numerical range of each element in multiple numerical intervals.
[0084] Based on the correspondence between the corresponding numerical range and the exponent of the target data format, determine the exponent of each element in the target data format.
[0085] In one example, the target data format has a 16-bit (binary digit) width, including a 1-bit sign bit, a 2-bit exponent bit, and a 13-bit mantissa bit. The maximum value of the target matrix is taken as the maximum endpoint, max0. Based on the 2-bit width of the exponent bit in the target data format, the numerical segments are divided into four consecutive numerical intervals, such as... Figure 3 As shown, it specifically includes:
[0086] The four numerical intervals are [0, max3], [max3, max2], [max2, max1], and [max1, max0].
[0087] When the absolute value of an element corresponds to the numerical range [0, max3], that is, when the absolute value is < max3, the exponent bit of the target data format corresponding to the element is determined to be 00.
[0088] When the absolute value of an element corresponds to the numerical range [max3, max2], that is, max3 < absolute value ≤ max2, the exponent bit of the target data format corresponding to the element is determined to be 0 or 1.
[0089] When the absolute value of an element corresponds to the numerical range [max2, max1], that is, max2 < absolute value ≤ max1, the exponent of the target data format corresponding to the element is determined to be 10.
[0090] When the absolute value of an element corresponds to the numerical range [max1, max0], that is, max1 < absolute value ≤ max0, the exponent of the target data format corresponding to the element is determined to be 11.
[0091] In one embodiment, the data format conversion method of this disclosure includes steps S100 to S102, wherein step S1022: determining the mantissa of the target data format corresponding to each element based on the correspondence between the floating-point number of each element and multiple numerical ranges, and the correspondence between the multiple numerical ranges and the target data format, specifically including:
[0092] Determine the absolute value of each element based on its floating-point number.
[0093] Based on the absolute value of each element, determine the corresponding numerical range of each element in multiple numerical intervals.
[0094] Based on the maximum endpoint value of the corresponding numerical range, the digit width of the mantissa in the target data format, and the absolute value of each element, the formula is used. Determine the mantissa of the target data format for each element.
[0095] Where F is the value of the mantissa of each element in the target data format, V is the absolute value of each element, k is the width of the mantissa in the target data format, and max... c This represents the maximum endpoint value of the corresponding numerical range.
[0096] It should be noted that when converting the original data format of each element of the target matrix to the target data format, the calculation logic for determining the mantissa of each element is the same as the calculation method of the mantissa in this embodiment. However, in actual operation, the mantissa of each element is obtained by shifting the floating-point number based on this calculation logic, which effectively improves the calculation time of the target data format conversion.
[0097] According to embodiments of this disclosure, the maximum endpoint value of the numerical range corresponding to each element, the digit width of the mantissa of the target data format, and the absolute value of each element can be used to accurately calculate the mantissa of the target data format corresponding to each element.
[0098] In one implementation, the target data format has a 16-bit (binary digit) width, including a 1-bit sign bit, a 2-bit exponent bit, and a 13-bit mantissa bit. The maximum value of the target matrix is taken as the maximum endpoint value, max0. Based on the 2-bit width of the exponent bit in the target data format, the numerical segments are divided into four consecutive numerical intervals, such as... Figure 3 As shown, it specifically includes:
[0099] The four numerical intervals are [0, max3], [max3, max2], [max2, max1], and [max1, max0].
[0100] When the absolute value of an element corresponds to a numerical range of [0, max3], that is, when the absolute value is less than max3, the mantissa of the target data format corresponding to the element...
[0101] When the absolute value of an element corresponds to a numerical range of [max3, max2], that is, max3 < absolute value ≤ max2, the mantissa of the target data format corresponding to the element.
[0102] When the absolute value of an element corresponds to a numerical range of [max2, max1], that is, max2 < absolute value ≤ max1, the mantissa of the target data format corresponding to the element.
[0103] When the absolute value of an element corresponds to a numerical range of [max1, max0], that is, max1 < absolute value ≤ max0, the mantissa of the target data format corresponding to the element.
[0104] In one implementation, step S1023: determining the sign bit of the target data format corresponding to each element based on the floating-point number of each element, including:
[0105] Based on the floating-point number of the element, if the value of the element is greater than or equal to 0, the sign bit of the target data format corresponding to the element is recorded as 0. If the value of the element is less than 0, the sign bit of the target data format corresponding to the element is recorded as 1.
[0106] This embodiment is for illustrative purposes only, and the reverse is also possible. That is, when the value of an element is ≥ 0, the sign bit of the target data format corresponding to the element is recorded as 1, and when the value of an element is < 0, the sign bit of the target data format corresponding to the element is recorded as 0.
[0107] It should be noted that the sign bit 1 and 0 are used to represent positive or negative numbers, respectively. Whether the sign bit is 1 represents a positive or negative number can be selected and adjusted as needed.
[0108] According to embodiments of this disclosure, such as Figure 4 As shown, a matrix processing method is provided, including:
[0109] Step S400: Perform a multiplication operation on the first target matrix and the second target matrix to obtain a third matrix. The data formats of both the first and second target matrices are target data formats, which are obtained according to the data format conversion method of any embodiment of this disclosure.
[0110] Step S401: Convert the data format of the third matrix into the preset standard data format according to the preset standard data format.
[0111] Based on the above embodiments of this disclosure, it should be noted that:
[0112] The first and second target matrices are matrices used by operators in the deep learning framework. Each first element and each second element is data obtained from feature extraction of image, speech, or text information.
[0113] According to embodiments of this disclosure, the matrix processing method can be executed by a multiplier. The data format conversion process of the first target matrix and the second target matrix is performed internally by the multiplier. The user is unaware of the data format conversion and only focuses on the input and output data of the multiplier. This method can achieve compatibility with different data without requiring the user to modify the data format of the input target matrix according to the multiplier, as the format conversion process is performed automatically within the multiplier.
[0114] The matrix processing method of this disclosure can be applied to computationally intensive operators in artificial intelligence models. This method enables the conversion of the data format of the input target matrix, thereby reducing the computational resource consumption of the operator. The computationally intensive operators described in this disclosure can be operators used during model training or operators used during inference after training. That is, the data format conversion method of this disclosure can be applied to both the model training process and the actual model inference process.
[0115] The matrix processing method of this disclosure can be applied to artificial intelligence chips, thereby improving their peak performance. When used for training and inference calculations of artificial intelligence models, the training and inference time can be significantly reduced.
[0116] In one example, the first and second target matrices are matrices used by operators in a deep learning framework. Operators in a deep learning framework can be high-precision operators used during model training, or operators used by the trained model during computation.
[0117] According to embodiments of this disclosure, using the target matrix after data format conversion for calculation can improve the computational efficiency of operators in the deep learning framework while saving computational resources.
[0118] In one example, the first and second elements can be data obtained by feature extraction from image information, voice information, or text information.
[0119] According to the embodiments of this disclosure, feature data extracted from image information, voice information, or text information can be converted into data formats, and the converted feature data can be used for post-processing, which can effectively improve the processing speed of image information, voice information, or text information.
[0120] In one example, such as Figure 5As shown, using the data format conversion method of any embodiment of this disclosure, a first target matrix in xfp16 data format is obtained by converting matrix A in fp16, bfloat16, or float data format. Also, using the data format conversion method of any embodiment of this disclosure, a second target matrix in xfp16 data format is obtained by converting matrix B in fp16, bfloat16, or float data format. Then, steps S400 and S401 of the matrix processing method are used to perform multiplication on the first and second target matrices. The calculated matrix is then converted according to a preset standard data format to obtain matrix C (i.e., the third matrix) in fp16, bfloat16, or float data format.
[0121] In one embodiment, the matrix processing method of this disclosure includes steps S400 and S401, wherein step S400: performing a multiplication operation on the first target matrix and the second target matrix to obtain a third matrix, specifically may include:
[0122] Based on the target data format corresponding to each first element in the first target matrix, determine the sign bit and mantissa bit of the target data format corresponding to each first element.
[0123] Based on the target data format corresponding to each second element in the second target matrix, determine the sign bit and mantissa bit of the target data format corresponding to each second element.
[0124] Based on the sign bit and mantissa bit of the target data format corresponding to each first element, and the sign bit and mantissa bit of the target data format corresponding to each second element, multiplication is performed on the first target matrix and the second target matrix to obtain the third matrix.
[0125] According to the embodiments of this disclosure, since the calculation process does not involve the exponent, the resources consumed by the multiplication operation of the first target matrix and the second target matrix are saved. At the same time, since the mantissa is used, the data accuracy of the elements of the obtained third matrix can be guaranteed.
[0126] In one embodiment, the matrix processing method of this disclosure includes steps S400 and S401, wherein in step S400, during the multiplication operation of the first target matrix and the second target matrix, the multiplication operation of the first element and the corresponding second element is performed using the formula c = F1 * F2 * S1 * S2.
[0127] Where F1 is the value of the mantissa of the target data format corresponding to the first element, F2 is the value of the mantissa of the target data format corresponding to the second element, S1 is the scaling factor for the fixed-to-floating-point conversion of the first element, and S2 is the scaling factor for the fixed-to-floating-point conversion of the second element.
[0128] According to embodiments of this disclosure, the first and second elements can be converted from fixed-point numbers to floating-point numbers using a scaling factor, which makes the data format conversion of the third matrix easier.
[0129] In one example, the scaling factor for the fixed-to-floating-point conversion of an element is determined based on the numerical range corresponding to the absolute values of the elements in the target matrix. Specifically, this can be achieved using the formula... Sure.
[0130] Where S is the fixed-to-floating-point conversion scaling factor for each element (S1, S2), k is the mantissa width of the target data format, and max... c This represents the maximum endpoint value of the corresponding numerical range.
[0131] In one example, the target data format has a 16-bit (binary digit) width, including a 1-bit sign bit, a 2-bit exponent bit, and a 13-bit mantissa bit. The maximum value of the target matrix is taken as the maximum endpoint, max0. Based on the 2-bit width of the exponent bit in the target data format, the numerical segments are divided into four consecutive numerical intervals, such as... Figure 3 As shown, it specifically includes:
[0132] The four numerical intervals are [0, max3], [max3, max2], [max2, max1], and [max1, max0].
[0133] When the absolute value of an element corresponds to a numerical range of [0, max3], that is, when the absolute value is less than max3, the mantissa of the target data format corresponding to the element... Element's fixed-to-floating conversion scaling factor
[0134] When the absolute value of an element corresponds to a numerical range of [max3, max2], that is, max3 < absolute value ≤ max2, the mantissa of the target data format corresponding to the element. Element's fixed-to-floating conversion scaling factor
[0135] When the absolute value of an element corresponds to a numerical range of [max2, max1], that is, max2 < absolute value ≤ max1, the mantissa of the target data format corresponding to the element. Element's fixed-to-floating conversion scaling factor
[0136] When the absolute value of an element corresponds to a numerical range of [max1, max0], that is, max1 < absolute value ≤ max0, the mantissa of the target data format corresponding to the element. Element's fixed-to-floating conversion scaling factor
[0137] In one embodiment, the matrix processing method of this disclosure includes steps S400 and S401, wherein in step S400, the sign of the multiplication result of the first element and the corresponding second element is determined by bitwise XORing the sign bit of the target data format corresponding to the first element and the sign bit of the target data format corresponding to the corresponding second element.
[0138] In one example, the data format conversion method and matrix processing method of this disclosure embodiment both include a quantization process of converting floating-point numbers to fixed-point numbers and a dequantization process of converting fixed-point numbers to floating-point numbers during execution. Specifically, the target data format converted from the original data format of the target matrix is floating-point data. The data format of the third matrix is converted to a preset standard data format, which is also floating-point data.
[0139] According to embodiments of this disclosure, such as Figure 6 As shown, a data format conversion apparatus is provided, comprising:
[0140] The first determining module 610 is used to determine the maximum value of the target matrix based on each element in the target matrix.
[0141] The second determining module 620 is used to determine multiple consecutive numerical intervals based on the digit width of the exponent in the target data format and the maximum value of the target matrix.
[0142] The first conversion module 630 is used to convert the original data format of the target matrix into the target data format according to the correspondence between each element and multiple numerical intervals, and the correspondence between multiple numerical intervals and the target data format.
[0143] In one implementation, the target data format has a bit width of 16 bits, including a sign bit with a bit width of 1 bit, an exponent bit with a bit width of 2 bits, and a mantissa bit with a bit width of 13 bits.
[0144] In one implementation, the first determining module 610 is used to:
[0145] Determine the absolute value of each element based on its floating-point number.
[0146] The largest absolute value among all elements is determined as the maximum value of the target matrix.
[0147] In one implementation, the second determining module 620 is used to:
[0148] The numerical line segment is determined by using the maximum value of the target matrix as the maximum endpoint value and 0 as the minimum endpoint value.
[0149] Based on the digit width of the exponent in the target data format, the numerical line segment is divided into continuous 2... N A range of values.
[0150] Based on the digit width of the mantissa in the target data format, use the formula Determine 2 respectively N The minimum endpoint value of each of the intervals.
[0151] Where N is the digit width of the exponent in the target data format, and max a The maximum endpoint value for each numerical interval, max b M represents the minimum endpoint value for each numerical interval, and M represents the mantissa width of the target data format.
[0152] In one implementation, the first conversion module 630 includes:
[0153] The first determining submodule is used to determine the exponent bits of the target data format corresponding to each element based on the correspondence between the floating-point number of each element and multiple numerical ranges, as well as the correspondence between multiple numerical ranges and the target data format.
[0154] The second determining submodule is used to determine the mantissa of the target data format corresponding to each element based on the correspondence between the floating-point number of each element and multiple numerical ranges, as well as the correspondence between multiple numerical ranges and the target data format.
[0155] The third determination submodule is used to determine the sign bit of the target data format corresponding to each element based on the floating-point number of each element.
[0156] The conversion submodule is used to convert the original data format of the target matrix into the target data format according to the sign bit, exponent bit, and mantissa bit of each element.
[0157] In one implementation, the first determining submodule is used to:
[0158] Determine the absolute value of each element based on its floating-point number.
[0159] Based on the absolute value of each element, determine the corresponding numerical range of each element in multiple numerical intervals.
[0160] Based on the correspondence between the corresponding numerical range and the exponent of the target data format, determine the exponent of each element in the target data format.
[0161] In one implementation, the second determining submodule is used to:
[0162] Determine the absolute value of each element based on its floating-point number.
[0163] Based on the absolute value of each element, determine the corresponding numerical range of each element in multiple numerical intervals.
[0164] Based on the maximum endpoint value of the corresponding numerical range, the digit width of the mantissa in the target data format, and the absolute value of each element, the formula is used. Determine the mantissa of the target data format for each element.
[0165] Where F is the value of the mantissa of each element in the target data format, V is the absolute value of each element, k is the width of the mantissa in the target data format, and max... c This represents the maximum endpoint value of the corresponding numerical range.
[0166] In one implementation, the target matrix is a matrix used by operators in a deep learning framework. Each element in the target matrix is data obtained by feature extraction from image, speech, or text information.
[0167] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.
[0168] According to embodiments of this disclosure, such as Figure 7 As shown, a matrix processing apparatus is provided, comprising:
[0169] The calculation module 710 is used to perform multiplication operations on the first target matrix and the second target matrix to obtain a third matrix. The data formats of the first target matrix and the second target matrix are both target data formats, which are obtained by the data format conversion method according to any one of claims 1 to 8.
[0170] as well as
[0171] The second conversion module 720 is used to convert the data format of the third matrix into a preset standard data format according to the preset standard data format.
[0172] In one implementation, the arithmetic module 710 is used for:
[0173] Based on the target data format corresponding to each first element in the first target matrix, determine the sign bit and mantissa bit of the target data format corresponding to each first element.
[0174] Based on the target data format corresponding to each second element in the second target matrix, determine the sign bit and mantissa bit of the target data format corresponding to each second element.
[0175] Based on the sign bit and mantissa bit of the target data format corresponding to each first element, and the sign bit and mantissa bit of the target data format corresponding to each second element, multiplication is performed on the first target matrix and the second target matrix to obtain the third matrix.
[0176] In one implementation, during the multiplication operation of the first target matrix and the second target matrix, the multiplication operation of the first element and the corresponding second element is performed using the formula c = F1 * F2 * S1 * S2.
[0177] Where F1 is the value of the mantissa of the target data format corresponding to the first element, F2 is the value of the mantissa of the target data format corresponding to the second element, S1 is the scaling factor for the fixed-to-floating-point conversion of the first element, and S2 is the scaling factor for the fixed-to-floating-point conversion of the second element.
[0178] In one implementation, the sign of the result of the multiplication operation between the first element and the corresponding second element is determined by bitwise XORing the sign bit of the target data format corresponding to the first element and the sign bit of the target data format corresponding to the second element.
[0179] In one implementation, the first target matrix and the second target matrix are matrices used by operators in a deep learning framework. Each first element and each second element is data obtained by feature extraction from image information, speech information, or text information.
[0180] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.
[0181] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0182] According to embodiments of this disclosure, Figure 8This is a schematic diagram of a distributed cluster processing scenario according to an embodiment of the present disclosure. The distributed cluster system is an example of a cluster system, and the diagram exemplarily describes how this distributed cluster system can be used for model training. The deep learning framework for model training can perform the data format conversion method and / or the matrix processing method of any of the above embodiments of the present disclosure using computationally intensive operators. This disclosure is not limited to model training on a single machine or multiple machines; using distributed processing can further improve the accuracy of model training. Figure 8 As shown, the distributed cluster system 800 includes multiple nodes (such as server cluster 801, server 802, server cluster 803, server 804, and server 805; server 805 can also connect to electronic devices, such as mobile phone 8051 and desktop computer 8052). Multiple nodes, as well as multiple nodes and connected electronic devices, can jointly execute one or more model training tasks. Optionally, the multiple nodes in this distributed cluster system can adopt a data-parallel model training method, in which case multiple nodes can execute model training tasks based on the same training method to better train the model; if the multiple nodes in this distributed cluster system adopt a model-parallel model training method, then multiple nodes can execute model training tasks based on different training methods to better train the model. Optionally, after each round of model training is completed, multiple nodes can exchange data (such as data synchronization).
[0183] According to embodiments of this disclosure, such as Figure 9 As shown, this disclosure also provides an artificial intelligence (AI) chip 900, including: an execution device for performing a data format conversion method and / or a matrix processing method of any of the above embodiments of this disclosure.
[0184] The AI chip 900 can be any AI chip in the existing technology, without specific limitations. This includes, but is not limited to, GPUs (graphics processing units), FPGAs (field-programmable gate arrays), and ASICs (application-specific integrated circuits).
[0185] According to embodiments of this disclosure, the peak performance of an artificial intelligence chip can be improved by using the data format conversion method and / or the matrix processing method of any of the above embodiments of this disclosure. When the artificial intelligence chip is applied to artificial intelligence model training and inference calculations, the training time and inference calculation time of the artificial intelligence model can be significantly shortened.
[0186] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0187] Figure 10 A schematic block diagram of an example electronic device 1000 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0188] like Figure 10 As shown, device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in read-only memory (ROM) 1002 or a computer program loaded from storage unit 1008 into random access memory (RAM) 1003. The RAM 1003 may also store various programs and data required for the operation of device 1000. The computing unit 1001, ROM 1002, and RAM 1003 are interconnected via bus 1004. Input / output (I / O) interface 1005 is also connected to bus 1004.
[0189] Multiple components in device 1000 are connected to I / O interface 1005, including: input unit 1006, such as a keyboard, mouse, etc.; output unit 1007, such as various types of displays, speakers, etc.; storage unit 1008, such as a disk, optical disk, etc.; and communication unit 1009, such as a network card, modem, wireless transceiver, etc. Communication unit 1009 allows device 1000 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0190] The computing unit 1001 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1001 performs the various methods and processes described above, such as methods for data format conversion and / or matrix processing. For example, in some embodiments, the methods for data format conversion and / or matrix processing may be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on device 1000 via ROM 1002 and / or communication unit 1009. When the computer program is loaded into RAM 1003 and executed by the computing unit 1001, one or more steps of the methods for data format conversion and / or matrix processing described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured by any other suitable means (e.g., by means of firmware) to perform methods of data format conversion and / or matrix processing.
[0191] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0192] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0193] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0194] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user. For example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0195] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0196] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0197] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0198] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for data format conversion, comprising: The maximum value of the target matrix is determined based on the elements of the target matrix used by the operators in the deep learning framework, wherein each element is data obtained by feature extraction of image information, speech information or text information; Using the maximum value of the target matrix as the maximum endpoint and 0 as the minimum endpoint, a numerical segment is determined; based on the digit width of the exponent in the target data format, the numerical segment is divided into two consecutive segments. N A numerical interval, where N is the digit width of the exponent in the target data format; based on the digit width of the mantissa in the target data format, the 2... N The minimum endpoint value of each of the intervals; and Based on the floating-point numbers of each element, determine the absolute value of each element and the sign bit of the target data format corresponding to each element; based on the absolute value of each element and the 2 N The minimum endpoint value of each of the 2 numerical intervals determines the element in the 2 N The numerical intervals are defined as follows: Based on the correspondence between the corresponding numerical intervals and the exponent bits of the target data format, the exponent bits of the target data format corresponding to each element are determined; based on the maximum endpoint value of the corresponding numerical interval, the digit width of the mantissa bits of the target data format, and the absolute value of each element, the mantissa bits of the target data format corresponding to each element are determined; based on the sign bit, exponent bit, and mantissa bits of the target data format corresponding to each element, the original data format of the target matrix is converted to the target data format.
2. The method according to claim 1, wherein, The target data format has a bit width of 16 bits, including a sign bit with a bit width of 1 bit, an exponent bit with a bit width of 2 bits, and a mantissa bit with a bit width of 13 bits.
3. The method according to claim 1 or 2, wherein, Determining the maximum value of the target matrix based on each element in the target matrix includes: Determine the absolute value of each element based on the floating-point number of each element in the target matrix; The largest absolute value among the elements is determined as the maximum value of the target matrix.
4. The method according to claim 1 or 2, wherein, The two are determined according to the digit width of the mantissa of the target data format. N The minimum endpoint value of each of the numerical intervals, including: Based on the digit width of the mantissa in the target data format, the formula is used. Determine the 2 respectively N The minimum endpoint value of each of the intervals of values; in, The maximum endpoint value for each of the given numerical intervals. M is the minimum endpoint value of each numerical interval, and M is the bit width of the mantissa of the target data format.
5. The method according to claim 1, wherein, The step of determining the mantissa of each element in the target data format based on the maximum endpoint value of the corresponding numerical interval, the digit width of the mantissa of the target data format, and the absolute value of each element includes: Based on the maximum endpoint value of the corresponding numerical interval, the digit width of the mantissa of the target data format, and the absolute value of each element, the formula is used... Determine the mantissa of the target data format corresponding to each element; Where F is the value of the mantissa of the target data format corresponding to each element. The absolute values of each element are given. The width of the mantissa in the target data format. This is the maximum endpoint value of the corresponding numerical range.
6. A matrix processing method, comprising: A third matrix is obtained by multiplying the first target matrix and the second target matrix; wherein the data formats of the first target matrix and the second target matrix are both target data formats, and the target data formats are obtained by the data format conversion method according to any one of claims 1 to 5; and The data format of the third matrix is converted into the preset standard data format according to the preset standard data format.
7. The method according to claim 6, wherein, The process of multiplying the first and second target matrices to obtain the third matrix includes: Based on the target data format corresponding to each first element in the first target matrix, determine the sign bit and mantissa bit of the target data format corresponding to each first element; Based on the target data format corresponding to each second element in the second target matrix, determine the sign bit and mantissa bit of the target data format corresponding to each second element; Based on the sign bit and mantissa bit of the target data format corresponding to each first element, and the sign bit and mantissa bit of the target data format corresponding to each second element, a multiplication operation is performed on the first target matrix and the second target matrix to obtain the third matrix.
8. The method according to claim 7, wherein, During the multiplication operation between the first target matrix and the second target matrix, the multiplication operation between the first element and the corresponding second element is performed using the formula c = F1*F2*S1*S2; Wherein, F1 is the value of the mantissa of the target data format corresponding to the first element, F2 is the value of the mantissa of the target data format corresponding to the second element, S1 is the fixed-to-floating-point conversion scaling factor of the first element, and S2 is the fixed-to-floating-point conversion scaling factor of the second element.
9. The method according to claim 8, wherein, The sign of the result of the multiplication operation between the first element and the corresponding second element is determined by bitwise XORing the sign bit of the target data format corresponding to the first element and the sign bit of the target data format corresponding to the second element.
10. The method according to any one of claims 7 to 9, wherein the first target matrix and the second target matrix are matrices used by operators in a deep learning framework; and each first element and each second element are data obtained by feature extraction of image information, speech information or text information.
11. An apparatus for data format conversion, comprising: The first determining module is used to determine the maximum value of the target matrix based on each element of the target matrix used by the operator in the deep learning framework, wherein each element is data obtained by feature extraction of image information, speech information or text information; The second determining module is used to determine numerical segments using the maximum value of the target matrix as the maximum endpoint value and 0 as the minimum endpoint value; and to divide the numerical segments into continuous 2^n segments according to the digit width of the exponent in the target data format. N A numerical interval, where N is the digit width of the exponent in the target data format; based on the digit width of the mantissa in the target data format, the 2... N The minimum endpoint value of each of the intervals; and The first conversion module is used to determine the absolute value of each element and the sign bit of the target data format corresponding to each element based on the floating-point number of each element; based on the absolute value of each element and the 2 N The minimum endpoint value of each of the 2 numerical intervals determines the element in the 2 N The numerical intervals are defined as follows: Based on the correspondence between the corresponding numerical intervals and the exponent bits of the target data format, the exponent bits of the target data format corresponding to each element are determined; based on the maximum endpoint value of the corresponding numerical interval, the digit width of the mantissa bits of the target data format, and the absolute value of each element, the mantissa bits of the target data format corresponding to each element are determined; based on the sign bit, exponent bit, and mantissa bits of the target data format corresponding to each element, the original data format of the target matrix is converted to the target data format.
12. The apparatus according to claim 11, wherein, The target data format has a bit width of 16 bits, including a sign bit with a bit width of 1 bit, an exponent bit with a bit width of 2 bits, and a mantissa bit with a bit width of 13 bits.
13. The apparatus according to claim 11 or 12, wherein, The first determining module is used for: Determine the absolute value of each element based on the floating-point number of each element in the target matrix; The largest absolute value among the elements is determined as the maximum value of the target matrix.
14. The apparatus according to claim 11 or 12, wherein, The two are determined according to the digit width of the mantissa of the target data format. N The minimum endpoint value of each of the numerical intervals, including: Based on the digit width of the mantissa in the target data format, the formula is used. Determine the 2 respectively N The minimum endpoint value of each of the intervals of values; in, The maximum endpoint value for each of the given numerical intervals. M is the minimum endpoint value of each numerical interval, and M is the bit width of the mantissa of the target data format.
15. The apparatus according to claim 11, wherein, The step of determining the mantissa of each element in the target data format based on the maximum endpoint value of the corresponding numerical interval, the digit width of the mantissa of the target data format, and the absolute value of each element includes: Based on the maximum endpoint value of the corresponding numerical interval, the digit width of the mantissa of the target data format, and the absolute value of each element, the formula is used... Determine the mantissa of the target data format corresponding to each element; Where F is the value of the mantissa of the target data format corresponding to each element. The absolute values of each element are given. The width of the mantissa in the target data format. This is the maximum endpoint value of the corresponding numerical range.
16. A matrix processing apparatus, comprising: The computation module is used to perform multiplication operations on the first target matrix and the second target matrix to obtain a third matrix; wherein the data formats of the first target matrix and the second target matrix are both target data formats, and the target data formats are obtained by the data format conversion method according to any one of claims 1 to 5; and The second conversion module is used to convert the data format of the third matrix into the preset standard data format according to the preset standard data format.
17. The apparatus according to claim 16, wherein, The computing module is used for: Based on the target data format corresponding to each first element in the first target matrix, determine the sign bit and mantissa bit of the target data format corresponding to each first element; Based on the target data format corresponding to each second element in the second target matrix, determine the sign bit and mantissa bit of the target data format corresponding to each second element; Based on the sign bit and mantissa bit of the target data format corresponding to each first element, and the sign bit and mantissa bit of the target data format corresponding to each second element, a multiplication operation is performed on the first target matrix and the second target matrix to obtain the third matrix.
18. The apparatus according to claim 17, wherein, During the multiplication operation between the first target matrix and the second target matrix, the multiplication operation between the first element and the corresponding second element is performed using the formula c = F1*F2*S1*S2; Wherein, F1 is the value of the mantissa of the target data format corresponding to the first element, F2 is the value of the mantissa of the target data format corresponding to the second element, S1 is the fixed-to-floating-point conversion scaling factor of the first element, and S2 is the fixed-to-floating-point conversion scaling factor of the second element.
19. The apparatus according to claim 18, wherein, The sign of the result of the multiplication operation between the first element and the corresponding second element is determined by bitwise XORing the sign bit of the target data format corresponding to the first element and the sign bit of the target data format corresponding to the second element.
20. The apparatus according to any one of claims 17 to 19, wherein, The first target matrix and the second target matrix are matrices used by operators in a deep learning framework; each first element and each second element is data obtained by feature extraction from image information, speech information, or text information.
21. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 10.
22. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 10.
23. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 10.
24. An artificial intelligence chip, comprising: An execution device for performing the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
GPU-based floating-point number conversion method and device
CN107038016A
Floating-point number conversion method and device
CN111340207A