WO2023279740A1 - Image processing method and apparatus, and electronic device and storage medium - Google Patents

Image processing method and apparatus, and electronic device and storage medium Download PDF

Info

Publication number
WO2023279740A1
WO2023279740A1 PCT/CN2022/078439 CN2022078439W WO2023279740A1 WO 2023279740 A1 WO2023279740 A1 WO 2023279740A1 CN 2022078439 W CN2022078439 W CN 2022078439W WO 2023279740 A1 WO2023279740 A1 WO 2023279740A1
Authority
WO
WIPO (PCT)
Prior art keywords
feature
convolution
threads
size
read
Prior art date
Application number
PCT/CN2022/078439
Other languages
French (fr)
Chinese (zh)
Inventor
刘宇玺
Original Assignee
上海商汤智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海商汤智能科技有限公司 filed Critical 上海商汤智能科技有限公司
Publication of WO2023279740A1 publication Critical patent/WO2023279740A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/51Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/25Fusion techniques
    • G06F18/253Fusion techniques of extracted features
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/20Processor architectures; Processor configuration, e.g. pipelining

Definitions

  • the present disclosure relates to the field of computer technology, and in particular to an image processing method and device, electronic equipment, storage media and computer program products.
  • GPU Graphics Processing Unit
  • AI artificial intelligence
  • the massive data to be processed in the training and reasoning process of deep learning is accelerated by the GPU.
  • the characteristics of the image can be represented in the form of a matrix, and each value in the matrix represents the pixel at the corresponding position in the image.
  • the convolution of the matrix can be realized.
  • the disclosure proposes an image processing technical solution.
  • an image processing method including:
  • controlling a plurality of second threads to read feature maps and/or feature values in convolution kernels according to the index positions, and perform convolution processing using the read feature values to obtain convolution features, and the convolution The feature is used to characterize the extraction result of the image feature.
  • the convolution process is performed using the read feature value to obtain the convolution feature, including:
  • the calculation of the index position of the feature map and/or the feature value in the convolution kernel through multiple first threads includes:
  • At least two threads are controlled to respectively calculate index positions of feature values in feature maps and/or convolution kernels.
  • the method further includes:
  • controlling multiple second threads to read feature values in feature maps and/or convolution kernels according to the index positions includes:
  • the convolution process is performed using the read eigenvalues to obtain convolution features, including:
  • Each feature value in the register is used to perform convolution processing to obtain convolution features.
  • the method further includes:
  • the method further includes:
  • an image processing device including:
  • An extraction unit is used to extract image features in the target image to obtain a feature map for representing image features
  • An index calculation unit is used to calculate the index position of the feature value in the feature map and/or the convolution kernel through a plurality of first threads;
  • a convolution processing unit configured to control multiple second threads to read feature maps and/or feature values in the convolution kernel according to the index positions, and perform convolution processing using the read feature values to obtain convolution Convolution feature, the convolution feature is used to characterize the extraction result of the image feature.
  • the convolution processing unit is configured to arrange the read eigenvalues in the channel K dimension of the matrix multiply-add operation MMA instruction, and perform matrix multiply-add operations to obtain convolution features.
  • the index calculation unit is configured to control at least two threads to respectively calculate the index positions of the feature maps and/or feature values in the convolution kernel according to the order of the identification IDs of the at least two threads .
  • the device further includes:
  • the loading unit is configured to load the characteristic value of the index position into the shared memory SMem for use by each thread.
  • the convolution processing unit is configured to control the plurality of second threads to read the eigenvalues at the index positions into respective registers, and use each eigenvalue in the registers Perform convolution processing to obtain convolution features.
  • the device further includes:
  • the first size determination unit is configured to determine multiple first sizes of feature blocks that can be processed in a single thread warp, and generate a graphics processor kernel function for dividing feature blocks based on the first size; wherein, the The maximum value of the first size is determined according to the register capacity, the minimum value of the first size is the size of the smallest matrix unit calculated by the matrix multiplication and addition operation instruction, and the values of the various first sizes are multiples of the minimum value .
  • the device further includes:
  • the second size determination unit is configured to determine multiple second sizes of feature blocks that can be processed in a single thread block TB, and generate a graphics processor kernel function for dividing feature blocks based on the second size; wherein, the The minimum value of the second size is the first size of a feature block that can be processed by a single thread warp, the second size is a multiple of the first size, and the maximum value of the second size is based on the capacity of the shared memory and The upper limit of the number of threads in a TB is determined.
  • an electronic device including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to call the instructions stored in the memory to execute the above-mentioned method.
  • a computer-readable storage medium on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above method is implemented.
  • a computer program product including computer readable codes, or a non-volatile computer readable storage medium bearing computer readable codes, when the computer readable codes are stored in an electronic device
  • the processor in the electronic device is used to implement the above method.
  • multiple first threads are used to calculate the index position of the feature value in the feature map and/convolution kernel; multiple second threads are controlled to read the feature map and/convolution kernel according to the index position eigenvalues, and use the read eigenvalues to perform convolution processing to obtain convolution features.
  • the feature map and/or convolution can be pre-calculated through multiple first scenes
  • the index position of the eigenvalue in the product kernel when the index position of the eigenvalue is known, multiple second threads can read the feature map and/or the eigenvalue in the convolution kernel according to the index position for calculation, instead of In one calculation, the indexes of the feature values calculated by all threads point to the same point of the feature map and/convolution kernel in each channel, which reduces the situation of filling data 0 because the index position is not known and the data cannot be read, so as to fully Using each thread for convolution calculation reduces the waste of GPU resources and improves the efficiency of convolution operations.
  • FIG. 1 shows a schematic diagram of feature map dimensions according to an embodiment of the disclosure.
  • FIG. 2 shows a schematic diagram of a convolution process of a matrix multiplication operation according to an embodiment of the present disclosure.
  • Fig. 3 shows a schematic diagram of a process of reading feature values by a convolution operation according to an embodiment of the present disclosure.
  • FIG. 4 shows a flowchart of an image processing method according to an embodiment of the present disclosure.
  • Fig. 5 shows a schematic diagram of an application scenario of an image processing method according to a disclosed embodiment.
  • Fig. 6 shows a block diagram of an image processing device according to an embodiment of the present disclosure.
  • Fig. 7 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
  • Fig. 8 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
  • the convolution operation can be performed based on a tensor computing unit (Tensor Core).
  • Tensor Core is a matrix multiply-accumulate computing unit, which can complete multiple multiply-accumulate operations in one cycle, and can achieve very high computing performance.
  • the computing performance of Tensor Core's int8 precision can even reach 624TOPS.
  • the increase in chip computing power is mainly to accelerate high-frequency calculation-intensive operators such as convolution/matrix multiplication, but it also brings about the difficulty of how to efficiently use computing power, that is, how to efficiently implement convolution operations on Tensor Core. son.
  • a typical convolutional neural network consists of an input layer (Input), a convolutional layer (Conv), an activation function (Relu), and a fully connected layer (FC).
  • CNN convolutional neural network
  • Conv convolutional layer
  • Relu activation function
  • FC fully connected layer
  • the convolution operation is the process of multiplying and adding the feature map (Feature Map) of the image and the filter kernel (Filter Kernel) to extract the image information.
  • the convolution operation is the most time-consuming operation in the neural network. Most of the time overhead of the deep learning model is on the convolution operator. The performance of the convolution operator has an important impact on the program performance.
  • the convolution type can be divided into a large image less channel type and a small image multi channel type, as shown in Figure 1.
  • the three dimensions of the feature map "length ⁇ width ⁇ channel” are marked on the top of the feature map, such as 224 ⁇ 224 ⁇ 3, 56 ⁇ 56 ⁇ 64, etc.
  • the convolution kernel size "length ⁇ width” is marked below the convolution kernel, such as 7x7, 1x1, etc.
  • This type of convolution generally exists in the initial stage of the neural network. It is characterized by a large length and width of the feature map (ie, a large image), such as 224, but the number of channels is relatively small (ie, more channel), such as 3. This type of convolution is a memory-intensive operation, and the computing power of Tensor Core cannot be fully utilized for this type.
  • Small image multi-channel type This type of convolution exists in the middle and end stages of the neural network. It is characterized by a small length and width of the feature map (ie small image), such as 56/28/14, etc., but the number of channels Relatively large (that is, multi-channel), such as 64/128/256, etc.
  • This type of convolution is a computationally intensive operation, which is very suitable for utilizing the computing power of Tensor Core.
  • the convolution algorithm used on TensorCore is mainly an implicit matrix multiplication algorithm.
  • the calculation form of matrix multiplication can be expressed as the multiplication of two matrices A of M ⁇ K and matrix B of K ⁇ N, and the Kth element of each row in A corresponds to the Kth element of the corresponding column in B Multiply to get the process of matrix C of M ⁇ N.
  • the programming model of GPU often includes three layers: thread network (Grid), thread block (Thread Block, TB) and thread (Thread); among them, thread block is the basic unit of task allocation, and enough thread blocks can ensure that the GPU hardware The computing unit is fully utilized.
  • the matrix multiplication uses a block technology to divide the entire large matrix multiplication task into multiple small matrix multiplication tasks, and then assign each small task to a different thread block for execution. For example, the matrix multiplication operation will divide the task of the matrix C (M ⁇ N dimension), and each thread block calculates a small matrix block of Mtile ⁇ Ntile, where Mtile is the size of the M-dimensional feature block, and Ntile is the size of the N-dimensional feature block. size.
  • SM Streaming Multiprocessor
  • the size of matrix multiplication is shown in Figure 2.
  • the M dimension of matrix A and the N dimension of matrix B are large, and the generated feature blocks are sufficient to utilize GPU Hardware resources; while the size of the K dimension is very small, in the GPU, the convolution operation will be performed through the issued matrix multiply and accumulate (MMA) instruction, for example, the processing of an MMA instruction
  • MMA matrix multiply and accumulate
  • the minimum matrix unit is 16 ⁇ 8 in M ⁇ N dimension and 8 in K dimension. Therefore, when the size of the K dimension is very small, it may even be smaller than the K size of M ⁇ N ⁇ K in the MMA instruction.
  • M ⁇ N ⁇ K 16 ⁇ 8 ⁇ 8; when the number of channels of the convolution kernel is less than 8, it is necessary to fill 0 at the end of the channel. Only after it reaches a multiple of 8 can it be sent to the Tensor Core for execution. The more 0s are filled at the end of the channel, the more redundant redundant operations are invalid, and the lower the utilization rate of Tensor Core is.
  • SIMT Single Instruction Multiple Threads
  • the convolution sliding window operation (Sliding Window) will traverse all the points of the convolution kernel in turn, from F(0,0), F(0,1) to F(2,2), a total of 9 times In order to traverse the 3x3 convolution kernel.
  • multiple first threads are used to calculate the index position of the feature value in the feature map and/convolution kernel; multiple second threads are controlled to read the feature map and/convolution kernel according to the index position eigenvalues, and use the read eigenvalues to perform convolution processing to obtain convolution features.
  • the feature map and/or convolution can be pre-calculated through multiple first scenes
  • the index position of the eigenvalue in the product kernel when the index position of the eigenvalue is known, multiple second threads can read the feature map and/or the eigenvalue in the convolution kernel according to the index position for calculation, instead of In one calculation, the indexes of the feature values calculated by all threads point to the same point of the feature map and/convolution kernel in each channel, which reduces the situation of filling data 0 because the index position is not known and the data cannot be read, so as to fully Using each thread for convolution calculation reduces the waste of GPU resources and improves the efficiency of convolution operations.
  • the subject of execution of the steps of the image processing method may be executed by hardware, or executed by a processor running computer executable codes.
  • the image processing method may be executed by electronic equipment such as a terminal device or a server, and the terminal device may be user equipment (User Equipment, UE), mobile device, user terminal, terminal, cellular phone, cordless Phones, personal digital assistants (Personal Digital Assistant, PDA), handheld devices, computing devices, vehicle-mounted devices, wearable devices, etc., the method can be realized by calling the computer-readable instructions stored in the memory by the processor.
  • UE User Equipment
  • PDA Personal Digital Assistant
  • the execution subject of the image processing method may be a graphics processing unit (graphics processing unit, GPU).
  • graphics processing unit graphics processing unit, GPU
  • the execution subject of the method is the GPU, which is only an exemplary description, and should not be understood as a limitation of the method.
  • FIG. 4 shows a flowchart of an image processing method according to an embodiment of the present disclosure. As shown in FIG. 4, the image processing method includes:
  • step S11 image features in the target image are extracted to obtain a feature map for characterizing image features.
  • the expression of an image in computer technology can be a matrix composed of pixel values, so the analysis of the image can be the analysis of the matrix representing the pixel values of the image.
  • the image feature here may be used to represent the pixel value of the image, and the image feature may be a matrix composed of the pixel values of the image, or may be an image feature obtained after multiple convolution operations, which is not limited in the present disclosure.
  • step S12 index positions of feature values in feature maps and/or convolution kernels are calculated by multiple first threads.
  • the specific form of convolution kernel can be a matrix, which contains three dimensions "length ⁇ width ⁇ channel”.
  • the eigenvalues in this matrix are the weights during convolution. Through this weight, it can be extracted by convolution operation. desired image features and suppress other image features.
  • the specific representation of the feature map is also a matrix, which contains three dimensions of "length ⁇ width ⁇ channel”. The eigenvalues in this matrix are used to represent the pixel values in the image.
  • index position which is used to represent the storage location of the data in the storage space.
  • the feature value in the storage space can be read directly according to the index position to perform convolution calculation, without expanding the feature map into a matrix and then performing convolution calculation, which can save memory resources.
  • a thread order can be preset as the order in which the threads calculate the index positions in the feature map and/or the length and width directions of the convolution kernel, and each first thread can calculate the index positions of the feature values in parallel, and each first thread Compute the index positions of the different eigenvalues.
  • thread 0 is in the length and width directions of the convolution kernel
  • thread No. 1 calculates the index position of the second eigenvalue
  • thread No. 2 calculates the index position of the third eigenvalue
  • thread No. 3 calculates the index position of the fourth eigenvalue.
  • each time a thread reads a characteristic value it can read values on two channels. For example, for a convolution kernel with a length and width of 3x3 and a number of channels of 2, according to the sequence in step S12, in the case of 1 thread computing 2 channels, it only needs to execute the MMA instruction 3 times to calculate all the eigenvalues Calculations are more efficient.
  • step S13 multiple second threads are controlled to read feature maps and/or feature values in the convolution kernel according to the index positions, and perform convolution processing using the read feature values to obtain convolution features,
  • the convolution feature is used to characterize the extraction result of the image feature.
  • each second thread can directly read each feature value in the feature map and/convolution kernel according to the index position when performing calculations, and the second thread is in the known
  • the eigenvalue can be directly read according to the index position as a parameter in the convolution calculation instruction, so the values required for each dimension calculation in a convolution calculation instruction can be filled as much as possible, reducing It is necessary to add 0.
  • the read eigenvalues can be used to perform convolution processing to obtain convolution features.
  • the specific convolution processing process can be convolution processing based on matrix multiplication, which is especially suitable for It is suitable for convolution processing of large image and less channel type, and the processing efficiency is high.
  • first thread and the second thread may be the same thread or different threads. It can be understood that the "first” and “second” in the embodiments of the present disclosure are used to distinguish the described It should not be understood as other restrictions on the order of describing objects, indicating or implying relative importance, etc.
  • multiple first threads are used to calculate the index position of the feature value in the feature map and/convolution kernel; multiple second threads are controlled to read the feature map and/convolution kernel according to the index position eigenvalues, and use the read eigenvalues to perform convolution processing to obtain convolution features.
  • the feature map and/or convolution can be pre-calculated through multiple first scenes
  • the index position of the eigenvalue in the product kernel when the index position of the eigenvalue is known, multiple second threads can read the feature map and/or the eigenvalue in the convolution kernel according to the index position for calculation, instead of In one calculation, the indexes of the feature values calculated by all threads point to the same point of the feature map and/convolution kernel in each channel, which reduces the situation of filling data 0 because the index position is not known and the data cannot be read, so as to fully Using each thread for convolution calculation reduces the waste of GPU resources and improves the efficiency of convolution operations.
  • performing convolution processing using the read eigenvalues to obtain convolution features includes: adding the read eigenvalues to the channel dimension K of the matrix multiplication and addition operation MMA instruction Arrange and perform matrix multiplication and addition operations to obtain convolution features.
  • the MMA instruction is used to perform the matrix multiplication operation.
  • the minimum size in the K direction of the channel dimension is 8. That is to say, when executing an MMA execution, the K dimension can calculate 8 eigenvalue, then, in the case of knowing the index position of the feature map and/or convolution kernel feature value, the feature values of the 8 channels can be read in turn according to the index position, as the value calculated by the MMA instruction, so that it can be fully utilized
  • the computing power of the second thread reduces the waste of GPU resources and improves the efficiency of convolution operations.
  • calculating the feature map and/the index position of the feature value in the convolution kernel through multiple first threads includes: according to the feature map and/the feature value in the convolution kernel in the feature map and/ The position in the convolution kernel, and the feature map and/or the data arrangement rule of each feature value in the convolution kernel in the storage space determine the index position of each feature value in the storage space.
  • NCHW arrangement N represents the number of feature maps
  • C represents channels
  • H Represents the height (length) of the matrix
  • W represents the width.
  • NCHW arrangement is to arrange the values of the matrix according to the priority order of [N,C,H,W]
  • NHWC arrangement is to arrange the values according to the priority order of [N,H,W,C]. Arrange the values of the matrix.
  • the channel, height, and width of each eigenvalue of the convolution kernel are known, that is, the position of the eigenvalue in the convolution kernel in the convolution kernel is known. Knowing the data arrangement rules of the eigenvalues of the convolution kernel in the data storage space, the position of each eigenvalue in the convolution kernel and the data arrangement rules in the data storage space can be used to determine each The index position of the feature value in the storage space.
  • the data arrangement rules determine the index position of each feature value in the storage space. In this way, the feature map to be read by each thread and/or the index position of the feature value in the convolution kernel can be accurately calculated.
  • the calculating the index position of the feature map and/or the feature value in the convolution kernel through multiple first threads includes: controlling at least two Threads compute index positions of feature maps and/or feature values in kernels respectively.
  • each thread in the GPU has an identification ID, which is used to distinguish different threads.
  • the ID can be: T0, T1, T2, T3, for example, then
  • the order of thread IDs can be the order of [T0, T1, T2, T3] in ascending order of numbers. It should be noted that this order is a circular order, that is, the order of T3 will continue to be connected after [ T0, T1, T2, T3] until the index position of the feature value in the convolution kernel is calculated.
  • each thread since the thread itself has an ID, each thread is controlled to calculate the index position of the feature map and/or the feature value in the convolution kernel according to the order of the identification ID of each thread, so that each thread parallelizes each The index position of the feature value is calculated, which improves the efficiency of the index position calculation.
  • the calculating the feature map and/the index position of the feature value in the convolution kernel through multiple first threads includes: loading the feature value of the index position into a shared memory (Shared Memory , SMem) for use by each thread.
  • SMem Shared Memory
  • the size of the shared memory is limited, it has high read and write speed and bandwidth. Therefore, considering that the value of the index position (index value) occupies a small amount of memory, then, in order to improve the efficiency of reading and writing the index value, you can use
  • the value of the index position is stored in the SMem, thereby improving the efficiency of the convolution operation to improve the efficiency of the image processing operation.
  • controlling the multiple second threads to read the feature values in the convolution kernel according to the index positions includes: controlling the multiple second threads to read the feature values at the index positions input into respective registers; said using the read feature values to perform convolution processing to obtain convolution features includes: using each feature value in the registers to perform convolution processing to obtain convolution features.
  • the MMA instruction is often used together with the ldmatrix instruction.
  • the data of matrix A and matrix B required for MMA instruction calculation will be read from the global memory space (Global Memory, GMem) and placed in SMem, and then use the ldmatrix instruction to store the data of matrix A and matrix B according to a specific matrix shape. Data is read into the registers of each thread.
  • the advantage of putting data into SMem is that there is data sharing between threads, which reduces the delay of reading data from GMem.
  • there is little convolution data that needs to be shared. Putting the data in the SMem cache will increase the delay of reading and writing SMem.
  • the data required in the MMA instruction is directly read into the registers of each thread, making full use of the characteristics of large image and less channel type convolution, and reducing the delay of data reading.
  • the matrix of the convolution operation in the process of performing the convolution operation, can be divided into blocks, the feature matrix can be divided into multiple feature blocks, and then the multiple feature blocks can be operated in parallel to obtain
  • To improve the efficiency of convolution specifically, it is possible to determine various possible feature block sizes of TB, thread warp, and K dimension, and finally generate a variety of corresponding graphics processor kernel function kernels, which are convenient for later selection according to the size of image features
  • a suitable kernel performs convolution processing on image features. The three dimensions are described in detail below.
  • the method further includes: determining multiple first sizes of feature blocks that can be processed in a single warp, and based on the The first size is used to generate a graphics processor kernel function for feature block division; wherein, the maximum value of the first size is determined according to the register capacity, and the minimum value of the first size is the minimum calculated by the matrix multiply-add operation instruction
  • the size of the matrix unit, the values of the multiple first sizes are multiples of the minimum value.
  • the convolution operation is performed through the issued matrix multiply and accumulate (MMA) instruction.
  • MMA matrix multiply and accumulate
  • the smallest matrix unit processed by an MMA instruction is 16 ⁇ 8 in the M ⁇ N dimension , which is 8 in the K dimension.
  • the size of the smallest matrix unit that can be processed is the size of the smallest matrix unit that can be processed by the MMA instruction, and since the operation of the instruction is accumulated in the form of an exponential power of 2, the characteristics that can be processed by a single Warp
  • the size of the block is the size of the smallest matrix unit multiplied by the power of 2
  • N can be 8
  • M can be 16, 32, 64, 128, then the obtained value of M ⁇ N is as follows Table 1 shows.
  • the size of the feature block cannot be increased infinitely, and its maximum value can be determined according to the register capacity. Due to the limitation of the register capacity, the Warp feature block of 128x64 cannot be stored in the register. Therefore, the feature block The maximum value of the first size is 128 ⁇ 32 or 64 ⁇ 64, as shown in Table 1 for details.
  • the first size of all feature blocks can be traversed in the Warp dimension, and then the graphics processor kernel function kernel can be generated based on the first size, and the kernel obtained in this way can be applied to image features of various sizes Segmentation, the resulting kernel has high universality.
  • the method further includes: determining multiple second sizes of feature blocks that can be processed in a single thread block TB, and based on the The second size is used to generate a graphics processor kernel function for feature block division; wherein, the minimum value of the second size is the first size of a feature block that can be processed by a single thread warp, and the second size is the multiples of the first size, and the maximum value of the second size is determined according to the capacity of the shared memory and the upper limit of the number of threads in a TB.
  • a TB contains one or more warps
  • the minimum value of the second size is the first size of the feature block that can be processed by a single thread warp, and the second size can also be a multiple of the first size, which is Powers of 2, ie 2, 4.
  • the specific values of M TB and NT TB in Table 3 are multiples of the first size.
  • a TB can often have up to 1024 threads, that is, 16 Warps.
  • the number of threads is 128-512
  • the calculation efficiency is higher, so 16 Warps are often not run, so , in order to ensure GPU computing efficiency, a maximum of 8 warps can be run in one TB, that is, the maximum value of M TB ⁇ N TB is 2 ⁇ 4 or 4 ⁇ 2, as shown in Table 2.
  • Table 2 Feature block size at TB level.
  • the numbers in the table represent the multiples of the corresponding Warp-level feature block size
  • the second size of all feature blocks can be traversed in the TB dimension, and then the graphics processor kernel function kernel can be generated based on the second size, and the kernel obtained in this way can be applied to image features of various sizes Segmentation, the resulting kernel has high universality.
  • the size of the smallest matrix unit that can be processed is the size of the smallest matrix unit that can be processed by the MMA instruction.
  • the smallest matrix unit processed by an MMA instruction is in the M ⁇ N dimension is 16 ⁇ 8, which is 8 in the K dimension.
  • various possible sizes of the K dimension in a single TB include k8, k16, k32, etc., as shown in Table 3.
  • the third size of the group can be traversed on the K dimension of the feature block, and then the kernel function kernel of the graphics processor can be generated based on various possible third sizes, and the kernel obtained in this way can be applied to each
  • the image features of different sizes are segmented, and the obtained kernel has high universality.
  • FIG. 5 is a schematic diagram of an application scenario of the image processing method of the embodiment of the present disclosure.
  • the index position of each feature value in the 3 ⁇ 3 convolution kernel is pre-calculated: F(0,0 ),F(0,1),F(0,2),F(1,0),F(1,1),F(1,2),F(2,0),F(2,1) , F(2,2), and put it into SMem; then threads T0, T1, T2, T3 read the pre-calculated index from SMem in turn, and only the F( 0,0), F(0,1), F(0,2) and F(1,0), where one thread reads the feature values of the 2-layer channel at the same length and width position, as shown in Figure 5 , C0 represents the 0th layer of the channel, C1 represents the first layer of the channel, T0 reads the eigenvalues of the two channels at F(0,0), and T1 reads the two channels at F(0,1) Eigenvalue
  • One MMA instruction can be executed by four threads T0, T1, T2, and T3. After the four threads read the data of the 8 channels shown in the figure, the MMA instruction is executed once. There is no need to fill in invalid data during this execution. 0 data, which improves the utilization of Tensor Core.
  • the 4 threads need to perform 3 MMA tasks in total, and then they can traverse the 3x3 convolution kernel.
  • the dual-channel F(0, 0), F(0,1), F(0,2), F(1,0) for processing a total of 8 channels of data, which can fill the minimum K dimension 8 of the MMA instruction;
  • the second time for the dual channel F(1,1), F(1,2), F(2,0), F(2,1) are processed, a total of 8 channels of data, which can fill the minimum K dimension 8 of the MMA instruction
  • the third time The two-channel F(2,2) is processed, and the data of two channels in total cannot fill the minimum K dimension of 8 in the MMA instruction, so it is filled with 6 zeros to make up.
  • the image processing method provided by the embodiment of the present disclosure can reduce the number of invalid padding zeros and improve the utilization rate of Tensor Core when processing images with large images and few channels.
  • the present disclosure also provides image processing devices, electronic equipment, computer-readable storage media, and programs, all of which can be used to implement any image processing method provided in the present disclosure.
  • image processing devices electronic equipment, computer-readable storage media, and programs, all of which can be used to implement any image processing method provided in the present disclosure.
  • FIG. 6 shows a block diagram of an image processing device according to an embodiment of the present disclosure. As shown in FIG. 6, the device 60 includes:
  • An extraction unit 61 configured to extract image features in the target image to obtain a feature map for characterizing image features
  • An index calculation unit 62 configured to calculate the index position of the feature value in the feature map and/or the convolution kernel through a plurality of first threads
  • the convolution processing unit 63 is configured to control multiple second threads to read feature maps and/or feature values in the convolution kernel according to the index positions, and perform convolution processing using the read feature values to obtain A convolution feature, the convolution feature is used to characterize the extraction result of the image feature.
  • the convolution processing unit is configured to arrange the read eigenvalues in the channel K dimension of the matrix multiplication and addition operation MMA instruction, and perform matrix multiplication and addition operations to obtain convolution features.
  • the index calculation unit is configured to control at least two threads to respectively calculate the index positions of the feature maps and/or feature values in the convolution kernel according to the order of the identification IDs of the at least two threads .
  • the device further includes:
  • the loading unit is configured to load the characteristic value of the index position into the shared memory SMem for use by each thread.
  • the convolution processing unit is configured to control the plurality of second threads to read the eigenvalues at the index positions into respective registers, and use each eigenvalue in the registers Perform convolution processing to obtain convolution features.
  • the device further includes:
  • the first size determination unit is configured to determine multiple first sizes of feature blocks that can be processed in a single thread warp, and generate a graphics processor kernel function for dividing feature blocks based on the first size; wherein, the The maximum value of the first size is determined according to the register capacity, the minimum value of the first size is the size of the smallest matrix unit calculated by the matrix multiplication and addition operation instruction, and the values of the various first sizes are multiples of the minimum value .
  • the device further includes:
  • the second size determination unit is configured to determine multiple second sizes of feature blocks that can be processed in a single thread block TB, and generate a graphics processor kernel function for dividing feature blocks based on the second size; wherein, the The minimum value of the second size is the first size of a feature block that can be processed by a single thread warp, the second size is a multiple of the first size, and the maximum value of the second size is based on the capacity of the shared memory and The upper limit of the number of threads in a TB is determined.
  • the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the methods described in the above method embodiments, and its specific implementation and technical effects can refer to the descriptions of the above method embodiments, for It is concise and will not be repeated here.
  • Embodiments of the present disclosure also provide a computer-readable storage medium, on which computer program instructions are stored, and the above-mentioned method is implemented when the computer program instructions are executed by a processor.
  • Computer readable storage media may be volatile or nonvolatile computer readable storage media.
  • An embodiment of the present disclosure also proposes an electronic device, including: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to invoke the instructions stored in the memory to execute the above method.
  • An embodiment of the present disclosure also provides a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium carrying computer-readable codes, when the computer-readable codes are stored in a processor of an electronic device When running in the electronic device, the processor in the electronic device executes the above method.
  • Electronic devices may be provided as terminals, servers, or other forms of devices.
  • FIG. 7 shows a block diagram of an electronic device 800 according to an embodiment of the present disclosure.
  • the electronic device 800 may be a terminal such as a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, or a personal digital assistant.
  • electronic device 800 may include one or more of the following components: processing component 802, memory 804, power supply component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814 , and the communication component 816.
  • the processing component 802 generally controls the overall operations of the electronic device 800, such as those associated with display, telephone calls, data communications, camera operations, and recording operations.
  • the processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above method. Additionally, processing component 802 may include one or more modules that facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802 .
  • the memory 804 is configured to store various types of data to support operations at the electronic device 800 . Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and the like.
  • the memory 804 can be implemented by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic or Optical Disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read-only memory
  • EPROM erasable Programmable Read Only Memory
  • PROM Programmable Read Only Memory
  • ROM Read Only Memory
  • Magnetic Memory Flash Memory
  • Magnetic or Optical Disk Magnetic Disk
  • the power supply component 806 provides power to various components of the electronic device 800 .
  • Power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for electronic device 800 .
  • the multimedia component 808 includes a screen providing an output interface between the electronic device 800 and the user.
  • the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user.
  • the touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense a boundary of a touch or swipe action, but also detect duration and pressure associated with the touch or swipe action.
  • the multimedia component 808 includes a front camera and/or a rear camera. When the electronic device 800 is in an operation mode, such as a shooting mode or a video mode, the front camera and/or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capability.
  • the audio component 810 is configured to output and/or input audio signals.
  • the audio component 810 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 800 is in operation modes, such as call mode, recording mode and voice recognition mode. Received audio signals may be further stored in memory 804 or sent via communication component 816 .
  • the audio component 810 also includes a speaker for outputting audio signals.
  • the I/O interface 812 provides an interface between the processing component 802 and a peripheral interface module, which may be a keyboard, a click wheel, a button, and the like. These buttons may include, but are not limited to: a home button, volume buttons, start button, and lock button.
  • Sensor assembly 814 includes one or more sensors for providing status assessments of various aspects of electronic device 800 .
  • the sensor component 814 can detect the open/closed state of the electronic device 800, the relative positioning of components, such as the display and the keypad of the electronic device 800, the sensor component 814 can also detect the electronic device 800 or a Changes in position of components, presence or absence of user contact with electronic device 800 , electronic device 800 orientation or acceleration/deceleration and temperature changes in electronic device 800 .
  • Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact.
  • Sensor assembly 814 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications.
  • CMOS complementary metal-oxide-semiconductor
  • CCD charge-coupled device
  • the sensor component 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
  • the communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices.
  • the electronic device 800 can access a wireless network based on a communication standard, such as a wireless network (WiFi), a second generation mobile communication technology (2G) or a third generation mobile communication technology (3G), or a combination thereof.
  • the communication component 816 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel.
  • the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication.
  • the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology and other technologies.
  • RFID Radio Frequency Identification
  • IrDA Infrared Data Association
  • UWB Ultra Wide Band
  • Bluetooth Bluetooth
  • electronic device 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable A programmable gate array (FPGA), controller, microcontroller, microprocessor or other electronic component implementation for performing the methods described above.
  • ASICs application specific integrated circuits
  • DSPs digital signal processors
  • DSPDs digital signal processing devices
  • PLDs programmable logic devices
  • FPGA field programmable A programmable gate array
  • controller microcontroller, microprocessor or other electronic component implementation for performing the methods described above.
  • a non-volatile computer-readable storage medium such as the memory 804 including computer program instructions, which can be executed by the processor 820 of the electronic device 800 to implement the above method.
  • FIG. 8 shows a block diagram of an electronic device 1900 according to an embodiment of the present disclosure.
  • electronic device 1900 may be provided as a server.
  • electronic device 1900 includes processing component 1922 , which further includes one or more processors, and a memory resource represented by memory 1932 for storing instructions executable by processing component 1922 , such as application programs.
  • the application programs stored in memory 1932 may include one or more modules each corresponding to a set of instructions.
  • the processing component 1922 is configured to execute instructions to perform the above method.
  • Electronic device 1900 may also include a power supply component 1926 configured to perform power management of electronic device 1900, a wired or wireless network interface 1950 configured to connect electronic device 1900 to a network, and an input-output (I/O) interface 1958 .
  • the electronic device 1900 can operate based on the operating system stored in the memory 1932, such as the Microsoft server operating system (Windows Server TM ), the graphical user interface-based operating system (Mac OS X TM ) introduced by Apple Inc., and the multi-user and multi-process computer operating system (Unix TM ), a free and open source Unix-like operating system (Linux TM ), an open source Unix-like operating system (FreeBSD TM ), or the like.
  • Microsoft server operating system Windows Server TM
  • Mac OS X TM graphical user interface-based operating system
  • Unix TM multi-user and multi-process computer operating system
  • Linux TM free and open source Unix-like operating system
  • FreeBSD TM open source Unix-like operating system
  • a non-transitory computer-readable storage medium such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to implement the above method.
  • the present disclosure can be a system, method and/or computer program product.
  • a computer program product may include a computer readable storage medium having computer readable program instructions thereon for causing a processor to implement various aspects of the present disclosure.
  • a computer readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device.
  • a computer readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
  • Computer-readable storage media include: portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory), static random access memory (SRAM), compact disc read only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanically encoded device, such as a printer with instructions stored thereon A hole card or a raised structure in a groove, and any suitable combination of the above.
  • RAM random access memory
  • ROM read-only memory
  • EPROM erasable programmable read-only memory
  • flash memory static random access memory
  • SRAM static random access memory
  • CD-ROM compact disc read only memory
  • DVD digital versatile disc
  • memory stick floppy disk
  • mechanically encoded device such as a printer with instructions stored thereon
  • a hole card or a raised structure in a groove and any suitable combination of the above.
  • computer-readable storage media are not to be construed as transient signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., pulses of light through fiber optic cables), or transmitted electrical signals.
  • Computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or downloaded to an external computer or external storage device over a network, such as the Internet, a local area network, a wide area network, and/or a wireless network.
  • the network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers.
  • a network adapter card or a network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .
  • Computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or Source or object code written in any combination, including object-oriented programming languages—such as Smalltalk, C++, etc., and conventional procedural programming languages—such as the “C” language or similar programming languages.
  • Computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement.
  • the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as via the Internet using an Internet service provider). connect).
  • LAN local area network
  • WAN wide area network
  • an electronic circuit such as a programmable logic circuit, field programmable gate array (FPGA), or programmable logic array (PLA)
  • FPGA field programmable gate array
  • PDA programmable logic array
  • These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine such that when executed by the processor of the computer or other programmable data processing apparatus , producing an apparatus for realizing the functions/actions specified in one or more blocks in the flowchart and/or block diagram.
  • These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause computers, programmable data processing devices and/or other devices to work in a specific way, so that the computer-readable medium storing instructions includes An article of manufacture comprising instructions for implementing various aspects of the functions/acts specified in one or more blocks in flowcharts and/or block diagrams.
  • each block in a flowchart or block diagram may represent a module, a portion of a program segment, or an instruction that includes one or more Executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions.
  • the computer program product can be specifically realized by means of hardware, software or a combination thereof.
  • the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK) etc. Wait.
  • a software development kit Software Development Kit, SDK

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computing Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Optimization (AREA)
  • General Health & Medical Sciences (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Health & Medical Sciences (AREA)
  • Pure & Applied Mathematics (AREA)
  • Molecular Biology (AREA)
  • Mathematical Analysis (AREA)
  • Computational Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Algebra (AREA)
  • Image Analysis (AREA)

Abstract

The present disclosure relates to an image processing method and apparatus, and an electronic device and a storage medium. The method comprises: extracting image features from a target image, so as to obtain a feature map for representing the image features; calculating an index position of a feature value in the feature map and/or a convolution kernel by means of a plurality of first threads; and controlling a plurality of second threads to read, according to the index position, the feature value in the feature map and/or the convolution kernel, and performing convolution processing by using the read feature value, so as to obtain a convolution feature, wherein the convolution feature is used for representing an extraction result of the image feature. By means of the embodiments of the present disclosure, the efficiency of a convolution operation during image processing can be improved.

Description

一种图像处理方法及装置、电子设备和存储介质An image processing method and device, electronic equipment, and storage medium
本申请要求2021年07月09日提交、申请号为202110779002.5,发明名称为“一种图像处理方法及装置、电子设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on July 09, 2021, with the application number 202110779002.5, and the title of the invention is "An image processing method and device, electronic equipment, and storage medium", the entire contents of which are incorporated herein by reference. Applying.
技术领域technical field
本公开涉及计算机技术领域,尤其涉及一种图像处理方法及装置、电子设备、存储介质和计算机程序产品。The present disclosure relates to the field of computer technology, and in particular to an image processing method and device, electronic equipment, storage media and computer program products.
背景技术Background technique
图形处理器(Graphics Processing Unit,GPU)作为硬件加速器在高性能计算领域得到广泛的应用。特别是近几年,GPU广泛应用在人工智能(AI)领域,特别是深度学习领域。深度学习的训练和推理过程中所要处理的海量数据由GPU来加速处理。Graphics Processing Unit (GPU) is widely used as a hardware accelerator in the field of high-performance computing. Especially in recent years, GPUs have been widely used in the field of artificial intelligence (AI), especially in the field of deep learning. The massive data to be processed in the training and reasoning process of deep learning is accelerated by the GPU.
图像的特征可以表征为矩阵的形式,矩阵中的每一个值表征图像中相应位置的像素点,通过对矩阵进行矩阵乘累加操作,可以实现对矩阵的卷积。The characteristics of the image can be represented in the form of a matrix, and each value in the matrix represents the pixel at the corresponding position in the image. By performing matrix multiplication and accumulation operations on the matrix, the convolution of the matrix can be realized.
发明内容Contents of the invention
本公开提出了一种图像处理技术方案。The disclosure proposes an image processing technical solution.
根据本公开的一方面,提供了一种图像处理方法,包括:According to an aspect of the present disclosure, an image processing method is provided, including:
对目标图像中的图像特征进行提取,得到用于表征图像特征的特征图;Extracting the image features in the target image to obtain a feature map used to characterize the image features;
通过多个第一线程计算特征图和/或卷积核中的特征值的索引位置;Computing index positions of feature values in feature maps and/or convolution kernels by multiple first threads;
控制多个第二线程按照所述索引位置读取特征图和/或卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征,所述卷积特征用于表征对所述图像特征的提取结果。controlling a plurality of second threads to read feature maps and/or feature values in convolution kernels according to the index positions, and perform convolution processing using the read feature values to obtain convolution features, and the convolution The feature is used to characterize the extraction result of the image feature.
在一种可能的实现方式中,所述利用读取到的所述特征值进行卷积处理,得到卷积特征,包括:In a possible implementation manner, the convolution process is performed using the read feature value to obtain the convolution feature, including:
将读取到的特征值在矩阵乘加运算MMA指令的通道K维度进行排列,进行矩阵乘加运算,得到卷积特征。Arrange the read eigenvalues in the channel K dimension of the matrix multiply-add operation MMA instruction, and perform matrix multiply-add operations to obtain convolution features.
在一种可能的实现方式中,所述通过多个第一线程计算特征图和/卷积核中的特征值的索引位置,包括:In a possible implementation manner, the calculation of the index position of the feature map and/or the feature value in the convolution kernel through multiple first threads includes:
按照至少两个线程的标识ID的顺序,控制至少两个线程分别计算特征图和/或卷积核中的特征值的索引位置。According to the sequence of the identification IDs of the at least two threads, at least two threads are controlled to respectively calculate index positions of feature values in feature maps and/or convolution kernels.
在一种可能的实现方式中,在所述通过多个第一线程计算特征图和/卷积核中的特征值的索引位置,所述方法还包括:In a possible implementation manner, at the index position of the feature map and/or the feature value in the convolution kernel calculated by multiple first threads, the method further includes:
将所述索引位置的特征值加载到共享内存SMem中,以供各线程使用。Load the characteristic value of the index position into the shared memory SMem for use by each thread.
在一种可能的实现方式中,所述控制多个第二线程按照所述索引位置读取特征图和/或卷积核中的特征值,包括:In a possible implementation manner, the controlling multiple second threads to read feature values in feature maps and/or convolution kernels according to the index positions includes:
控制所述多个第二线程将索引位置处的特征值读入到各自的寄存器中;controlling the plurality of second threads to read the feature values at the index positions into respective registers;
所述利用读取到的所述特征值进行卷积处理,得到卷积特征,包括:The convolution process is performed using the read eigenvalues to obtain convolution features, including:
利用所述寄存器中的各个特征值进行卷积处理,得到卷积特征。Each feature value in the register is used to perform convolution processing to obtain convolution features.
在一种可能的实现方式中,在所述对目标图像中的图像特征进行提取后,所述方法还包括:In a possible implementation, after the image features in the target image are extracted, the method further includes:
确定单个线程束Warp中能够处理的特征块的多种第一尺寸,并基于所述第一尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第一尺寸的最大值根据寄存器容量确定,所述第一尺寸的最小值为矩阵乘加运算指令计算的最小矩阵单元的尺寸,所述多种第一尺寸的值为所述最小值的倍数。Determining multiple first sizes of feature blocks that can be processed in a single thread warp Warp, and generating a graphics processor kernel function for dividing feature blocks based on the first size; wherein, the maximum value of the first size is based on The register capacity is determined, the minimum value of the first size is the size of the smallest matrix unit calculated by the matrix multiply-add operation instruction, and the values of the various first sizes are multiples of the minimum value.
在一种可能的实现方式中,在所述对目标图像中的图像特征进行提取后,所述方法还包括:In a possible implementation, after the image features in the target image are extracted, the method further includes:
确定单个线程块TB中能够处理的特征块的多种第二尺寸,并基于所述第二尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第二尺寸的最小值为单个线程束Warp能够处理的特征块的第一尺寸,所述第二尺寸为所述第一尺寸的倍数,所述第二尺寸的最大值根据共享内存的容量和TB内线程数上限确定。Determining multiple second sizes of feature blocks that can be processed in a single thread block TB, and generating a graphics processor kernel function for dividing feature blocks based on the second size; wherein, the minimum value of the second size is The first size of a feature block that can be processed by a single warp warp, the second size is a multiple of the first size, and the maximum value of the second size is determined according to the capacity of the shared memory and the upper limit of the number of threads in a TB.
根据本公开的一方面,提供了一种图像处理装置,包括:According to an aspect of the present disclosure, an image processing device is provided, including:
提取单元,用于对目标图像中的图像特征进行提取,得到用于表征图像特征的特征图;An extraction unit is used to extract image features in the target image to obtain a feature map for representing image features;
索引计算单元,用于通过多个第一线程计算特征图和/或卷积核中的特征值的索引位置;An index calculation unit is used to calculate the index position of the feature value in the feature map and/or the convolution kernel through a plurality of first threads;
卷积处理单元,用于控制多个第二线程按照所述索引位置读取特征图和/或卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征,所述卷积特征用于表征对所述图像特征的提取结果。A convolution processing unit, configured to control multiple second threads to read feature maps and/or feature values in the convolution kernel according to the index positions, and perform convolution processing using the read feature values to obtain convolution Convolution feature, the convolution feature is used to characterize the extraction result of the image feature.
在一种可能的实现方式中,所述卷积处理单元,用于将读取到的特征值在矩阵乘加运算MMA指令的通道K维度进行排列,进行矩阵乘加运算,得到卷积特征。In a possible implementation manner, the convolution processing unit is configured to arrange the read eigenvalues in the channel K dimension of the matrix multiply-add operation MMA instruction, and perform matrix multiply-add operations to obtain convolution features.
在一种可能的实现方式中,所述索引计算单元,用于按照至少两个线程的标识ID的顺序,控制至少两个线程分别计算特征图和/或卷积核中的特征值的索引位置。In a possible implementation manner, the index calculation unit is configured to control at least two threads to respectively calculate the index positions of the feature maps and/or feature values in the convolution kernel according to the order of the identification IDs of the at least two threads .
在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:
加载单元,用于将所述索引位置的特征值加载到共享内存SMem中,以供各线程使用。The loading unit is configured to load the characteristic value of the index position into the shared memory SMem for use by each thread.
在一种可能的实现方式中,所述卷积处理单元,用于控制所述多个第二线程将索引位置处的特征值读入到各自的寄存器中,利用所述寄存器中的各个特征值进行卷积处理,得到卷积特征。In a possible implementation manner, the convolution processing unit is configured to control the plurality of second threads to read the eigenvalues at the index positions into respective registers, and use each eigenvalue in the registers Perform convolution processing to obtain convolution features.
在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:
第一尺寸确定单元,用于确定单个线程束Warp中能够处理的特征块的多种第一尺寸,并基于所述第一尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第一尺寸的最大值根据寄存器容量确定,所述第一尺寸的最小值为矩阵乘加运算指令计算的最 小矩阵单元的尺寸,所述多种第一尺寸的值为所述最小值的倍数。The first size determination unit is configured to determine multiple first sizes of feature blocks that can be processed in a single thread warp, and generate a graphics processor kernel function for dividing feature blocks based on the first size; wherein, the The maximum value of the first size is determined according to the register capacity, the minimum value of the first size is the size of the smallest matrix unit calculated by the matrix multiplication and addition operation instruction, and the values of the various first sizes are multiples of the minimum value .
在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:
第二尺寸确定单元,用于确定单个线程块TB中能够处理的特征块的多种第二尺寸,并基于所述第二尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第二尺寸的最小值为单个线程束Warp能够处理的特征块的第一尺寸,所述第二尺寸为所述第一尺寸的倍数,所述第二尺寸的最大值根据共享内存的容量和TB内线程数上限确定。The second size determination unit is configured to determine multiple second sizes of feature blocks that can be processed in a single thread block TB, and generate a graphics processor kernel function for dividing feature blocks based on the second size; wherein, the The minimum value of the second size is the first size of a feature block that can be processed by a single thread warp, the second size is a multiple of the first size, and the maximum value of the second size is based on the capacity of the shared memory and The upper limit of the number of threads in a TB is determined.
根据本公开的一方面,提供了一种电子设备,包括:处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为调用所述存储器存储的指令,以执行上述方法。According to an aspect of the present disclosure, there is provided an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to call the instructions stored in the memory to execute the above-mentioned method.
根据本公开的一方面,提供了一种计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。According to one aspect of the present disclosure, there is provided a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above method is implemented.
根据本公开的一方面,提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行用于实现上述方法。According to an aspect of the present disclosure, there is provided a computer program product, including computer readable codes, or a non-volatile computer readable storage medium bearing computer readable codes, when the computer readable codes are stored in an electronic device When running in the processor, the processor in the electronic device is used to implement the above method.
在本公开实施例中,通过多个第一线程计算特征图和/卷积核中的特征值的索引位置;控制多个第二线程按照所述索引位置读取特征图和/卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征。由此,针对矩阵乘卷积方式而言,对于大图少通道的卷积类型,由于通道数较少,为便于充分利用计算资源,可以通过多个第一现场预先计算出特征图和/卷积核中的特征值的索引位置,在已知特征值的索引位置的情况下,多个第二线程可以按照索引位置去读取特征图和/卷积核中的特征值进行计算,而非在一次计算中所有线程计算的特征值的索引都指向各通道中特征图和/卷积核的同一个点,减少了由于不知道索引位置读取不到数据而填充数据0的情况,以充分利用各线程进行卷积计算,减少了GPU资源浪费,提高了卷积操作的效率。In the embodiment of the present disclosure, multiple first threads are used to calculate the index position of the feature value in the feature map and/convolution kernel; multiple second threads are controlled to read the feature map and/convolution kernel according to the index position eigenvalues, and use the read eigenvalues to perform convolution processing to obtain convolution features. Therefore, for the matrix multiplication convolution method, for the convolution type with large images and few channels, due to the small number of channels, in order to make full use of computing resources, the feature map and/or convolution can be pre-calculated through multiple first scenes The index position of the eigenvalue in the product kernel, when the index position of the eigenvalue is known, multiple second threads can read the feature map and/or the eigenvalue in the convolution kernel according to the index position for calculation, instead of In one calculation, the indexes of the feature values calculated by all threads point to the same point of the feature map and/convolution kernel in each channel, which reduces the situation of filling data 0 because the index position is not known and the data cannot be read, so as to fully Using each thread for convolution calculation reduces the waste of GPU resources and improves the efficiency of convolution operations.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,而非限制本公开。根据下面参考附图对示例性实施例的详细说明,本公开的其它特征及方面将变得清楚。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the accompanying drawings.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。The accompanying drawings here are incorporated into the description and constitute a part of the present description. These drawings show embodiments consistent with the present disclosure, and are used together with the description to explain the technical solution of the present disclosure.
图1示出根据本公开实施例的特征图尺寸的示意图。FIG. 1 shows a schematic diagram of feature map dimensions according to an embodiment of the disclosure.
图2示出根据本公开实施例的矩阵乘运算的卷积过程的示意图。FIG. 2 shows a schematic diagram of a convolution process of a matrix multiplication operation according to an embodiment of the present disclosure.
图3示出根据本公开实施例的卷积操作读取特征值过程的示意图。Fig. 3 shows a schematic diagram of a process of reading feature values by a convolution operation according to an embodiment of the present disclosure.
图4示出根据本公开实施例的图像处理方法的流程图。FIG. 4 shows a flowchart of an image processing method according to an embodiment of the present disclosure.
图5示出根据公开实施例的图像处理方法的一个应用场景示意图。Fig. 5 shows a schematic diagram of an application scenario of an image processing method according to a disclosed embodiment.
图6示出根据本公开实施例的一种图像处理装置的框图。Fig. 6 shows a block diagram of an image processing device according to an embodiment of the present disclosure.
图7示出根据本公开实施例的一种电子设备的框图。Fig. 7 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
图8示出根据本公开实施例的一种电子设备的框图。Fig. 8 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
具体实施方式detailed description
以下将参考附图详细说明本公开的各种示例性实施例、特征和方面。附图中相同的附图标记表示功能相同或相似的元件。尽管在附图中示出了实施例的各种方面,但是除非特别指出,不必按比例绘制附图。Various exemplary embodiments, features, and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numbers in the figures indicate functionally identical or similar elements. While various aspects of the embodiments are shown in drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
在这里专用的词“示例性”意为“用作例子、实施例或说明性”。这里作为“示例性”所说明的任何实施例不必解释为优于或好于其它实施例。The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as superior or better than other embodiments.
本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。The term "and/or" in this article is just an association relationship describing associated objects, which means that there can be three relationships, for example, A and/or B can mean: A exists alone, A and B exist simultaneously, and there exists alone B these three situations. In addition, the term "at least one" herein means any one of a variety or any combination of at least two of the more, for example, including at least one of A, B, and C, which may mean including from A, Any one or more elements selected from the set formed by B and C.
另外,为了更好地说明本公开,在下文的具体实施方式中给出了众多的具体细节。本领域技术人员应当理解,没有某些具体细节,本公开同样可以实施。在一些实例中,对于本领域技术人员熟知的方法、手段、元件和电路未作详细描述,以便于凸显本公开的主旨。In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific implementation manners. It will be understood by those skilled in the art that the present disclosure may be practiced without some of the specific details. In some instances, methods, means, components and circuits that are well known to those skilled in the art have not been described in detail so as to obscure the gist of the present disclosure.
如背景技术所述,相关技术中的卷积操作的效率有待提高,为了提高卷积操作的效率,可以基于张量计算单元(Tensor Core)进行卷积操作。Tensor Core是一种矩阵乘累加的计算单元,其在一个周期可以完成多次的乘加操作,可以达到非常高的计算性能。针对A100型号的GPU,Tensor Core的int8精度的计算性能甚至可以达到624TOPS。芯片算力的增加主要是为了加速卷积/矩阵乘法一类的高频计算密集型算子,但是也带来了如何高效利用算力的困难,即如何高效地在Tensor Core上实现卷积算子。As described in the background technology, the efficiency of the convolution operation in the related art needs to be improved. In order to improve the efficiency of the convolution operation, the convolution operation can be performed based on a tensor computing unit (Tensor Core). Tensor Core is a matrix multiply-accumulate computing unit, which can complete multiple multiply-accumulate operations in one cycle, and can achieve very high computing performance. For the A100 model GPU, the computing performance of Tensor Core's int8 precision can even reach 624TOPS. The increase in chip computing power is mainly to accelerate high-frequency calculation-intensive operators such as convolution/matrix multiplication, but it also brings about the difficulty of how to efficiently use computing power, that is, how to efficiently implement convolution operations on Tensor Core. son.
典型的卷积神经网络(CNN)由输入层(Input)、卷积层(Conv)、激活函数(Relu)、全连接层(FC)等组成。其中,原始的图像数据经过网络,逐渐抽取出其底层特征,最后形成高级语义特征。A typical convolutional neural network (CNN) consists of an input layer (Input), a convolutional layer (Conv), an activation function (Relu), and a fully connected layer (FC). Among them, the original image data passes through the network, gradually extracts its underlying features, and finally forms high-level semantic features.
卷积操作就是图像的特征图(Feature Map)与卷积核(Filter Kernel)进行乘加运算,抽取出图像信息的过程。卷积操作是神经网络中最耗时的运算,深度学习模型的大部分时间开销都在卷积算子上,卷积算子的性能对程序性能有着重要影响。The convolution operation is the process of multiplying and adding the feature map (Feature Map) of the image and the filter kernel (Filter Kernel) to extract the image information. The convolution operation is the most time-consuming operation in the neural network. Most of the time overhead of the deep learning model is on the convolution operator. The performance of the convolution operator has an important impact on the program performance.
根据特征图(Feature Map)的尺寸大小,可以将卷积类型分为大图少通道类型和小图多通道类型,如图1所示。其中特征图的三个尺寸“长×宽×通道”标注于特征图的上方,如224×224×3、56×56×64等。卷积核尺寸“长×宽”标注于卷积核的下方,如7x7、1x1等。According to the size of the feature map (Feature Map), the convolution type can be divided into a large image less channel type and a small image multi channel type, as shown in Figure 1. The three dimensions of the feature map "length × width × channel" are marked on the top of the feature map, such as 224×224×3, 56×56×64, etc. The convolution kernel size "length × width" is marked below the convolution kernel, such as 7x7, 1x1, etc.
大图少通道类型:这种类型的卷积一般存在于神经网络的开始阶段,它的特点是特征图的长和宽较大(即大图),比如224,但是通道数目比较小(即多通道),比如3。这 种卷积类型属于访存密集型运算,Tensor Core的计算能力对于这种类型得不到充分的发挥。Large image and few channel type: This type of convolution generally exists in the initial stage of the neural network. It is characterized by a large length and width of the feature map (ie, a large image), such as 224, but the number of channels is relatively small (ie, more channel), such as 3. This type of convolution is a memory-intensive operation, and the computing power of Tensor Core cannot be fully utilized for this type.
小图多通道类型:这种类型的卷积存在于神经网络的中间和末尾阶段,它的特点是特征图的长和宽较小(即小图),比如56/28/14等,但是通道数目比较大(即多通道),比如64/128/256等。这种卷积类型属于计算密集型运算,很适合发挥Tensor Core的计算能力。Small image multi-channel type: This type of convolution exists in the middle and end stages of the neural network. It is characterized by a small length and width of the feature map (ie small image), such as 56/28/14, etc., but the number of channels Relatively large (that is, multi-channel), such as 64/128/256, etc. This type of convolution is a computationally intensive operation, which is very suitable for utilizing the computing power of Tensor Core.
目前TensorCore上采用的卷积算法主要是隐式矩阵乘算法。矩阵乘法的计算形式可以表述为两个尺寸为M×K的矩阵A和K×N的矩阵B相乘,A中每一行的第K个元素都与B中对应列的第K个元素对应相乘,得到M×N的矩阵C的过程。Currently, the convolution algorithm used on TensorCore is mainly an implicit matrix multiplication algorithm. The calculation form of matrix multiplication can be expressed as the multiplication of two matrices A of M×K and matrix B of K×N, and the Kth element of each row in A corresponds to the Kth element of the corresponding column in B Multiply to get the process of matrix C of M×N.
GPU的编程模型往往包含三层:线程网(Grid)、线程块(Thread Block,TB)和线程(Thread);其中,线程块是任务分配的基本单元,足够多的线程块能保证GPU的硬件计算单元得到充分的发挥。在本公开实施例中,矩阵乘法利用分块技术,将整个大的矩阵乘任务划分成多个小矩阵的乘法任务,然后将每一块小任务分配给不同的线程块来执行。例如,矩阵乘运算会对矩阵C(M×N维度)进行任务划分,每一个线程块计算Mtile×Ntile的小矩阵块,其中,Mtile为M维度特征块的尺寸,Ntile为N维度特征块的尺寸。例如,当M=N=1024时,在M和N维度可以按照Mtile=Ntile=128进行分块,这样一共产生(1024/128)x(1024/128)=64个特征块。对于T4型号的GPU来说,至少需要40个线程块才能用上全部的GPU计算单元SM(Streaming Multiprocessor)。The programming model of GPU often includes three layers: thread network (Grid), thread block (Thread Block, TB) and thread (Thread); among them, thread block is the basic unit of task allocation, and enough thread blocks can ensure that the GPU hardware The computing unit is fully utilized. In the embodiment of the present disclosure, the matrix multiplication uses a block technology to divide the entire large matrix multiplication task into multiple small matrix multiplication tasks, and then assign each small task to a different thread block for execution. For example, the matrix multiplication operation will divide the task of the matrix C (M×N dimension), and each thread block calculates a small matrix block of Mtile×Ntile, where Mtile is the size of the M-dimensional feature block, and Ntile is the size of the N-dimensional feature block. size. For example, when M=N=1024, Mtile=Ntile=128 can be divided into blocks in M and N dimensions, so that a total of (1024/128)x(1024/128)=64 feature blocks are generated. For a T4 model GPU, at least 40 thread blocks are required to use all GPU computing units SM (Streaming Multiprocessor).
然而,把大图少通道的卷积类型转换成矩阵乘后,矩阵乘的尺寸如图2所示,矩阵A的M维度和矩阵B的N维度尺寸很大,生成的特征块足够利用GPU的硬件资源;而K维度的尺寸却很小,在GPU中,会通过下发的矩阵乘加运算(matrix multiply and accumulate,MMA)指令来进行卷积运算,示例性的,一个MMA指令所处理的最小矩阵单元在M×N维度是16×8,在K维度是8。因此,在K维度尺寸很小的情况下,甚至会小于MMA指令中M×N×K的K的大小。However, after converting the convolution type with large images and few channels into matrix multiplication, the size of matrix multiplication is shown in Figure 2. The M dimension of matrix A and the N dimension of matrix B are large, and the generated feature blocks are sufficient to utilize GPU Hardware resources; while the size of the K dimension is very small, in the GPU, the convolution operation will be performed through the issued matrix multiply and accumulate (MMA) instruction, for example, the processing of an MMA instruction The minimum matrix unit is 16×8 in M×N dimension and 8 in K dimension. Therefore, when the size of the K dimension is very small, it may even be smaller than the K size of M×N×K in the MMA instruction.
这里以T4型号的GPU在FP16级别精度的MMA指令为例,其M×N×K的大小为16×8×8;当卷积核的通道数小于8时,就要在通道末尾填充0,使其达到8的倍数后才能发送到Tensor Core上执行。通道末尾填充的0越多,无效的冗余操作就越多,Tensor Core的利用率就越低。Here we take the MMA instruction of the T4 model GPU at the FP16 level of precision as an example. The size of M×N×K is 16×8×8; when the number of channels of the convolution kernel is less than 8, it is necessary to fill 0 at the end of the channel. Only after it reaches a multiple of 8 can it be sent to the Tensor Core for execution. The more 0s are filled at the end of the channel, the more redundant redundant operations are invalid, and the lower the utilization rate of Tensor Core is.
图3展示了尺寸3×3大小、通道数为2的卷积核由K=8的MMA指令执行时产生的问题。由于GPU使用单指令多线程(Single Instruction Multiple Threads,SIMT)的编程模式的限制,同属于一个线程束Warp的不同线程会执行相同的指令,因此线程T0、T1、T2、T3计算的索引都指向了各通道中卷积核的第一个点F(0,0)。但是由于卷积核的通道数只有2,而MMA指令的K方向大小为8,因此就需要再MMA指令中读取不到数值的K方向上补充6个0,一个线程读取2个数据,那么只有线程T0读取到了数据,T1、T2、T3读取的数据都是无效的填充数据0。这就会造成Tensor Core的利用率只有25%,带来严重的资源浪费。而卷积的滑窗操作(Sliding Window)会依次遍历完卷积核的所有点,从F(0,0),F(0,1)一直遍历到F(2,2),共需要9次才能遍历完3x3的卷积核。Figure 3 shows the problem when a convolution kernel with a size of 3×3 and a channel number of 2 is executed by an MMA instruction with K=8. Due to the limitation of GPU using Single Instruction Multiple Threads (Single Instruction Multiple Threads, SIMT) programming mode, different threads belonging to the same thread warp will execute the same instruction, so the indexes calculated by threads T0, T1, T2, and T3 all point to The first point F(0,0) of the convolution kernel in each channel. However, since the number of channels of the convolution kernel is only 2, and the size of the K direction of the MMA instruction is 8, it is necessary to add 6 0s in the K direction where the value cannot be read in the MMA instruction, and one thread reads 2 data. Then only thread T0 reads the data, and the data read by T1, T2, and T3 are all invalid padding data 0. This will cause the utilization rate of Tensor Core to be only 25%, resulting in a serious waste of resources. The convolution sliding window operation (Sliding Window) will traverse all the points of the convolution kernel in turn, from F(0,0), F(0,1) to F(2,2), a total of 9 times In order to traverse the 3x3 convolution kernel.
在本公开实施例中,通过多个第一线程计算特征图和/卷积核中的特征值的索引位置;控制多个第二线程按照所述索引位置读取特征图和/卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征。由此,针对矩阵乘卷积方式而言,对于大图少通道的卷积类型,由于通道数较少,为便于充分利用计算资源,可以通过多个第一现场预先计算出特征图和/卷积核中的特征值的索引位置,在已知特征值的索引位置的情况下,多个第二线程可以按照索引位置去读取特征图和/卷积核中的特征值进行计算,而非在一次计算中所有线程计算的特征值的索引都指向各通道中特征图和/卷积核的同一个点,减少了由于不知道索引位置读取不到数据而填充数据0的情况,以充分利用各线程进行卷积计算,减少了GPU资源浪费,提高了卷积操作的效率。In the embodiment of the present disclosure, multiple first threads are used to calculate the index position of the feature value in the feature map and/convolution kernel; multiple second threads are controlled to read the feature map and/convolution kernel according to the index position eigenvalues, and use the read eigenvalues to perform convolution processing to obtain convolution features. Therefore, for the matrix multiplication convolution method, for the convolution type with large images and few channels, due to the small number of channels, in order to make full use of computing resources, the feature map and/or convolution can be pre-calculated through multiple first scenes The index position of the eigenvalue in the product kernel, when the index position of the eigenvalue is known, multiple second threads can read the feature map and/or the eigenvalue in the convolution kernel according to the index position for calculation, instead of In one calculation, the indexes of the feature values calculated by all threads point to the same point of the feature map and/convolution kernel in each channel, which reduces the situation of filling data 0 because the index position is not known and the data cannot be read, so as to fully Using each thread for convolution calculation reduces the waste of GPU resources and improves the efficiency of convolution operations.
图像处理方法步骤的执行主体可以为硬件执行,或者通过处理器运行计算机可执行代码的方式执行。在一种可能的实现方式中,所述图像处理方法可以由终端设备或服务器等电子设备执行,终端设备可以为用户设备(User Equipment,UE)、移动设备、用户终端、终端、蜂窝电话、无绳电话、个人数字助理(Personal Digital Assistant,PDA)、手持设备、计算设备、车载设备、可穿戴设备等,所述方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。The subject of execution of the steps of the image processing method may be executed by hardware, or executed by a processor running computer executable codes. In a possible implementation, the image processing method may be executed by electronic equipment such as a terminal device or a server, and the terminal device may be user equipment (User Equipment, UE), mobile device, user terminal, terminal, cellular phone, cordless Phones, personal digital assistants (Personal Digital Assistant, PDA), handheld devices, computing devices, vehicle-mounted devices, wearable devices, etc., the method can be realized by calling the computer-readable instructions stored in the memory by the processor.
为便于描述,本说明书一个或多个实施例中,图像处理方法的执行主体可以是图形处理器(graphics processing unit,GPU),后文以执行主体为图形处理器为例,对该方法的实施方式进行介绍。可以理解,该方法的执行主体为GPU只是一种示例性的说明,并不应理解为对该方法的限定。For ease of description, in one or more embodiments of this specification, the execution subject of the image processing method may be a graphics processing unit (graphics processing unit, GPU). way to introduce. It can be understood that the execution subject of the method is the GPU, which is only an exemplary description, and should not be understood as a limitation of the method.
图4示出根据本公开实施例的图像处理方法的流程图,如图4所示,所述图像处理方法包括:FIG. 4 shows a flowchart of an image processing method according to an embodiment of the present disclosure. As shown in FIG. 4, the image processing method includes:
在步骤S11中,对目标图像中的图像特征进行提取,得到用于表征图像特征的特征图。In step S11, image features in the target image are extracted to obtain a feature map for characterizing image features.
图像在计算机技术中的表达可以是一个个像素值组成的矩阵,那么对图像的分析可以是对表征图像像素值的矩阵进行分析。The expression of an image in computer technology can be a matrix composed of pixel values, so the analysis of the image can be the analysis of the matrix representing the pixel values of the image.
这里的图像特征可以用来表征图像的像素值,该图像特征可以是图像的像素值组成的矩阵,或者也可以是经多次卷积操作后得到的图像特征,本公开对此不做限定。The image feature here may be used to represent the pixel value of the image, and the image feature may be a matrix composed of the pixel values of the image, or may be an image feature obtained after multiple convolution operations, which is not limited in the present disclosure.
在步骤S12中,通过多个第一线程计算特征图和/卷积核中的特征值的索引位置。In step S12, index positions of feature values in feature maps and/or convolution kernels are calculated by multiple first threads.
卷积核的具体表现形式可以是一个矩阵,该矩阵包含三个维度“长×宽×通道”,该矩阵中的特征值为卷积时的权值,通过该权重,可以通过卷积操作提取想要的图像特征,抑制其它图像特征。而特征图的具体表现形式同样也是一个矩阵,包含“长×宽×通道”三个维度,该矩阵中的特征值用来表征图像中的像素值。The specific form of convolution kernel can be a matrix, which contains three dimensions "length × width × channel". The eigenvalues in this matrix are the weights during convolution. Through this weight, it can be extracted by convolution operation. desired image features and suppress other image features. The specific representation of the feature map is also a matrix, which contains three dimensions of "length × width × channel". The eigenvalues in this matrix are used to represent the pixel values in the image.
数据在存储空间中存储时会有一个索引位置,用来表征数据在存储空间中的存储位置。在本公开实施例中,可以直接依据索引位置来读取存储空间中的特征值进行卷积计算,而无需将特征图展开为矩阵再进行卷积计算,能够节省内存资源。When data is stored in the storage space, there will be an index position, which is used to represent the storage location of the data in the storage space. In the embodiment of the present disclosure, the feature value in the storage space can be read directly according to the index position to perform convolution calculation, without expanding the feature map into a matrix and then performing convolution calculation, which can save memory resources.
而针对大图少通道卷积而言,由于通道数较少,为便于充分利用计算资源,多个第一线程可以在特征图和/卷积核的长和宽方向上顺序地读取特征值,以充分利用各线程进 行索引位置的计算。因此,可以预设一个线程顺序,作为线程在特征图和/卷积核的长和宽方向上计算索引位置的顺序,各第一线程可以并行地计算特征值的索引位置,每个第一线程计算不同特征值的索引位置。For the convolution of large images with few channels, due to the small number of channels, in order to make full use of computing resources, multiple first threads can sequentially read feature values in the length and width directions of feature maps and/or convolution kernels , to make full use of each thread to calculate the index position. Therefore, a thread order can be preset as the order in which the threads calculate the index positions in the feature map and/or the length and width directions of the convolution kernel, and each first thread can calculate the index positions of the feature values in parallel, and each first thread Compute the index positions of the different eigenvalues.
例如,以计算卷积核的索引位置为例,对于编号为0、1、2、3的4个线程,其编号可以作为线程顺序,那么,0号线程在卷积核的长和宽方向上计算第1个特征值的索引位置,1号线程计算第2个特征值的索引位置,2号线程计算第3个特征值的索引位置,3号线程计算第4个特征值的索引位置。For example, taking the calculation of the index position of the convolution kernel as an example, for the four threads numbered 0, 1, 2, and 3, their numbers can be used as the thread order, then, thread 0 is in the length and width directions of the convolution kernel Calculate the index position of the first eigenvalue, thread No. 1 calculates the index position of the second eigenvalue, thread No. 2 calculates the index position of the third eigenvalue, thread No. 3 calculates the index position of the fourth eigenvalue.
需要说明的是,线程每一次读取特征值时,可以读取2个通道上的值。例如,对于长宽为3x3、通道数为2的卷积核,按照步骤S12中的顺序,在1个线程计算2个通道的情况下,只需要执行3次MMA指令就能对全部的特征值进行计算,效率较高。It should be noted that each time a thread reads a characteristic value, it can read values on two channels. For example, for a convolution kernel with a length and width of 3x3 and a number of channels of 2, according to the sequence in step S12, in the case of 1 thread computing 2 channels, it only needs to execute the MMA instruction 3 times to calculate all the eigenvalues Calculations are more efficient.
在步骤S13中,控制多个第二线程按照所述索引位置读取特征图和/卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征,所述卷积特征用于表征对所述图像特征的提取结果。In step S13, multiple second threads are controlled to read feature maps and/or feature values in the convolution kernel according to the index positions, and perform convolution processing using the read feature values to obtain convolution features, The convolution feature is used to characterize the extraction result of the image feature.
在确定索引位置后,由于索引位置是已知的,那么各第二线程在进行计算时可以直接根据索引位置读取特征图和/卷积核中的每个特征值,第二线程在已知特征值的索引位置的情况下,可以直接根据索引位置读取特征值作为卷积计算指令中的参数,因此可以尽可能地将一次卷积计算指令中各维度计算所需的值排满,减少需要补0的情况。After determining the index position, since the index position is known, each second thread can directly read each feature value in the feature map and/convolution kernel according to the index position when performing calculations, and the second thread is in the known In the case of the index position of the eigenvalue, the eigenvalue can be directly read according to the index position as a parameter in the convolution calculation instruction, so the values required for each dimension calculation in a convolution calculation instruction can be filled as much as possible, reducing It is necessary to add 0.
在得到存储空间中的特征值后,即可利用读取到的所述特征值进行卷积处理,得到卷积特征,具体卷积处理的过程可以是基于矩阵乘进行的卷积处理,尤其适用于进行大图少通道类型的卷积处理,处理效率较高。After obtaining the eigenvalues in the storage space, the read eigenvalues can be used to perform convolution processing to obtain convolution features. The specific convolution processing process can be convolution processing based on matrix multiplication, which is especially suitable for It is suitable for convolution processing of large image and less channel type, and the processing efficiency is high.
需要说明的是,第一线程和第二线程可以是相同的线程,也可以是不同的线程,可以理解的是,本公开实施例中的“第一”和“第二”用于区分所描述的对象,而不应当理解为对描述对象的次序、指示或暗示相对重要性等其它限定。It should be noted that the first thread and the second thread may be the same thread or different threads. It can be understood that the "first" and "second" in the embodiments of the present disclosure are used to distinguish the described It should not be understood as other restrictions on the order of describing objects, indicating or implying relative importance, etc.
在本公开实施例中,通过多个第一线程计算特征图和/卷积核中的特征值的索引位置;控制多个第二线程按照所述索引位置读取特征图和/卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征。由此,针对矩阵乘卷积方式而言,对于大图少通道的卷积类型,由于通道数较少,为便于充分利用计算资源,可以通过多个第一现场预先计算出特征图和/卷积核中的特征值的索引位置,在已知特征值的索引位置的情况下,多个第二线程可以按照索引位置去读取特征图和/卷积核中的特征值进行计算,而非在一次计算中所有线程计算的特征值的索引都指向各通道中特征图和/卷积核的同一个点,减少了由于不知道索引位置读取不到数据而填充数据0的情况,以充分利用各线程进行卷积计算,减少了GPU资源浪费,提高了卷积操作的效率。In the embodiment of the present disclosure, multiple first threads are used to calculate the index position of the feature value in the feature map and/convolution kernel; multiple second threads are controlled to read the feature map and/convolution kernel according to the index position eigenvalues, and use the read eigenvalues to perform convolution processing to obtain convolution features. Therefore, for the matrix multiplication convolution method, for the convolution type with large images and few channels, due to the small number of channels, in order to make full use of computing resources, the feature map and/or convolution can be pre-calculated through multiple first scenes The index position of the eigenvalue in the product kernel, when the index position of the eigenvalue is known, multiple second threads can read the feature map and/or the eigenvalue in the convolution kernel according to the index position for calculation, instead of In one calculation, the indexes of the feature values calculated by all threads point to the same point of the feature map and/convolution kernel in each channel, which reduces the situation of filling data 0 because the index position is not known and the data cannot be read, so as to fully Using each thread for convolution calculation reduces the waste of GPU resources and improves the efficiency of convolution operations.
在一种可能的实现方式中,所述利用读取到的所述特征值进行卷积处理,得到卷积特征,包括:将读取到的特征值在矩阵乘加运算MMA指令的通道维度K进行排列,进行矩阵乘加运算,得到卷积特征。In a possible implementation manner, performing convolution processing using the read eigenvalues to obtain convolution features includes: adding the read eigenvalues to the channel dimension K of the matrix multiplication and addition operation MMA instruction Arrange and perform matrix multiplication and addition operations to obtain convolution features.
在矩阵乘运算中,会通过MMA指令来进行矩阵乘运算,针对MMA指令而言,其通 道维度K方向上的最小尺寸是8,也就是说,在执行一次MMA执行时,K维度能够计算8份特征值,那么,在已知特征图和/卷积核特征值的索引位置的情况下,可以依据索引位置依次读取8个通道的特征值,作为MMA指令计算的数值,这样可以充分利用第二线程的运算能力,减少了GPU资源浪费,提高了卷积操作的效率。In the matrix multiplication operation, the MMA instruction is used to perform the matrix multiplication operation. For the MMA instruction, the minimum size in the K direction of the channel dimension is 8. That is to say, when executing an MMA execution, the K dimension can calculate 8 eigenvalue, then, in the case of knowing the index position of the feature map and/or convolution kernel feature value, the feature values of the 8 channels can be read in turn according to the index position, as the value calculated by the MMA instruction, so that it can be fully utilized The computing power of the second thread reduces the waste of GPU resources and improves the efficiency of convolution operations.
在一种可能的实现方式中,通过多个第一线程计算特征图和/卷积核中的特征值的索引位置,包括:根据特征图和/卷积核中的特征值在特征图和/卷积核中的位置,以及所述特征图和/卷积核中的各特征值在存储空间中的数据排布规则,确定各特征值在存储空间中的索引位置。In a possible implementation manner, calculating the feature map and/the index position of the feature value in the convolution kernel through multiple first threads includes: according to the feature map and/the feature value in the convolution kernel in the feature map and/ The position in the convolution kernel, and the feature map and/or the data arrangement rule of each feature value in the convolution kernel in the storage space determine the index position of each feature value in the storage space.
数据在存储空间中存储时会遵循一定的排布规则,对于特征矩阵而言,常见的排布规则有两种:NCHW排布和NHWC排布,其中N代表特征图数量,C代表通道,H代表矩阵的高度(长),W代表宽度。NCHW排布的规则即为按照[N,C,H,W]的优先级顺序对矩阵的值进行排布,而NHWC排布即为按照[N,H,W,C]的优先级顺序对矩阵的值进行排布。When the data is stored in the storage space, it will follow certain arrangement rules. For the feature matrix, there are two common arrangement rules: NCHW arrangement and NHWC arrangement, where N represents the number of feature maps, C represents channels, and H Represents the height (length) of the matrix, and W represents the width. The rule of NCHW arrangement is to arrange the values of the matrix according to the priority order of [N,C,H,W], and the NHWC arrangement is to arrange the values according to the priority order of [N,H,W,C]. Arrange the values of the matrix.
以卷积核为例,卷积核的各特征值的通道、高度、宽度均为已知的,即卷积核中的特征值在卷积核中的位置是已知的,因此,在已知卷积核的特征值在数据存储空间中的数据排布规则的情况下,即可根据各特征值在卷积核中的位置,以及在数据存储空间中的数据排布规则,确定出各特征值在存储空间中的索引位置。Taking the convolution kernel as an example, the channel, height, and width of each eigenvalue of the convolution kernel are known, that is, the position of the eigenvalue in the convolution kernel in the convolution kernel is known. Knowing the data arrangement rules of the eigenvalues of the convolution kernel in the data storage space, the position of each eigenvalue in the convolution kernel and the data arrangement rules in the data storage space can be used to determine each The index position of the feature value in the storage space.
在本公开实施例中,通过根据特征图和/卷积核中的特征值在特征图和/卷积核中的位置,以及特征图和/卷积核中的各特征值在存储空间中的数据排布规则,确定各特征值在存储空间中的索引位置。由此,能够精确地计算出各线程要读取的特征图和/卷积核中的特征值的索引位置。In the embodiment of the present disclosure, according to the position of the feature value in the feature map and/convolution kernel in the feature map and/convolution kernel, and the storage space of each feature value in the feature map and/convolution kernel The data arrangement rules determine the index position of each feature value in the storage space. In this way, the feature map to be read by each thread and/or the index position of the feature value in the convolution kernel can be accurately calculated.
在一种可能的实现方式中,所述通过多个第一线程计算特征图和/卷积核中的特征值的索引位置,包括:按照至少两个线程的标识ID的顺序,控制至少两个线程分别计算特征图和/卷积核中的特征值的索引位置。In a possible implementation manner, the calculating the index position of the feature map and/or the feature value in the convolution kernel through multiple first threads includes: controlling at least two Threads compute index positions of feature maps and/or feature values in kernels respectively.
以计算卷积核的特征值为例,在GPU中各线程自身是具备一个标识ID的,该ID用来对不同的线程进行区分,该ID例如可以是:T0、T1、T2、T3,那么线程的标识ID的顺序即可以是数字由小到大排列的[T0、T1、T2、T3]的顺序,需要说明的是该顺序为一个循环的顺序,即T3的顺序后面会继续再连接[T0、T1、T2、T3]的顺序,直至将卷积核中的特征值的索引位置计算完毕。Taking the calculation of the eigenvalues of the convolution kernel as an example, each thread in the GPU has an identification ID, which is used to distinguish different threads. The ID can be: T0, T1, T2, T3, for example, then The order of thread IDs can be the order of [T0, T1, T2, T3] in ascending order of numbers. It should be noted that this order is a circular order, that is, the order of T3 will continue to be connected after [ T0, T1, T2, T3] until the index position of the feature value in the convolution kernel is calculated.
在本公开实施例中,由于线程自身具备ID,因此按照各线程的标识ID的顺序,控制各线程分别计算特征图和/卷积核中的特征值的索引位置,使得各线程并行地对各特征值的索引位置进行计算,提高了对索引位置计算的效率。In the embodiment of the present disclosure, since the thread itself has an ID, each thread is controlled to calculate the index position of the feature map and/or the feature value in the convolution kernel according to the order of the identification ID of each thread, so that each thread parallelizes each The index position of the feature value is calculated, which improves the efficiency of the index position calculation.
在一种可能的实现方式中,所述通过多个第一线程计算特征图和/卷积核中的特征值的索引位置,包括:将所述索引位置的特征值加载到共享内存(Shared Memory,SMem)中,以供各线程使用。In a possible implementation manner, the calculating the feature map and/the index position of the feature value in the convolution kernel through multiple first threads includes: loading the feature value of the index position into a shared memory (Shared Memory , SMem) for use by each thread.
虽然共享内存的大小有限,但是其具备较高的读写速度和带宽,因此,考虑到索引位置的值(索引值)占内存较小,那么,为了提高对索引值的读写效率,可以将索引位 置的值存储到SMem中,进而提高卷积操作的效率,以提高图像处理操作的效率。Although the size of the shared memory is limited, it has high read and write speed and bandwidth. Therefore, considering that the value of the index position (index value) occupies a small amount of memory, then, in order to improve the efficiency of reading and writing the index value, you can use The value of the index position is stored in the SMem, thereby improving the efficiency of the convolution operation to improve the efficiency of the image processing operation.
在一种可能的实现方式中,所述控制多个第二线程按照所述索引位置读取卷积核中的特征值,包括:控制所述多个第二线程将索引位置处的特征值读入到各自的寄存器中;所述利用读取到的所述特征值进行卷积处理,得到卷积特征,包括:利用所述寄存器中的各个特征值进行卷积处理,得到卷积特征。In a possible implementation manner, the controlling the multiple second threads to read the feature values in the convolution kernel according to the index positions includes: controlling the multiple second threads to read the feature values at the index positions input into respective registers; said using the read feature values to perform convolution processing to obtain convolution features includes: using each feature value in the registers to perform convolution processing to obtain convolution features.
在使用Tensor Core时,MMA指令经常与ldmatrix指令共同使用。通常,MMA指令计算所需的矩阵A、矩阵B的数据从全局存储空间(Global Memory,GMem)读入后会放到SMem中,然后使用ldmatrix指令按照特定的矩阵形状将矩阵A、矩阵B的数据读入各个线程的寄存器中。将数据放入到SMem中的好处是线程之间存在数据共享,降低了从GMem中读取数据的延迟,然而对于大图少通道类型的矩阵乘运算而言,需要共享的卷积数据很少,把数据放到SMem中缓存反而会增加一次读写SMem的延迟。When using Tensor Core, the MMA instruction is often used together with the ldmatrix instruction. Usually, the data of matrix A and matrix B required for MMA instruction calculation will be read from the global memory space (Global Memory, GMem) and placed in SMem, and then use the ldmatrix instruction to store the data of matrix A and matrix B according to a specific matrix shape. Data is read into the registers of each thread. The advantage of putting data into SMem is that there is data sharing between threads, which reduces the delay of reading data from GMem. However, for matrix multiplication operations with large images and few channels, there is little convolution data that needs to be shared. , Putting the data in the SMem cache will increase the delay of reading and writing SMem.
因此,在本公开实施例中,直接将MMA指令中所需的数据读入到各个线程的寄存器中,充分利用了大图少通道类型卷积的特点,降低了数据读取的延迟。Therefore, in the embodiment of the present disclosure, the data required in the MMA instruction is directly read into the registers of each thread, making full use of the characteristics of large image and less channel type convolution, and reducing the delay of data reading.
在本公开实施例中,在进行卷积运算的过程中,可以对卷积运算的矩阵进行分块处理,将特征矩阵划分为多个特征块,然后并行地对多个特征块进行运算,以提高卷积的效率,具体地,可以确定TB,线程束Warp及K维度的多种可能的特征块尺寸,最终生成对应的多种图形处理器核函数kernel,方便后期根据图像特征的尺寸来选择合适的kernel,对图像特征进行卷积处理。下面对三个维度分别进行详细的说明。In the embodiment of the present disclosure, in the process of performing the convolution operation, the matrix of the convolution operation can be divided into blocks, the feature matrix can be divided into multiple feature blocks, and then the multiple feature blocks can be operated in parallel to obtain To improve the efficiency of convolution, specifically, it is possible to determine various possible feature block sizes of TB, thread warp, and K dimension, and finally generate a variety of corresponding graphics processor kernel function kernels, which are convenient for later selection according to the size of image features A suitable kernel performs convolution processing on image features. The three dimensions are described in detail below.
在一种可能的实现方式中,在所述对目标图像中的图像特征进行提取后,所述方法还包括:确定单个线程束Warp中能够处理的特征块的多种第一尺寸,并基于所述第一尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第一尺寸的最大值根据寄存器容量确定,所述第一尺寸的最小值为矩阵乘加运算指令计算的最小矩阵单元的尺寸,所述多种第一尺寸的值为所述最小值的倍数。In a possible implementation, after the image features in the target image are extracted, the method further includes: determining multiple first sizes of feature blocks that can be processed in a single warp, and based on the The first size is used to generate a graphics processor kernel function for feature block division; wherein, the maximum value of the first size is determined according to the register capacity, and the minimum value of the first size is the minimum calculated by the matrix multiply-add operation instruction The size of the matrix unit, the values of the multiple first sizes are multiples of the minimum value.
在GPU中,会通过下发的矩阵乘加运算(matrix multiply and accumulate,MMA)指令来进行卷积运算,示例性的,一个MMA指令所处理的最小矩阵单元在M×N维度是16×8,在K维度是8。In the GPU, the convolution operation is performed through the issued matrix multiply and accumulate (MMA) instruction. For example, the smallest matrix unit processed by an MMA instruction is 16×8 in the M×N dimension , which is 8 in the K dimension.
在单个Warp中,其能够处理的最小矩阵单元的尺寸即为MMA指令能够处理的最小矩阵单元的尺寸,而由于指令的运算是以2的指数幂的形式累加,因此单个Warp所能够处理的特征块的尺寸即为最小矩阵单元的尺寸再乘以2的指数幂,N可以为8、16、32、64,M可以为16、32、64、128,那么得到的M×N的值具体如表1所示。In a single Warp, the size of the smallest matrix unit that can be processed is the size of the smallest matrix unit that can be processed by the MMA instruction, and since the operation of the instruction is accumulated in the form of an exponential power of 2, the characteristics that can be processed by a single Warp The size of the block is the size of the smallest matrix unit multiplied by the power of 2, N can be 8, 16, 32, 64, M can be 16, 32, 64, 128, then the obtained value of M×N is as follows Table 1 shows.
而考虑到寄存器容量的限制,特征块的尺寸也不能无限的增大,其最大值可以根据寄存器容量来确定,由于寄存器容量的限制,寄存器中无法存储128x64的Warp特征块,因此,特征块的第一尺寸的最大值为128×32或64×64,具体如表1所示。Considering the limitation of the register capacity, the size of the feature block cannot be increased infinitely, and its maximum value can be determined according to the register capacity. Due to the limitation of the register capacity, the Warp feature block of 128x64 cannot be stored in the register. Therefore, the feature block The maximum value of the first size is 128×32 or 64×64, as shown in Table 1 for details.
Figure PCTCN2022078439-appb-000001
Figure PCTCN2022078439-appb-000001
Figure PCTCN2022078439-appb-000002
Figure PCTCN2022078439-appb-000002
表1 Warp级的特征块尺寸Table 1 Warp-level characteristic block size
在本公开实施例中,可以在Warp维度将所有的特征块的第一尺寸进行遍历,进而基于第一尺寸生成图形处理器核函数kernel,这样得到的kernel可以适用于对各种尺寸的图像特征进行切分,得到的kernel的普适性较高。In the embodiment of the present disclosure, the first size of all feature blocks can be traversed in the Warp dimension, and then the graphics processor kernel function kernel can be generated based on the first size, and the kernel obtained in this way can be applied to image features of various sizes Segmentation, the resulting kernel has high universality.
在一种可能的实现方式中,在所述对目标图像中的图像特征进行提取后,所述方法还包括:确定单个线程块TB中能够处理的特征块的多种第二尺寸,并基于所述第二尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第二尺寸的最小值为单个线程束Warp能够处理的特征块的第一尺寸,所述第二尺寸为所述第一尺寸的倍数,所述第二尺寸的最大值根据共享内存的容量和TB内线程数上限确定。In a possible implementation manner, after the image features in the target image are extracted, the method further includes: determining multiple second sizes of feature blocks that can be processed in a single thread block TB, and based on the The second size is used to generate a graphics processor kernel function for feature block division; wherein, the minimum value of the second size is the first size of a feature block that can be processed by a single thread warp, and the second size is the multiples of the first size, and the maximum value of the second size is determined according to the capacity of the shared memory and the upper limit of the number of threads in a TB.
一个TB中会包含一个或多个Warp,那么,第二尺寸的最小值即为单个线程束Warp能够处理的特征块的第一尺寸,第二尺寸也可以是第一尺寸的倍数,该倍数为2的指数幂,即2、4。表3中的M TB和N TB的具体值为第一尺寸的倍数。 A TB contains one or more warps, then the minimum value of the second size is the first size of the feature block that can be processed by a single thread warp, and the second size can also be a multiple of the first size, which is Powers of 2, ie 2, 4. The specific values of M TB and NT TB in Table 3 are multiples of the first size.
在一些GPU中,一个TB往往最多可以有1024个线程,即16个Warp,然而,在GPU中,线程数量为128-512个时运算效率较高,因此,往往不会运行16个Warp,因此,为了保证GPU运算效率,一个TB中最多运行8个Warp,即M TB×N TB的最大值为2×4或者4×2,如表2所示。 In some GPUs, a TB can often have up to 1024 threads, that is, 16 Warps. However, in GPUs, when the number of threads is 128-512, the calculation efficiency is higher, so 16 Warps are often not run, so , in order to ensure GPU computing efficiency, a maximum of 8 warps can be run in one TB, that is, the maximum value of M TB ×N TB is 2×4 or 4×2, as shown in Table 2.
M TB\N TB M TB \N TB 11 22 44
11 1x11x1 1x21x2 1x41x4
22 2x12x1 2x22x2 2x42x4
44 4x14x1 4x24x2 \\
表2 TB级的特征块尺寸。表中的数字表示相应Warp级特征块尺寸的倍数Table 2 Feature block size at TB level. The numbers in the table represent the multiples of the corresponding Warp-level feature block size
在本公开实施例中,可以在TB维度将所有的特征块的第二尺寸进行遍历,进而基于第二尺寸生成图形处理器核函数kernel,这样得到的kernel可以适用于对各种尺寸的图像特征进行切分,得到的kernel的普适性较高。In the embodiment of the present disclosure, the second size of all feature blocks can be traversed in the TB dimension, and then the graphics processor kernel function kernel can be generated based on the second size, and the kernel obtained in this way can be applied to image features of various sizes Segmentation, the resulting kernel has high universality.
如前文所述,在单个Warp中,其能够处理的最小矩阵单元的尺寸即为MMA指令能够处理的最小矩阵单元的尺寸,示例性的,一个MMA指令所处理的最小矩阵单元在M×N维度是16×8,在K维度是8。那么,单个TB中多种可能的K维度的尺寸包括k8、k16、k32等,如表3所示。As mentioned above, in a single Warp, the size of the smallest matrix unit that can be processed is the size of the smallest matrix unit that can be processed by the MMA instruction. For example, the smallest matrix unit processed by an MMA instruction is in the M×N dimension is 16×8, which is 8 in the K dimension. Then, various possible sizes of the K dimension in a single TB include k8, k16, k32, etc., as shown in Table 3.
KK 88 1616 3232
表3 K维度的分块大小Table 3 Block size of K dimension
在本公开实施例中,可以在特征块的K维度上对分组的第三尺寸进行遍历,进而基于多种可能的第三尺寸生成图形处理器核函数kernel,这样得到的kernel可以适用于对各种尺寸的图像特征进行切分,得到的kernel的普适性较高。In the embodiment of the present disclosure, the third size of the group can be traversed on the K dimension of the feature block, and then the kernel function kernel of the graphics processor can be generated based on various possible third sizes, and the kernel obtained in this way can be applied to each The image features of different sizes are segmented, and the obtained kernel has high universality.
请参阅图5,为本公开实施例的图像处理方法的一个应用场景示意图,在该应用场景 中,会预先计算好3×3的卷积核中各个特征值的索引位置:F(0,0),F(0,1),F(0,2),F(1,0),F(1,1),F(1,2),F(2,0),F(2,1),F(2,2),并放入SMem中;然后线程T0,T1,T2,T3依次从SMem中读取预先计算好的索引,图5中仅示出1次遍历中读取的F(0,0),F(0,1),F(0,2)和F(1,0),其中,1个线程读取相同长宽位置的2层通道的特征值,如图5所示,C0代表通道的第0层,C1代表通道的第1层,T0读取F(0,0)处的两个通道的特征值,T1读取F(0,1)处的两个通道的特征值,T2读取F(0,2)处的两个通道的特征值,T3读取F(1,0)处的两个通道的特征值,然后把相应的卷积核数据读入到各自的寄存器中。1个MMA指令可以由T0,T1,T2,T3四个线程一起执行,四个线程共读取图中所示的8个通道的数据后,执行一次MMA指令,该次执行中无需填充无效的0数据,提高了Tensor Core的利用率。Please refer to FIG. 5, which is a schematic diagram of an application scenario of the image processing method of the embodiment of the present disclosure. In this application scenario, the index position of each feature value in the 3×3 convolution kernel is pre-calculated: F(0,0 ),F(0,1),F(0,2),F(1,0),F(1,1),F(1,2),F(2,0),F(2,1) , F(2,2), and put it into SMem; then threads T0, T1, T2, T3 read the pre-calculated index from SMem in turn, and only the F( 0,0), F(0,1), F(0,2) and F(1,0), where one thread reads the feature values of the 2-layer channel at the same length and width position, as shown in Figure 5 , C0 represents the 0th layer of the channel, C1 represents the first layer of the channel, T0 reads the eigenvalues of the two channels at F(0,0), and T1 reads the two channels at F(0,1) Eigenvalues, T2 reads the eigenvalues of the two channels at F(0,2), T3 reads the eigenvalues of the two channels at F(1,0), and then reads the corresponding convolution kernel data into in their respective registers. One MMA instruction can be executed by four threads T0, T1, T2, and T3. After the four threads read the data of the 8 channels shown in the figure, the MMA instruction is executed once. There is no need to fill in invalid data during this execution. 0 data, which improves the utilization of Tensor Core.
从图5可以看出,在4个线程进行图像处理的情况下,4个线程共需执行3次MMA任务,便可以遍历完3x3的卷积核,第一次对双通道的F(0,0),F(0,1),F(0,2),F(1,0)进行处理,共计8通道的数据,可填满MMA指令的最小K维度8;第二次对双通道的F(1,1),F(1,2),F(2,0),F(2,1)进行处理,共计8通道的数据,可填满MMA指令的最小K维度8,第三次对双通道的F(2,2)进行处理,共计2通道的数据,无法填满MMA指令的最小K维度8,因此填充6个0来补齐。由此,与图3中的运算方式相比较,图3中一次执行MMA指令便需要填充6个0,而其需要共执行9次MMA指令,即共需要填充54个0,显然,相比较于图3中的技术而言,本公开实施例提供的图像处理方法,在对大图少通道的图像进行处理时,能够减少无效填充的0的数量,提高了Tensor Core的利用率。It can be seen from Figure 5 that in the case of 4 threads performing image processing, the 4 threads need to perform 3 MMA tasks in total, and then they can traverse the 3x3 convolution kernel. For the first time, the dual-channel F(0, 0), F(0,1), F(0,2), F(1,0) for processing, a total of 8 channels of data, which can fill the minimum K dimension 8 of the MMA instruction; the second time for the dual channel F(1,1), F(1,2), F(2,0), F(2,1) are processed, a total of 8 channels of data, which can fill the minimum K dimension 8 of the MMA instruction, the third time The two-channel F(2,2) is processed, and the data of two channels in total cannot fill the minimum K dimension of 8 in the MMA instruction, so it is filled with 6 zeros to make up. Therefore, compared with the operation method in Fig. 3, in Fig. 3, six 0s need to be filled for one execution of the MMA instruction, and a total of 9 MMA instructions need to be executed, that is, a total of 54 0s need to be filled. Obviously, compared with As far as the technology in Figure 3 is concerned, the image processing method provided by the embodiment of the present disclosure can reduce the number of invalid padding zeros and improve the utilization rate of Tensor Core when processing images with large images and few channels.
可以理解,本公开提及的上述各个方法实施例,在不违背原理逻辑的情况下,均可以彼此相互结合形成结合后的实施例,限于篇幅,本公开不再赘述。本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。It can be understood that the above-mentioned method embodiments mentioned in this disclosure can all be combined with each other to form a combined embodiment without violating the principle and logic. Due to space limitations, this disclosure will not repeat them. Those skilled in the art can understand that, in the above method in the specific implementation manner, the specific execution order of each step should be determined according to its function and possible internal logic.
此外,本公开还提供了图像处理装置、电子设备、计算机可读存储介质、程序,上述均可用来实现本公开提供的任一种图像处理方法,相应技术方案和描述和参见方法部分的相应记载,不再赘述。In addition, the present disclosure also provides image processing devices, electronic equipment, computer-readable storage media, and programs, all of which can be used to implement any image processing method provided in the present disclosure. For the corresponding technical solutions and descriptions, refer to the corresponding records in the method section ,No longer.
图6示出根据本公开实施例的图像处理装置的框图,如图6所示,所述装置60包括:FIG. 6 shows a block diagram of an image processing device according to an embodiment of the present disclosure. As shown in FIG. 6, the device 60 includes:
提取单元61,用于对目标图像中的图像特征进行提取,得到用于表征图像特征的特征图;An extraction unit 61, configured to extract image features in the target image to obtain a feature map for characterizing image features;
索引计算单元62,用于通过多个第一线程计算特征图和/或卷积核中的特征值的索引位置;An index calculation unit 62, configured to calculate the index position of the feature value in the feature map and/or the convolution kernel through a plurality of first threads;
卷积处理单元63,用于控制多个第二线程按照所述索引位置读取特征图和/或卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征,所述卷积特征用于表征对所述图像特征的提取结果。The convolution processing unit 63 is configured to control multiple second threads to read feature maps and/or feature values in the convolution kernel according to the index positions, and perform convolution processing using the read feature values to obtain A convolution feature, the convolution feature is used to characterize the extraction result of the image feature.
在一种可能的实现方式中,所述卷积处理单元,用于将读取到的特征值在矩阵乘加 运算MMA指令的通道K维度进行排列,进行矩阵乘加运算,得到卷积特征。In a possible implementation, the convolution processing unit is configured to arrange the read eigenvalues in the channel K dimension of the matrix multiplication and addition operation MMA instruction, and perform matrix multiplication and addition operations to obtain convolution features.
在一种可能的实现方式中,所述索引计算单元,用于按照至少两个线程的标识ID的顺序,控制至少两个线程分别计算特征图和/或卷积核中的特征值的索引位置。In a possible implementation manner, the index calculation unit is configured to control at least two threads to respectively calculate the index positions of the feature maps and/or feature values in the convolution kernel according to the order of the identification IDs of the at least two threads .
在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:
加载单元,用于将所述索引位置的特征值加载到共享内存SMem中,以供各线程使用。The loading unit is configured to load the characteristic value of the index position into the shared memory SMem for use by each thread.
在一种可能的实现方式中,所述卷积处理单元,用于控制所述多个第二线程将索引位置处的特征值读入到各自的寄存器中,利用所述寄存器中的各个特征值进行卷积处理,得到卷积特征。In a possible implementation manner, the convolution processing unit is configured to control the plurality of second threads to read the eigenvalues at the index positions into respective registers, and use each eigenvalue in the registers Perform convolution processing to obtain convolution features.
在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:
第一尺寸确定单元,用于确定单个线程束Warp中能够处理的特征块的多种第一尺寸,并基于所述第一尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第一尺寸的最大值根据寄存器容量确定,所述第一尺寸的最小值为矩阵乘加运算指令计算的最小矩阵单元的尺寸,所述多种第一尺寸的值为所述最小值的倍数。The first size determination unit is configured to determine multiple first sizes of feature blocks that can be processed in a single thread warp, and generate a graphics processor kernel function for dividing feature blocks based on the first size; wherein, the The maximum value of the first size is determined according to the register capacity, the minimum value of the first size is the size of the smallest matrix unit calculated by the matrix multiplication and addition operation instruction, and the values of the various first sizes are multiples of the minimum value .
在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:
第二尺寸确定单元,用于确定单个线程块TB中能够处理的特征块的多种第二尺寸,并基于所述第二尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第二尺寸的最小值为单个线程束Warp能够处理的特征块的第一尺寸,所述第二尺寸为所述第一尺寸的倍数,所述第二尺寸的最大值根据共享内存的容量和TB内线程数上限确定。The second size determination unit is configured to determine multiple second sizes of feature blocks that can be processed in a single thread block TB, and generate a graphics processor kernel function for dividing feature blocks based on the second size; wherein, the The minimum value of the second size is the first size of a feature block that can be processed by a single thread warp, the second size is a multiple of the first size, and the maximum value of the second size is based on the capacity of the shared memory and The upper limit of the number of threads in a TB is determined.
在一些实施例中,本公开实施例提供的装置具有的功能或包含的模块可以用于执行上文方法实施例描述的方法,其具体实现和技术效果可以参照上文方法实施例的描述,为了简洁,这里不再赘述。In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the methods described in the above method embodiments, and its specific implementation and technical effects can refer to the descriptions of the above method embodiments, for It is concise and will not be repeated here.
本公开实施例还提出一种计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。计算机可读存储介质可以是易失性或非易失性计算机可读存储介质。Embodiments of the present disclosure also provide a computer-readable storage medium, on which computer program instructions are stored, and the above-mentioned method is implemented when the computer program instructions are executed by a processor. Computer readable storage media may be volatile or nonvolatile computer readable storage media.
本公开实施例还提出一种电子设备,包括:处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为调用所述存储器存储的指令,以执行上述方法。An embodiment of the present disclosure also proposes an electronic device, including: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to invoke the instructions stored in the memory to execute the above method.
本公开实施例还提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行上述方法。An embodiment of the present disclosure also provides a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium carrying computer-readable codes, when the computer-readable codes are stored in a processor of an electronic device When running in the electronic device, the processor in the electronic device executes the above method.
电子设备可以被提供为终端、服务器或其它形态的设备。Electronic devices may be provided as terminals, servers, or other forms of devices.
图7示出根据本公开实施例的一种电子设备800的框图。例如,电子设备800可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等终端。FIG. 7 shows a block diagram of an electronic device 800 according to an embodiment of the present disclosure. For example, the electronic device 800 may be a terminal such as a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, or a personal digital assistant.
参照图7,电子设备800可以包括以下一个或多个组件:处理组件802,存储器804,电源组件806,多媒体组件808,音频组件810,输入/输出(I/O)的接口812,传感器组 件814,以及通信组件816。7, electronic device 800 may include one or more of the following components: processing component 802, memory 804, power supply component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814 , and the communication component 816.
处理组件802通常控制电子设备800的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理组件802可以包括一个或多个处理器820来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件802可以包括一个或多个模块,便于处理组件802和其他组件之间的交互。例如,处理组件802可以包括多媒体模块,以方便多媒体组件808和处理组件802之间的交互。The processing component 802 generally controls the overall operations of the electronic device 800, such as those associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above method. Additionally, processing component 802 may include one or more modules that facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802 .
存储器804被配置为存储各种类型的数据以支持在电子设备800的操作。这些数据的示例包括用于在电子设备800上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器804可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。The memory 804 is configured to store various types of data to support operations at the electronic device 800 . Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and the like. The memory 804 can be implemented by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic or Optical Disk.
电源组件806为电子设备800的各种组件提供电力。电源组件806可以包括电源管理系统,一个或多个电源,及其他与为电子设备800生成、管理和分配电力相关联的组件。The power supply component 806 provides power to various components of the electronic device 800 . Power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for electronic device 800 .
多媒体组件808包括在所述电子设备800和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与所述触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件808包括一个前置摄像头和/或后置摄像头。当电子设备800处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。The multimedia component 808 includes a screen providing an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense a boundary of a touch or swipe action, but also detect duration and pressure associated with the touch or swipe action. In some embodiments, the multimedia component 808 includes a front camera and/or a rear camera. When the electronic device 800 is in an operation mode, such as a shooting mode or a video mode, the front camera and/or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capability.
音频组件810被配置为输出和/或输入音频信号。例如,音频组件810包括一个麦克风(MIC),当电子设备800处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器804或经由通信组件816发送。在一些实施例中,音频组件810还包括一个扬声器,用于输出音频信号。The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 800 is in operation modes, such as call mode, recording mode and voice recognition mode. Received audio signals may be further stored in memory 804 or sent via communication component 816 . In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
I/O接口812为处理组件802和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。The I/O interface 812 provides an interface between the processing component 802 and a peripheral interface module, which may be a keyboard, a click wheel, a button, and the like. These buttons may include, but are not limited to: a home button, volume buttons, start button, and lock button.
传感器组件814包括一个或多个传感器,用于为电子设备800提供各个方面的状态评估。例如,传感器组件814可以检测到电子设备800的打开/关闭状态,组件的相对定位,例如所述组件为电子设备800的显示器和小键盘,传感器组件814还可以检测电子设备800或电子设备800一个组件的位置改变,用户与电子设备800接触的存在或不存在,电子设备800方位或加速/减速和电子设备800的温度变化。传感器组件814可以包括接近传感器, 被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件814还可以包括光传感器,如互补金属氧化物半导体(CMOS)或电荷耦合装置(CCD)图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件814还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。 Sensor assembly 814 includes one or more sensors for providing status assessments of various aspects of electronic device 800 . For example, the sensor component 814 can detect the open/closed state of the electronic device 800, the relative positioning of components, such as the display and the keypad of the electronic device 800, the sensor component 814 can also detect the electronic device 800 or a Changes in position of components, presence or absence of user contact with electronic device 800 , electronic device 800 orientation or acceleration/deceleration and temperature changes in electronic device 800 . Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact. Sensor assembly 814 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, the sensor component 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
通信组件816被配置为便于电子设备800和其他设备之间有线或无线方式的通信。电子设备800可以接入基于通信标准的无线网络,如无线网络(WiFi),第二代移动通信技术(2G)或第三代移动通信技术(3G),或它们的组合。在一个示例性实施例中,通信组件816经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,所述通信组件816还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as a wireless network (WiFi), a second generation mobile communication technology (2G) or a third generation mobile communication technology (3G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology and other technologies.
在示例性实施例中,电子设备800可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述方法。In an exemplary embodiment, electronic device 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable A programmable gate array (FPGA), controller, microcontroller, microprocessor or other electronic component implementation for performing the methods described above.
在示例性实施例中,还提供了一种非易失性计算机可读存储介质,例如包括计算机程序指令的存储器804,上述计算机程序指令可由电子设备800的处理器820执行以完成上述方法。In an exemplary embodiment, there is also provided a non-volatile computer-readable storage medium, such as the memory 804 including computer program instructions, which can be executed by the processor 820 of the electronic device 800 to implement the above method.
图8示出根据本公开实施例的一种电子设备1900的框图。例如,电子设备1900可以被提供为一服务器。参照图8,电子设备1900包括处理组件1922,其进一步包括一个或多个处理器,以及由存储器1932所代表的存储器资源,用于存储可由处理组件1922的执行的指令,例如应用程序。存储器1932中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件1922被配置为执行指令,以执行上述方法。FIG. 8 shows a block diagram of an electronic device 1900 according to an embodiment of the present disclosure. For example, electronic device 1900 may be provided as a server. Referring to FIG. 8 , electronic device 1900 includes processing component 1922 , which further includes one or more processors, and a memory resource represented by memory 1932 for storing instructions executable by processing component 1922 , such as application programs. The application programs stored in memory 1932 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
电子设备1900还可以包括一个电源组件1926被配置为执行电子设备1900的电源管理,一个有线或无线网络接口1950被配置为将电子设备1900连接到网络,和一个输入输出(I/O)接口1958。电子设备1900可以操作基于存储在存储器1932的操作系统,例如微软服务器操作系统(Windows Server TM),苹果公司推出的基于图形用户界面操作系统(Mac OS X TM),多用户多进程的计算机操作系统(Unix TM),自由和开放原代码的类Unix操作系统(Linux TM),开放原代码的类Unix操作系统(FreeBSD TM)或类似。 Electronic device 1900 may also include a power supply component 1926 configured to perform power management of electronic device 1900, a wired or wireless network interface 1950 configured to connect electronic device 1900 to a network, and an input-output (I/O) interface 1958 . The electronic device 1900 can operate based on the operating system stored in the memory 1932, such as the Microsoft server operating system (Windows Server TM ), the graphical user interface-based operating system (Mac OS X TM ) introduced by Apple Inc., and the multi-user and multi-process computer operating system (Unix ), a free and open source Unix-like operating system (Linux ), an open source Unix-like operating system (FreeBSD ), or the like.
在示例性实施例中,还提供了一种非易失性计算机可读存储介质,例如包括计算机程序指令的存储器1932,上述计算机程序指令可由电子设备1900的处理组件1922执行以完成上述方法。In an exemplary embodiment, there is also provided a non-transitory computer-readable storage medium, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to implement the above method.
本公开可以是系统、方法和/或计算机程序产品。计算机程序产品可以包括计算机可读存储介质,其上载有用于使处理器实现本公开的各个方面的计算机可读程序指令。The present disclosure can be a system, method and/or computer program product. A computer program product may include a computer readable storage medium having computer readable program instructions thereon for causing a processor to implement various aspects of the present disclosure.
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。 计算机可读存储介质例如可以是(但不限于)电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、静态随机存取存储器(SRAM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。这里所使用的计算机可读存储介质不被解释为瞬时信号本身,诸如无线电波或者其他自由传播的电磁波、通过波导或其他传输媒介传播的电磁波(例如,通过光纤电缆的光脉冲)、或者通过电线传输的电信号。A computer readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. A computer readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory), static random access memory (SRAM), compact disc read only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanically encoded device, such as a printer with instructions stored thereon A hole card or a raised structure in a groove, and any suitable combination of the above. As used herein, computer-readable storage media are not to be construed as transient signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., pulses of light through fiber optic cables), or transmitted electrical signals.
这里所描述的计算机可读程序指令可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。Computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or downloaded to an external computer or external storage device over a network, such as the Internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers. A network adapter card or a network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .
用于执行本公开操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本公开的各个方面。Computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or Source or object code written in any combination, including object-oriented programming languages—such as Smalltalk, C++, etc., and conventional procedural programming languages—such as the “C” language or similar programming languages. Computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement. In cases involving a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as via the Internet using an Internet service provider). connect). In some embodiments, an electronic circuit, such as a programmable logic circuit, field programmable gate array (FPGA), or programmable logic array (PLA), can be customized by utilizing state information of computer-readable program instructions, which can Various aspects of the present disclosure are implemented by executing computer readable program instructions.
这里参照根据本公开实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本公开的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。Aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It should be understood that each block of the flowcharts and/or block diagrams, and combinations of blocks in the flowcharts and/or block diagrams, can be implemented by computer-readable program instructions.
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方 框中规定的功能/动作的各个方面的指令。These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine such that when executed by the processor of the computer or other programmable data processing apparatus , producing an apparatus for realizing the functions/actions specified in one or more blocks in the flowchart and/or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause computers, programmable data processing devices and/or other devices to work in a specific way, so that the computer-readable medium storing instructions includes An article of manufacture comprising instructions for implementing various aspects of the functions/acts specified in one or more blocks in flowcharts and/or block diagrams.
也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。It is also possible to load computer-readable program instructions into a computer, other programmable data processing device, or other equipment, so that a series of operational steps are performed on the computer, other programmable data processing device, or other equipment to produce a computer-implemented process , so that instructions executed on computers, other programmable data processing devices, or other devices implement the functions/actions specified in one or more blocks in the flowcharts and/or block diagrams.
附图中的流程图和框图显示了根据本公开的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, a portion of a program segment, or an instruction that includes one or more Executable instructions. In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions.
该计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。The computer program product can be specifically realized by means of hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK) etc. Wait.
以上已经描述了本公开的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。Having described various embodiments of the present disclosure above, the foregoing description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and alterations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principle of each embodiment, practical application or improvement of technology in the market, or to enable other ordinary skilled in the art to understand each embodiment disclosed herein.

Claims (11)

  1. 一种图像处理方法,其特征在于,包括:An image processing method, characterized in that, comprising:
    对目标图像中的图像特征进行提取,得到用于表征图像特征的特征图;Extracting the image features in the target image to obtain a feature map used to characterize the image features;
    通过多个第一线程计算特征图和/或卷积核中的特征值的索引位置;Computing index positions of feature values in feature maps and/or convolution kernels by multiple first threads;
    控制多个第二线程按照所述索引位置读取特征图和/或卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征,所述卷积特征用于表征对所述图像特征的提取结果。controlling a plurality of second threads to read feature maps and/or feature values in convolution kernels according to the index positions, and perform convolution processing using the read feature values to obtain convolution features, and the convolution The feature is used to characterize the extraction result of the image feature.
  2. 根据权利要求1所述的方法,其特征在于,所述利用读取到的所述特征值进行卷积处理,得到卷积特征,包括:The method according to claim 1, wherein said performing convolution processing using the read eigenvalues to obtain convolution features includes:
    将读取到的特征值在矩阵乘加运算MMA指令的通道K维度进行排列,进行矩阵乘加运算,得到卷积特征。Arrange the read eigenvalues in the channel K dimension of the matrix multiply-add operation MMA instruction, and perform matrix multiply-add operations to obtain convolution features.
  3. 根据权利要求1或2所述的方法,其特征在于,所述通过多个第一线程计算特征图和/卷积核中的特征值的索引位置,包括:The method according to claim 1 or 2, wherein the calculation of the feature map and/the index position of the feature value in the convolution kernel through a plurality of first threads comprises:
    按照至少两个线程的标识ID的顺序,控制至少两个线程分别计算特征图和/或卷积核中的特征值的索引位置。According to the sequence of the identification IDs of the at least two threads, at least two threads are controlled to respectively calculate index positions of feature values in feature maps and/or convolution kernels.
  4. 根据权利要求1-3任一所述方法,其特征在于,在所述通过多个第一线程计算特征图和/卷积核中的特征值的索引位置,所述方法还包括:According to the method according to any one of claims 1-3, it is characterized in that, at the index position of the feature value in the feature map and/convolution kernel calculated by multiple first threads, the method further comprises:
    将所述索引位置的特征值加载到共享内存SMem中,以供线程使用。Load the characteristic value of the index position into the shared memory SMem for thread use.
  5. 根据权利要求1-4任一所述方法,其特征在于,所述控制多个第二线程按照所述索引位置读取特征图和/或卷积核中的特征值,包括:The method according to any one of claims 1-4, wherein the controlling multiple second threads to read feature maps and/or feature values in convolution kernels according to the index positions includes:
    控制所述多个第二线程将索引位置处的特征值读入到各自的寄存器中;controlling the plurality of second threads to read the feature values at the index positions into respective registers;
    所述利用读取到的所述特征值进行卷积处理,得到卷积特征,包括:The convolution process is performed using the read eigenvalues to obtain convolution features, including:
    利用所述寄存器中的各个特征值进行卷积处理,得到卷积特征。Each feature value in the register is used to perform convolution processing to obtain convolution features.
  6. 根据权利要求1-5任一所述方法,其特征在于,在所述对目标图像中的图像特征进行提取后,所述方法还包括:According to the method according to any one of claims 1-5, it is characterized in that, after the image features in the target image are extracted, the method further comprises:
    确定单个线程束Warp中能够处理的特征块的多种第一尺寸,并基于所述第一尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第一尺寸的最大值根据寄存器容量确定,所述第一尺寸的最小值为矩阵乘加运算指令计算的最小矩阵单元的尺寸,所述多种第一尺寸的值为所述最小值的倍数。Determining multiple first sizes of feature blocks that can be processed in a single thread warp Warp, and generating a graphics processor kernel function for dividing feature blocks based on the first size; wherein, the maximum value of the first size is based on The register capacity is determined, the minimum value of the first size is the size of the smallest matrix unit calculated by the matrix multiply-add operation instruction, and the values of the various first sizes are multiples of the minimum value.
  7. 根据权利要求1-6任一所述方法,其特征在于,在所述对目标图像中的图像特征进行提取后,所述方法还包括:According to the method according to any one of claims 1-6, it is characterized in that, after the image features in the target image are extracted, the method further comprises:
    确定单个线程块TB中能够处理的特征块的多种第二尺寸,并基于所述第二尺寸生成用于进行特征块划分的图形处理器核函数;其中,所述第二尺寸的最小值为单个线程束Warp能够处理的特征块的第一尺寸,所述第二尺寸为所述第一尺寸的倍数,所述第二尺寸的最大值根据共享内存的容量和TB内线程数上限确定。Determining multiple second sizes of feature blocks that can be processed in a single thread block TB, and generating a graphics processor kernel function for dividing feature blocks based on the second size; wherein, the minimum value of the second size is The first size of a feature block that can be processed by a single warp warp, the second size is a multiple of the first size, and the maximum value of the second size is determined according to the capacity of the shared memory and the upper limit of the number of threads in a TB.
  8. 一种图像处理装置,其特征在于,包括:An image processing device, characterized in that it comprises:
    提取单元,用于对目标图像中的图像特征进行提取,得到用于表征图像特征的特征图;An extraction unit is used to extract image features in the target image to obtain a feature map for representing image features;
    索引计算单元,用于通过多个第一线程计算特征图和/或卷积核中的特征值的索引位置;An index calculation unit is used to calculate the index position of the feature value in the feature map and/or the convolution kernel through a plurality of first threads;
    卷积处理单元,用于控制多个第二线程按照所述索引位置读取特征图和/或卷积核中的特征值,并利用读取到的所述特征值进行卷积处理,得到卷积特征,所述卷积特征用于表征对所述图像特征的提取结果。A convolution processing unit, configured to control multiple second threads to read feature maps and/or feature values in the convolution kernel according to the index positions, and perform convolution processing using the read feature values to obtain convolution Convolution feature, the convolution feature is used to characterize the extraction result of the image feature.
  9. 一种电子设备,其特征在于,包括:An electronic device, characterized in that it comprises:
    处理器;processor;
    用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions;
    其中,所述处理器被配置为调用所述存储器存储的指令,以执行权利要求1至7中任意一项所述的方法。Wherein, the processor is configured to invoke instructions stored in the memory to execute the method according to any one of claims 1-7.
  10. 一种计算机可读存储介质,其上存储有计算机程序指令,其特征在于,所述计算机程序指令被处理器执行时实现权利要求1至7中任意一项所述的方法。A computer-readable storage medium, on which computer program instructions are stored, wherein, when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
  11. 一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行用于实现权利要求1-7中的任一权利要求所述的方法。A computer program product, comprising computer readable codes, or a non-volatile computer readable storage medium bearing computer readable codes, when the computer readable codes are run in a processor of an electronic device, the electronic A processor in the device is configured to implement the method of any one of claims 1-7.
PCT/CN2022/078439 2021-07-09 2022-02-28 Image processing method and apparatus, and electronic device and storage medium WO2023279740A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110779002.5A CN113378863B (en) 2021-07-09 2021-07-09 Image processing method and device, electronic equipment and storage medium
CN202110779002.5 2021-07-09

Publications (1)

Publication Number Publication Date
WO2023279740A1 true WO2023279740A1 (en) 2023-01-12

Family

ID=77581607

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/078439 WO2023279740A1 (en) 2021-07-09 2022-02-28 Image processing method and apparatus, and electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN113378863B (en)
WO (1) WO2023279740A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113378863B (en) * 2021-07-09 2023-12-19 上海商汤科技开发有限公司 Image processing method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110348574A (en) * 2019-07-17 2019-10-18 哈尔滨理工大学 A kind of general convolutional neural networks accelerating structure and design method based on ZYNQ
WO2020252762A1 (en) * 2019-06-21 2020-12-24 Intel Corporation Generic modular sparse three-dimensional (3d) convolution design utilizing sparse 3d group convolution
CN113378863A (en) * 2021-07-09 2021-09-10 上海商汤科技开发有限公司 Image processing method and device, electronic equipment and storage medium
CN113378862A (en) * 2021-07-09 2021-09-10 上海商汤科技开发有限公司 Image processing method and device, electronic equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105809114B (en) * 2016-02-29 2019-02-01 深圳市智美达科技股份有限公司 Method for detecting human face and device
CN110738316B (en) * 2018-07-20 2024-05-14 北京三星通信技术研究有限公司 Operation method and device based on neural network and electronic equipment
CN111831254A (en) * 2019-04-15 2020-10-27 阿里巴巴集团控股有限公司 Image processing acceleration method, image processing model storage method and corresponding device
CN110458280B (en) * 2019-07-15 2022-08-30 武汉魅瞳科技有限公司 Convolutional neural network acceleration method and system suitable for mobile terminal

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020252762A1 (en) * 2019-06-21 2020-12-24 Intel Corporation Generic modular sparse three-dimensional (3d) convolution design utilizing sparse 3d group convolution
CN110348574A (en) * 2019-07-17 2019-10-18 哈尔滨理工大学 A kind of general convolutional neural networks accelerating structure and design method based on ZYNQ
CN113378863A (en) * 2021-07-09 2021-09-10 上海商汤科技开发有限公司 Image processing method and device, electronic equipment and storage medium
CN113378862A (en) * 2021-07-09 2021-09-10 上海商汤科技开发有限公司 Image processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN113378863B (en) 2023-12-19
CN113378863A (en) 2021-09-10

Similar Documents

Publication Publication Date Title
WO2023279739A1 (en) Image processing method and apparatus, and electronic device and storage medium
KR102406354B1 (en) Video restoration method and apparatus, electronic device and storage medium
CN110390394B (en) Batch normalization data processing method and device, electronic equipment and storage medium
JP7096888B2 (en) Network modules, allocation methods and devices, electronic devices and storage media
CN111597029B (en) Data processing method and device, electronic equipment and storage medium
WO2022247103A1 (en) Image processing method and apparatus, electronic device, and computer-readable storage medium
CN111443917B (en) Neural network operation optimization method and device and related products
CN112668707B (en) Operation method, device and related product
US8446363B1 (en) Enhanced input using touch screen
WO2022247128A1 (en) Image processing method and apparatus, electronic device, and storage medium
WO2023279740A1 (en) Image processing method and apparatus, and electronic device and storage medium
CN109447258B (en) Neural network model optimization method and device, electronic device and storage medium
CN111694768B (en) Operation method, device and related product
CN112269595A (en) Image processing method, image processing device, computer equipment and storage medium
CN110163372B (en) Operation method, device and related product
CN112988194B (en) Program optimization method and device based on equipment information, electronic equipment and storage medium
CN110892371B (en) Display control method and terminal
CN111695686A (en) Operation method, device and related product
CN114020264A (en) Operator processing method and device, electronic equipment and storage medium
CN114005124A (en) Sampling method and device, electronic equipment and storage medium
CN111783969A (en) Data processing method, data processing device, computer equipment and storage medium
US10359913B2 (en) Interface for creating and comparing multiple object sets
CN111626398A (en) Operation method, device and related product
CN114116590B (en) Data acquisition method, device, vehicle, storage medium and electronic equipment
CN111258656B (en) Data processing device and terminal

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE