A method, device, equipment and storage medium for processing data in a function

By allocating elements to single-instruction multi-data streams and single-instruction single-data streams for processing in the RELU function, the problem of slow computing speed in the prior art is solved, and the computing speed and user experience are improved.

CN112346782BActive Publication Date: 2024-12-13TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910726018.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-07
Publication Date
2024-12-13
Estimated Expiration
2039-10-09

AI Technical Summary

Technical Problem

In the prior art, the RELU function based on single instruction and single data stream is slow to calculate, resulting in increased delays and poor user experience in key areas such as online services.

Method used

By determining the number of element bits in the input vector and the number of processed data bits for a single instruction multi-data stream, the elements are allocated to a single instruction multi-data stream and a single instruction single-data stream for processing, improving data processing efficiency.

Benefits of technology

It significantly improves the computing speed of RELU functions, reduces delays, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112346782B_ABST
    Figure CN112346782B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, equipment and storage medium for processing data in a function, the method comprising: determining a vector in an input target function; determining the number of elements processed by the single instruction multiple data stream at a time based on the number of bits of a single element in the vector and the number of bits of data processed at a time by the single instruction multiple data stream; determining a first element set and a second element set in the vector based on the number of elements in the vector and the number of elements processed at a time by the single instruction multiple data stream; the ratio of the sum of the number of elements in the first element set to the number of elements processed at a time by the single instruction multiple data stream is a positive integer; processing the first element set based on the single instruction multiple data stream; processing the second element set based on the single instruction single data stream. The technical solution of the present application is adopted to improve the processing efficiency of data in the elements, thereby improving the operation speed of the function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment and storage medium for processing data in a function. Background Art

[0002] The RELU function is a core function in deep learning, and its speed is crucial. At present, the RELU functions known in the prior art are all implemented using Single Instruction Single Data (SISD) instructions. The SISD instruction processes one element in the input vector at a time until all elements in the vector are processed.

[0003] The calculation speed of the RELU function based on the SISD instruction is slow. When the RELU function is executed in key areas, such as online services, the slower speed means greater delays, more timeout failures, and worse user experience.

[0004] Therefore, it is necessary to provide a data processing method, device, equipment and storage medium that can improve the function operation speed. Summary of the invention

[0005] The present application provides a method, device, equipment and storage medium for processing data in a function, which can improve the processing efficiency of data in an element, thereby increasing the operation speed of the function and improving the user experience.

[0006] On the one hand, the present application provides a method for processing data in a function, the method comprising:

[0007] Determine the vector in the input objective function;

[0008] Determine the number of elements to be processed at a single time by the single instruction multiple data stream based on the number of bits of a single element in the vector and the number of bits of data to be processed at a single time by the single instruction multiple data stream;

[0009] Based on the number of elements in the vector and the number of elements processed at a single time by the SIMD stream, determine a first element set and a second element set in the vector; the ratio of the sum of the number of elements in the first element set to the number of elements processed at a single time by the SIMD stream is a positive integer, and the second element set is a set of elements in the vector excluding the first element set;

[0010] Processing the first set of elements based on the single instruction multiple data stream;

[0011] The second set of elements is processed based on a single instruction single data flow.

[0012] Another aspect provides a device for processing data in a function, the device comprising:

[0013] A vector determination module is used to determine the vector in the input target function;

[0014] A single-processing element number determination module, used to determine the number of elements processed at a single time by the single instruction multiple data stream based on the number of bits of a single element in the vector and the number of bits of data processed at a single time by the single instruction multiple data stream;

[0015] an element set determination module, configured to determine a first element set and a second element set in the vector based on the number of elements in the vector and the number of elements processed at a single time by the single instruction multiple data stream; the ratio of the sum of the number of elements in the first element set to the number of elements processed at a single time by the single instruction multiple data stream is a positive integer, and the second element set is a collection of elements in the vector excluding the first element set;

[0016] A first element set processing module, configured to process the first element set based on the single instruction multiple data stream;

[0017] The second element set processing module is used to process the second element set based on a single instruction single data stream.

[0018] On the other hand, a device for processing data in a function is provided, the device comprising a processor and a memory, the memory storing at least one instruction, at least one program, a code set or an instruction set, the at least one instruction, the at least one program, the code set or the instruction set being loaded and executed by the processor to implement the method for processing data in a function as described above.

[0019] On the other hand, a computer-readable storage medium is provided, in which at least one instruction, at least one program, a code set or an instruction set is stored, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the data processing method in the function as described above.

[0020] The data processing method, device, equipment and storage medium in the function provided by this application have the following technical effects:

[0021] The present application determines the number of elements that can be processed at one time by a single instruction multiple data stream based on the number of bits of a single element in the input vector of the function and the number of bits of data processed at one time by the single instruction multiple data stream; then, based on the total number of elements in the vector, determines the number of elements allocated to the single instruction multiple data stream, and allocates the remaining elements to the single instruction single data stream for processing; based on the fact that a single instruction multiple data stream can process multiple elements at one time, the scheme of the present application is used to improve the processing efficiency of the data in the elements, thereby improving the calculation speed of the function and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0023] Figure 1 is a schematic diagram of a data processing system in a function provided by an embodiment of the present application;

[0024] Figure 2 It is a flowchart of a method for processing data in a function provided by an embodiment of the present application;

[0025] Figure 3 It is a flowchart of a method for determining the number of elements processed at a single instruction multiple data stream in an embodiment of the present application;

[0026] Figure 4 is a flowchart of a method for determining a first element set and a second element set in the vector provided by an embodiment of the present application;

[0027] Figure 5 is a flowchart of another method for determining the first element set and the second element set in the vector provided by an embodiment of the present application;

[0028] Figure 6 is a flowchart of a method for determining a first number of elements in the first element set provided in an embodiment of the present application;

[0029] Figure 7 is a flowchart of a method for processing the first element set based on the single instruction multiple data stream provided in an embodiment of the present application;

[0030] Figure 8 is a flowchart of a method for determining multiple element groups provided in an embodiment of the present application;

[0031] Fig. 9 It is a flowchart of a method for processing data in a vector provided in an embodiment of the present application;

[0032] Fig.10 is a structural schematic diagram of a data processing device in a function provided by an embodiment of the present application;

[0033] Fig.11 is a structural diagram of an element set determination module provided in an embodiment of the present application;

[0034] Fig.12 It is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0037] See also Figure 1 , Figure 1 is a schematic diagram of a data processing system in a function provided by an embodiment of the present application, such as Figure 1 As shown, the data processing system in this function may include at least a server 01 and a client 02 .

[0038] Specifically, in the embodiments of this specification, the server 01 may include an independently operated server, a distributed server, or a server cluster composed of multiple servers. The server 01 may include a network communication unit, a processor, a memory, etc. Specifically, the server 01 may be used to receive the information query request sent by the client 02, and use a function to perform data processing to obtain query information.

[0039] Specifically, in the embodiments of this specification, the client 02 may include physical devices such as smart phones, desktop computers, tablet computers, laptops, digital assistants, smart wearable devices, etc., and may also include software running in physical devices, such as web pages provided by some service providers to users, or applications provided by these service providers to users. Specifically, the client 02 may be used to send information query requests to the server 01.

[0040] The following describes a method for processing data in a function of the present application. Figure 2It is a flowchart of a method for processing data in a function provided by an embodiment of the present application. This specification provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or server product is executed, it can be executed in sequence or in parallel (for example, in a parallel processor or multi-threaded processing environment) according to the method shown in the embodiment or the accompanying drawings. Specifically, Figure 2 As shown, the method may include:

[0041] S201: Determine the vector in the input objective function.

[0042] In the embodiments of the present specification, the objective function may be a rectified linear unit (ReLU), also known as a rectified linear unit, which is an activation function commonly used in artificial neural networks, usually referring to a nonlinear function represented by a ramp function and its variants.

[0043] In the embodiment of this specification, the objective function may include one vector or multiple vectors.

[0044] S203: Determine the number of elements to be processed at a single time by the SIMD stream based on the number of bits of a single element in the vector and the number of bits of data to be processed at a single time by the SIMD stream.

[0045] In the embodiments of this specification, Single Instruction Multiple Data (SIMD) refers to a type of instruction set that can process multiple data elements simultaneously in a single instruction cycle, using data-level parallelism to improve operating efficiency. The usage environment of this type of instruction is to perform the same processing on multiple data, so the typical application scenario is the multimedia field, especially in the encoding and decoding process therein.

[0046] Single instruction multiple data means that only one instruction cycle is needed to batch process multiple data at the same time. Although the instruction cycle of this type of instruction itself may be longer than that of general instructions, the overall consideration improves the data processing efficiency.

[0047] In the embodiments of this specification, Figure 3 As shown, the determining the number of elements processed at a single time by the single instruction multiple data stream based on the number of bits of a single element in the vector and the number of bits of data processed at a single time by the single instruction multiple data stream may include:

[0048] S2031: Determine the number of bits of a single element in the vector;

[0049] S2033: Calculate the ratio of the number of bits of data processed at a time by the SIMD stream to the number of bits of a single element in the vector, and obtain the number of elements processed at a time by the SIMD stream.

[0050] In the embodiment of the present specification, the types of the elements in the vector are the same, and the number of bits of the elements is also the same. The number of bits of a single element in the vector can be the number of binary bits of the element, for example, the number of bits of an element of type single-precision floating point number is 32 bits, and the number of bits of an element of type double-precision floating point number is 64 bits; the SIMD instruction can include an asm_max instruction, and the number of data bits that can be processed by the asm_max instruction at one time can be 128, 256, 512, ...

[0051] In some embodiments, the element type T of the vector is a single-precision (float, 32 bits) or double-precision (double, 64 bits) floating point number, and b1 is used to represent the binary digit number of a T element, then b1 is 32 or 64. Fig. 9 As shown, the asm_max instruction can process b2 bits of data at a time, and b2 can be 128, 256, 512, ... Obviously, b = b2 / b1 is the number of T elements that the asm_max instruction can process at a time, and b must be an integer power of 2. b is the number of elements that the SIMD flow processes at a time.

[0052] S205: Based on the number of elements in the vector and the number of elements processed at a single time by the SIMD stream, determine a first element set and a second element set in the vector; the ratio of the sum of the number of elements in the first element set to the number of elements processed at a single time by the SIMD stream is a positive integer, and the second element set is a set of elements in the vector excluding the first element set.

[0053] In the embodiments of this specification, Figure 4 As shown, determining the first set of elements and the second set of elements in the vector based on the number of elements in the vector and the number of elements processed at a single time by the SIMD stream may include:

[0054] S2051: Divide the number of elements in the vector by the number of elements processed at a time by the SIMD stream to obtain a quotient and a remainder of the elements;

[0055] S2053: Determine a first number of elements in the first element set based on the quotient of the element and the number of elements processed at a single time by the SIMD stream;

[0056] S2055: Using the remainder of the element as the second number of elements in the second element set;

[0057] In the embodiment of the present specification, the remainder of the element is less than the number of elements processed at a single time by the SIMD stream.

[0058] In the embodiment of this specification, the second number may also be determined according to the first number, and the second number is obtained by subtracting the first number from the total number of elements in the vector.

[0059] S2057: Determine a first element set and a second element set in the vector based on the first number and the second number.

[0060] In some embodiments, Figure 5 As shown, determining the first element set and the second element set in the vector based on the first number and the second number may include:

[0061] S20571: assemble a first number of elements in the vector that are ranked first into the first element set;

[0062] S20573: Organize a second number of elements sorted later in the vector into the second element set.

[0063] In some embodiments, a second element set may be determined based on the first element set, and the elements in the vector other than the first element set may be combined into the second element set.

[0064] In some embodiments, the first number of elements at any position in the vector may be used to form the first element set, and the elements at the remaining positions may be used to form the second element set. For example, the first number of elements that are adjacent to each other may be used, or the elements that are spaced may be used; and the positions of the elements in the first element set may be determined according to actual conditions while ensuring the number of elements in the first element set.

[0065] In the embodiment of the present specification, a first number of elements in the vector that are ranked later may be combined into the first element set, and correspondingly, a second number of elements in the vector that are ranked earlier may be combined into the second element set.

[0066] In some embodiments, Figure 6 As shown, determining the first number of elements in the first element set based on the quotient of the element and the number of elements processed at a single time by the SIMD stream may include:

[0067] S20531: Calculate the product of the quotient of the element and the number of elements processed at a single time by the SIMD flow;

[0068] S20533: Taking the product of the quotient of the elements and the number of elements processed at a single time by the SIMD stream as the first number of elements in the first element set.

[0069] S207: Process the first element set based on the single instruction multiple data stream.

[0070] In the embodiments of this specification, Figure 7 As shown, the objective function is used to determine a larger value of elements corresponding to the same position in the first vector and the second vector, the first vector and the second vector have the same length, and the processing of the first element set based on the single instruction multiple data stream may include:

[0071] S2071: Determine a plurality of element groups based on a first element set in the first vector and a first element set in the second vector;

[0072] S2073: Based on the SIMD stream, the elements with larger values ​​in each element group are grouped into a third element set.

[0073] In a specific embodiment, Fig. 9 As shown in the figure, 03 is the data corresponding to the elements in the first vector, and 04 is the data corresponding to the elements in the second vector. The asm_max instruction is used to process the first element set in the two vectors. The number of bits of data processed by the asm_max instruction at a time is b2. The number of data in the first element set is an integer multiple of b2. The elements in the vector other than the first element set (the second element set) are all processed by a single instruction single data stream (Single Instruction Single Data, SISD). SISD is a type of CPU instruction set. One SISD instruction can process one data. The number of executions of the SISD instruction is determined by the number of bits of data in the first element set.

[0074] In the embodiment of the present specification, when the remainder of the element is 0, all elements in the vector can be processed by SIMD, and SISD does not need to process any data.

[0075] In the embodiments of this specification, SIMD and SISD are combined to process data according to the number of bits of data in the vector. Based on the characteristic of SIMD that multiple data can be processed at a time, SIMD is used in the function to process data, which improves the data processing efficiency and thus speeds up the function's operation speed.

[0076] In some embodiments, Figure 8 As shown, determining a plurality of element groups based on the first element set in the first vector and the first element set in the second vector may include:

[0077] S20711: Obtain two elements in the first element set in the first vector and in the first element set in the second vector that are located at the same position;

[0078] S20713: Take the two elements at the same position as an element group.

[0079] In the embodiments of this specification, the SIMD can process the data in one or more element groups at a time.

[0080] S209: Process the second element set based on single instruction single data stream.

[0081] In the embodiments of this specification, the single instruction single data stream can only process one data in the element at a time.

[0082] In some embodiments, the RELU function can be: y = max(x, 0);

[0083] Input: A vector x of type T and length n bytes;

[0084] Output: A vector y of type T and length n bytes.

[0085] The data processing method in the function can be implemented by the following code of Version 1.

[0086] Version 1:

[0087] 1. Initialize a vector y of length n bytes

[0088] 2. Initialize a zero vector zero of length b bytes

[0089] 3. i = 0 (where i is an integer variable)

[0090] 4. n1 = n % b (where n1 is the remainder of n divided by b, here n refers to the length of vector x, and n in the following code has the same meaning as n here, n1 < b)

[0091] 5. for (i = 0; i < n1; i = i + b) (where i = 0 is the loop start condition; i < n1 is used to limit the loop termination condition, when this condition is not met, the loop exits; i = i + b means that each time the loop is executed, i is incremented by b)

[0092] 6. y[i:i + b] = asm_max(x[i:i + b], zero) (where asm_max here is a SIMD instruction, and x[i:i + b] refers to the i-th byte to the (i + b - 1)-th byte in x)

[0093] 7. endfor

[0094] 8. for (; i < n; i = i + 1) (where i < n is used to limit the loop termination condition, when this condition is not met, the loop exits; i = i + 1 means that each time the loop is executed, i is incremented by 1)

[0095] 9. y[i] = asm_max(x[i], 0) (where asm_max here is an SISD instruction)

[0096] 10. endfor

[0097] 11. Return y.

[0098] In some other embodiments, the data processing method in the function can also be loop-unrolled, unrolled k-way, where k is a non - negative integer power of 2; the value of k can be determined according to the number of registers in the central processing unit (CPU), with a larger number of registers corresponding to a larger k value and a smaller number of registers corresponding to a smaller k value; all available registers are utilized; the data processing method in the function can be implemented using the following code of Version 2.

[0099] Version 2:

[0100] 1. Initialize a vector y of length n bytes;

[0101] 2. Initialize a zero vector zero of length b bytes;

[0102] 3. i = 0; (where i is an integer variable)

[0103] 4. n1 = n % (b * k) (where n1 is the remainder of n divided by b * k, n here refers to the length of vector x, and n in the following code has the same meaning as n here, n1 < b * k)

[0104] 5. for (i = 0; i < n1; i = i + b * k) (where i = 0 refers to the loop start condition; i < n1 is used to limit the loop termination condition, and when this condition is not met, the loop exits; i = i + b * k means that each time the loop is executed, i is incremented by b * k)

[0105] 6. y[i:i + b] = asm_max(x[i:i + b], zero) (where asm_max here is an SIMD instruction, and x[i:i + b] refers to the bytes from the i - th byte to the (i + b - 1)-th byte in x)

[0106] 7. y[i + b:i + b * 2] = asm_max(x[i + b:i + b * 2], zero) (where asm_max here is an SIMD instruction, and x[i + b:i + b * 2] refers to the bytes from the (i + b)-th byte to the (i + b * 2 - 1)-th byte in x)

[0107] 8. y[i + b * 2:i + b * 3] = asm_max(x[i + b * 2:i + b * 3], zero) (where asm_max here is a SIMD instruction, and x[i + b * 2:i + b * 3] refers to the bytes from the (i + b * 2)-th byte to the (i + b * 3 - 1)-th byte in x)

[0108] 9....

[0109] 10. y[i + b * (k - 1):i + b * k] = asm_max(x[i + b * (k - 1):i + b * k], zero) (where asm_max here is a SIMD instruction, and x[i + b * (k - 1):i + b * k] refers to the bytes from the (i + b * (k - 1))-th byte to the (i + b * k - 1)-th byte in x)

[0110] 11. endfor

[0111] 12. for(; i < n; i = i + 1) (where i < n is used to limit the loop termination condition, and when this condition is not met, the loop exits; i = i + 1 means that each time the loop is executed, i needs to be incremented by 1)

[0112] 13. y[i] = asm_max(x[i], 0) (where asm_max here is a SISD instruction)

[0113] 14. endfor

[0114] 15. Return y.

[0115] Among them, Version 1 calls the SIMD instruction once, and Version 2 calls the SIMD instruction multiple times; if Step 5 of Version 1 needs to be executed m times, Step 5 of Version 2 only needs to be executed m / k times, and the time consumption is less; it can be seen that the time spent by Version 2 on loop control is 1 / k of that of Version 1; since the number of executions in the loop body of both is the same, that is, the execution time of Step 6 of Version 1 is the same as that of Steps 6 - 10 of Version 2; therefore, Version 2 is faster.

[0116] In a specific embodiment, according to the different dimensions of the input vector and the floating-point type, the SIMD-based double-precision RELU function is 3 - 8 times faster than the SISD-based RELU function in terms of calculation speed. For example, in a look-and-recommend service, compared with the prior art, adopting the technical solution of this application reduces the backend latency by about 5 milliseconds.

[0117] It can be seen from the technical solutions provided in the above embodiments of this specification that the embodiments of this specification determine the number of elements that can be processed at one time by a single instruction multiple data stream based on the number of bits of a single element in the input vector of the function and the number of bits of data processed at one time by the single instruction multiple data stream; then, combined with the total number of elements in the vector, the number of elements allocated to the single instruction multiple data stream is determined, and the remaining elements are allocated to the single instruction single data stream for processing; based on the fact that a single instruction multiple data stream can process multiple elements at one time, the solution of the present application is used to improve the processing efficiency of data in the elements, thereby improving the calculation speed of the function and enhancing the user experience.

[0118] The present application also provides a data processing device in a function, such as Fig.10 As shown, the device may include:

[0119] A vector determination module 1010 is used to determine a vector in an input objective function;

[0120] A single-processing element number determination module 1020 is used to determine the number of elements that the single instruction multiple data stream processes at a time based on the number of bits of a single element in the vector and the number of bits of data that the single instruction multiple data stream processes at a time;

[0121] An element set determination module 1030 is used to determine a first element set and a second element set in the vector based on the number of elements in the vector and the number of elements processed at a single time by the single instruction multiple data stream; the ratio of the sum of the number of elements in the first element set to the number of elements processed at a single time by the single instruction multiple data stream is a positive integer, and the second element set is a set of elements in the vector except the first element set;

[0122] A first element set processing module 1040, configured to process the first element set based on the single instruction multiple data stream;

[0123] The second element set processing module 1050 is configured to process the second element set based on a single instruction single data flow.

[0124] In some embodiments, the module for determining the number of elements processed at a single time may include:

[0125] An element bit determination unit, used to determine the number of bits of a single element in the vector;

[0126] The element number determination unit is used to calculate the ratio of the number of data bits processed at a single time by the SIMD stream to the number of bits of a single element in the vector, so as to obtain the number of elements processed at a single time by the SIMD stream.

[0127] In some embodiments, Fig.11 As shown, the element set determination module may include:

[0128] A quotient and remainder determination unit 1110, configured to divide the number of elements in the vector by the number of elements processed at a single time by the SIMD stream to obtain a quotient and a remainder of the element;

[0129] A first number determining unit 1120, configured to determine a first number of elements in the first element set based on a quotient of the elements and the number of elements processed at a single time by the SIMD stream;

[0130] A second number determining unit 1130, configured to use the remainder of the element as a second number of elements in the second element set;

[0131] The element set determining unit 1140 is configured to determine a first element set and a second element set in the vector based on the first number and the second number.

[0132] In some embodiments, the element set determination unit may include:

[0133] A first element set determination subunit, configured to form the first element set from a first number of elements that are ranked first in the vector;

[0134] The second element set determination subunit is used to form the second element set from a second number of elements that are sorted later in the vector.

[0135] In some embodiments, the first quantity determining unit may include:

[0136] a product calculation subunit, for calculating the product of the quotient of the element and the number of elements processed at a single time by the SIMD stream;

[0137] The first quantity determination subunit is used to take the product of the quotient of the elements and the number of elements processed at a single time by the SIMD stream as the first quantity of elements in the first element set.

[0138] In some embodiments, the objective function is used to determine a larger value of elements corresponding to the same position in the first vector and the second vector, the first vector and the second vector have the same length, and the first element set processing module may include:

[0139] an element group determining unit, configured to determine a plurality of element groups based on a first element set in the first vector and a first element set in the second vector;

[0140] The third element set determination unit is used to form a third element set from elements with larger values ​​in each element group based on the single instruction multiple data stream.

[0141] In some embodiments, the element group determination unit may include:

[0142] An element acquisition subunit, used to acquire two elements located at the same position in the first element set in the first vector and the first element set in the second vector;

[0143] The element group determination subunit is used to regard the two elements located at the same position as an element group.

[0144] The device and method embodiments in the described device embodiments are based on the same inventive concept.

[0145] An embodiment of the present application provides a device for processing data in a function, the device comprising a processor and a memory, the memory storing at least one instruction, at least one program, a code set or an instruction set, the at least one instruction, the at least one program, the code set or the instruction set being loaded and executed by the processor to implement a method for processing data in a function as provided in the above method embodiment.

[0146] An embodiment of the present application also provides a computer-readable storage medium, which can be set in a server to store at least one instruction, at least one program, a code set or an instruction set related to a data processing method in a function in a method embodiment. The at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the data processing method in the function provided by the above method embodiment.

[0147] Optionally, in the embodiments of this specification, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0148] The memory described in the embodiments of this specification can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, application programs required for functions, etc.; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.

[0149] The data processing method embodiment of the function provided in the embodiment of the present application can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking running on a server as an example, Fig.12 1 is a hardware structure diagram of a server of a method for processing data in a function provided by an embodiment of the present application. Fig.12 As shown, the server 1200 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1210 (the processor 1210 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1230 for storing data, and one or more storage media 1220 (such as one or more mass storage devices) for storing application programs 1223 or data 1222. Among them, the memory 1230 and the storage medium 1220 can be short-term storage or permanent storage. The program stored in the storage medium 1220 may include one or more modules, each of which may include a series of instruction operations on the server. Furthermore, the central processing unit 1210 can be configured to communicate with the storage medium 1220 and execute a series of instruction operations in the storage medium 1220 on the server 1200. The server 1200 may also include one or more power supplies 1260, one or more wired or wireless network interfaces 1250, one or more input and output interfaces 1240, and / or one or more operating systems 1221, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0150] The input / output interface 1240 may be used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the server 1200. In one example, the input / output interface 1240 includes a network adapter (Network Interface Controller, NIC), which may be connected to other network devices via a base station so as to communicate with the Internet. In one example, the input / output interface 1240 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0151] It can be understood by those skilled in the art that Fig.12 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig.12 More or fewer components as shown, or with Fig.12 Different configurations shown.

[0152] It can be seen from the embodiments of the data processing method, device, equipment or storage medium in the function provided by the above-mentioned application that the application determines the number of elements that can be processed at one time by a single instruction multiple data stream based on the number of bits of a single element in the input vector of the function and the number of bits of data processed at a single time by the single instruction multiple data stream; then, combined with the total number of elements in the vector, the number of elements allocated to the single instruction multiple data stream is determined, and the remaining elements are allocated to the single instruction single data stream for processing; based on the fact that a single instruction multiple data stream can process multiple elements at a time, the scheme of the application is adopted to improve the processing efficiency of the data in the elements, thereby improving the calculation speed of the function and improving the user experience.

[0153] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of this specification are described. Other embodiments are within the scope of the attached claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0154] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0155] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0156] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for processing data in a function, characterized in that: The method comprises: Determine the vectors in the input objective function; Determine the number of elements to be processed at a single time by the single instruction multiple data stream based on the number of bits of a single element in the vector and the number of bits of data to be processed at a single time by the single instruction multiple data stream; Dividing the number of elements in the vector by the number of elements processed at a single time by the SIMD stream, to obtain a quotient and a remainder of the elements; Determining a first number of elements in a first set of elements based on a quotient of the elements and a number of elements processed at a single time by the SIMD stream; taking the remainder of the element as the second number of elements in the second set of elements; Based on the first number and the second number, determine a first element set and a second element set in the vector; the ratio of the sum of the number of elements in the first element set to the number of elements processed at a single time by the SIMD stream is a positive integer, and the second element set is a set of elements in the vector excluding the first element set; Processing the first set of elements based on the single instruction multiple data stream; The second set of elements is processed based on a single instruction single data flow.

2. The method according to claim 1, characterized in that The determining the number of elements processed at a single time by the single instruction multiple data stream based on the number of bits of a single element in the vector and the number of bits of data processed at a single time by the single instruction multiple data stream comprises: determining the number of bits of a single element in the vector; The ratio of the number of data bits processed at a single time by the SIMD stream to the number of bits of a single element in the vector is calculated to obtain the number of elements processed at a single time by the SIMD stream.

3. The method according to claim 1, characterized in that The determining, based on the first number and the second number, a first set of elements and a second set of elements in the vector comprises: Form the first element set from a first number of elements in the vector that are ranked first; A second number of elements that are sorted later in the vector form the second element set.

4. The method according to claim 1, characterized in that: Determining the first number of elements in the first element set based on the quotient of the element and the number of elements processed at a single time by the SIMD stream comprises: Calculate the product of the quotient of the element and the number of elements processed at a single time by the SIMD stream; The product of the quotient of the elements and the number of elements processed at a single time by the SIMD stream is used as the first number of elements in the first element set.

5. The method according to claim 1, characterized in that: The objective function is used to determine a larger value of elements corresponding to the same position in the first vector and the second vector, the first vector and the second vector have the same length, and the processing of the first element set based on the single instruction multiple data stream includes: determining a plurality of element groups based on a first set of elements in the first vector and a first set of elements in the second vector; Based on the SIMD stream, elements with larger values ​​in each element group are grouped into a third element set.

6. The method according to claim 5, characterized in that The determining a plurality of element groups based on the first element set in the first vector and the first element set in the second vector comprises: Obtain two elements located at the same position in the first element set in the first vector and the first element set in the second vector; The two elements located at the same position are regarded as an element group.

7. A data processing device in a function, characterized in that: The device comprises: A vector determination module, used to determine the vector in the input objective function; A single-processing element number determination module, used to determine the number of elements processed at a single time by the single instruction multiple data stream based on the number of bits of a single element in the vector and the number of bits of data processed at a single time by the single instruction multiple data stream; an element set determination module, configured to determine a first element set and a second element set in the vector based on the number of elements in the vector and the number of elements processed at a single time by the single instruction multiple data stream; the ratio of the sum of the number of elements in the first element set to the number of elements processed at a single time by the single instruction multiple data stream is a positive integer, and the second element set is a collection of elements in the vector excluding the first element set; A first element set processing module, configured to process the first element set based on the single instruction multiple data stream; A second element set processing module, used for processing the second element set based on a single instruction single data stream; The element set determination module includes: a quotient and remainder determination unit, used to divide the number of elements in the vector by the number of elements processed at a single time by the single instruction multiple data stream to obtain the quotient and remainder of the element; a first quantity determination unit, used to determine the first number of elements in the first element set based on the quotient of the element and the number of elements processed at a single time by the single instruction multiple data stream; a second quantity determination unit, used to use the remainder of the element as the second number of elements in the second element set; an element set determination unit, used to determine the first element set and the second element set in the vector based on the first number and the second number.

8. The device according to claim 7, characterized in that The module for determining the number of elements processed at a single time includes: an element bit number determination unit, which is used to determine the number of bits of a single element in the vector; an element number determination unit, which is used to calculate the ratio of the number of data bits processed at a single time of the single instruction multiple data stream to the number of bits of a single element in the vector, and obtain the number of elements processed at a single time by the single instruction multiple data stream.

9. The device according to claim 7, characterized in that The element set determination unit comprises: A first element set determination subunit, configured to form the first element set from a first number of elements that are ranked first in the vector; The second element set determination subunit is used to form the second element set from a second number of elements that are sorted later in the vector.

10. The device according to claim 7, characterized in that The first quantity determination unit includes: a product calculation subunit, used to calculate the product of the quotient of the elements and the number of elements processed at a single time by the single instruction multiple data stream; a first quantity determination subunit, used to use the product of the quotient of the elements and the number of elements processed at a single time by the single instruction multiple data stream as the first quantity of elements in the first element set.

11. The device according to claim 7, characterized in that The objective function is used to determine the larger value of the elements corresponding to the same position in the first vector and the second vector, the first vector and the second vector have the same length, and the first element set processing module includes: an element group determining unit, configured to determine a plurality of element groups based on a first element set in the first vector and a first element set in the second vector; The third element set determination unit is used to form a third element set from elements with larger values ​​in each element group based on the single instruction multiple data stream.

12. The device according to claim 11, characterized in that The element group determination unit comprises: An element acquisition subunit, used to acquire two elements located at the same position in the first element set in the first vector and the first element set in the second vector; The element group determination subunit is used to regard the two elements located at the same position as an element group.

13. A data processing device in a function, characterized in that: The device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the data processing method in the function as described in any one of claims 1-6.

14. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the data processing method in the function as described in any one of claims 1-6.