Thread arrangement determination method and apparatus, computer device, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- DAWNING INFORMATION IND (BEIJING) CO LTD
- Filing Date
- 2023-11-07
- Publication Date
- 2026-08-07
AI Technical Summary
[0003]在网络模型运行时需要读取网络模型的卷积算子,通常,网络模型卷积算子维度的较大时,需要跨通道读取网络模型的卷积算子,会降低缓冲存储器的命中率;若降低网络模型算子读取时所跨通道的数量,可能会使得线程在写入共享内存时发生写入冲突,导致网络模型的卷积算子的性能较差,从而影响网络模型的整体性能
[0046] The aforementioned thread arrangement determination method, apparatus, computer device, and storage medium obtain the accumulated multiplication dimension value of the convolution operator of the network model, determine the reading mode of the threads reading the network model and feature map based on the accumulated multiplication dimension value and a preset threshold, and determine the thread arrangement method corresponding to the reading mode based on the constraints of the reading mode, the filter size, and the number of callable threads. The preset threshold is determined based on the size of the buffer memory, and the constraints of the reading mode are related to the buffer memory hit rate and the conflict of threads writing to shared memory. Since changes in the accumulated multiplication dimension value of the convolution operator affect the buffer memory hit rate and the conflict of threads writing to shared memory, in this embodiment, different reading modes are determined based on the accumulated multiplication dimension value of the convolution operator and the preset threshold. Under different reading modes, different constraints are determined based on the buffer memory hit rate and the conflict of threads writing to shared memory, so that the thread arrangement method determined based on the constraints of the reading mode can better balance the buffer memory hit rate and the conflict of threads writing to shared memory. Furthermore, by determining the reading mode of the thread that reads the filter and feature map based on the accumulated multiplication dimension value and the preset threshold, the number of times the filter and feature map are accessed can be reduced, thereby improving the overall performance of the network model.
Smart Images

Figure CN117472576B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, and storage medium for determining thread arrangement. Background Technology
[0002] With the development of deep learning, the application scope of various network models is becoming increasingly wide. The performance of network model operators largely determines the overall performance of the network model.
[0003] When a network model is running, it is necessary to read the convolution operators of the network model. Usually, when the convolution operators of the network model have a large dimension, it is necessary to read the convolution operators of the network model across channels, which will reduce the hit rate of the buffer memory. If the number of channels across when reading the network model operators is reduced, it may cause write conflicts when threads write to shared memory, resulting in poor performance of the convolution operators of the network model, thus affecting the overall performance of the network model.
[0004] Therefore, it is necessary to arrange the reading threads of the convolution operators of the network model in order to balance the hit rate of the buffer memory and the conflict of threads writing to shared memory. Summary of the Invention
[0005] Therefore, it is necessary to provide a method, apparatus, computer device, and storage medium for determining thread arrangement that can balance the hit rate of buffer memory with the conflict of threads writing to shared memory, in order to address the above-mentioned technical problems.
[0006] Firstly, this application provides a method for determining thread arrangement, including:
[0007] Obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model;
[0008] Based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread that reads the filter and feature map of the convolution operator is determined; wherein, the preset threshold is determined according to the size of the buffer memory;
[0009] The thread arrangement corresponding to the read mode is determined based on the constraints of the read mode, the size of the filter, and the number of callable threads; the constraints of the read mode are related to the hit rate of the buffer memory and the conflict of writing to shared memory between threads.
[0010] In this embodiment, by obtaining the accumulated multiplication dimension value of the convolution operator of the network model, and based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread reading the network model and feature map is determined. Based on the constraints of the reading mode, the filter size, and the number of callable threads, the thread arrangement corresponding to the reading mode is determined. The preset threshold is determined based on the size of the buffer memory, and the constraints of the reading mode are related to the buffer memory hit rate and the conflict of threads writing to shared memory. Since changes in the accumulated multiplication dimension value of the convolution operator affect the buffer memory hit rate and the conflict of threads writing to shared memory, this embodiment determines different reading modes based on the accumulated multiplication dimension value of the convolution operator and the preset threshold. Under different reading modes, different constraints are determined based on the buffer memory hit rate and the conflict of threads writing to shared memory, so that the thread arrangement determined based on the constraints of the reading mode can better balance the buffer memory hit rate and the conflict of threads writing to shared memory. Furthermore, by determining the reading mode of the thread that reads the filter and feature map based on the accumulated multiplication dimension value and the preset threshold, the number of times the filter and feature map are accessed can be reduced, thereby improving the overall performance of the network model.
[0011] In one embodiment, determining the thread arrangement corresponding to the read mode based on the constraints of the read mode, the size of the filter, and the number of callable threads includes:
[0012] Based on the number of callable threads, determine the number of callable thread column directions and the number of callable thread row directions;
[0013] Based on the constraints of the read mode and the number of callable thread column directions, determine the column thread arrangement corresponding to the read mode;
[0014] The row thread arrangement corresponding to the read mode is determined based on the column thread arrangement method corresponding to the read mode, the size of the filter, and the number of callable thread row thread directions.
[0015] In this embodiment, the number of callable thread column directions and the number of callable thread row directions are determined based on the number of callable threads. Based on the constraints of the read mode and the number of callable thread column directions, the column thread arrangement corresponding to the read mode is determined. Then, based on the column thread arrangement corresponding to the read mode, the filter size, and the number of callable thread row directions, the row thread arrangement corresponding to the read mode is determined. This embodiment primarily determines the column thread arrangement corresponding to the read mode based on the constraints of the read mode and the number of callable thread column directions, and then determines the row thread arrangement based on the column thread arrangement. This considers the dynamic balance between the buffer memory hit rate and the inter-thread writes to shared memory during global reading of filters and feature maps. Furthermore, it can reduce the amount of data read from filters and feature maps, thereby improving the performance of the network model.
[0016] In one embodiment, the preset threshold includes multiple thresholds; determining the reading mode of the thread reading the filter and feature map of the convolution operator based on the accumulated multiplication dimension value and the preset threshold includes:
[0017] Based on the accumulated multiplication dimension value and the multiple thresholds, the reading mode of the thread that reads the filter and feature map is determined.
[0018] In this embodiment, the reading mode of the thread for reading the filter and feature map is determined based on the accumulated multiplication dimension value and multiple thresholds. Multiple thresholds can be set according to the actual situation, thereby dividing the reading mode of the thread for reading the filter and feature map into multiple forms. The reading mode division is more accurate and the universality of the reading mode is improved.
[0019] In one embodiment, the plurality of thresholds includes a first threshold and a second threshold, and determining the reading pattern of the thread reading the filter and the feature map based on the accumulated multiplication dimension value and the plurality of thresholds includes:
[0020] If the accumulated multiplication dimension value is less than the first threshold, then the reading mode is determined to be the first mode;
[0021] If the accumulated multiplication dimension value is greater than or equal to the first threshold and less than the second threshold, then the reading mode is determined to be the second mode;
[0022] If the accumulated multiplication dimension value is greater than or equal to the second threshold, then the reading mode is determined to be the third mode; wherein the constraints corresponding to the first mode, the second model and the third mode are all different.
[0023] In this embodiment, multiple thresholds include a first threshold and a second threshold. Based on the relationship between the accumulated multiplier dimension value and the first and second thresholds, the read mode is divided into three modes. These three modes can effectively balance the hit rate of the buffer memory and the conflict of writing to shared memory between threads. The division of read modes is simple.
[0024] In one embodiment, the method further includes:
[0025] The constraints of the read mode are determined based on the cumulative multiplication dimension value corresponding to the read mode, the hit rate of the buffer memory, and the conflict of writing to shared memory between threads.
[0026] In this embodiment, the callable thread is controlled to read the filter and feature map according to the thread arrangement method corresponding to the reading mode, so as to obtain the convolution result based on the read filter and feature map. This thread arrangement method can take into account the hit rate of the buffer memory and the conflict of writing to shared memory between threads, thereby improving the overall performance of the filter.
[0027] In one embodiment, the method further includes:
[0028] Based on the thread arrangement corresponding to the reading mode, the callable thread is controlled to read the filter and the feature map.
[0029] In this embodiment, the callable thread is controlled to read the filter and feature map according to the thread arrangement method corresponding to the reading mode, so as to obtain the convolution result based on the read filter and feature map. This thread arrangement method can take into account the hit rate of the buffer memory and the conflict of writing to shared memory between threads, thereby improving the overall performance of the network model.
[0030] Secondly, this application also provides a thread arrangement determination device, comprising:
[0031] The acquisition module is used to obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model;
[0032] The first determining module is used to determine the reading mode of the thread that reads the accumulated multiplication dimension value and the preset threshold based on the accumulated multiplication dimension value and the preset threshold; wherein, the preset threshold is determined based on the size of the buffer memory;
[0033] The second determining module is used to determine the thread arrangement corresponding to the reading mode based on the constraints of the reading mode, the size of the filter, and the number of callable threads; the constraints of the reading mode are related to the hit rate of the buffer memory and the conflict of threads writing to shared memory.
[0034] Thirdly, this application also provides a computer device, including a buffer memory and a processor, wherein the buffer memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0035] Obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model;
[0036] Based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread that reads the filter and feature map of the convolution operator is determined; wherein, the preset threshold is determined according to the size of the buffer memory;
[0037] Based on the constraints of the read mode, the size of the filter, and the number of callable threads, the thread arrangement corresponding to the read mode is determined; the constraints of the read mode are related to the cache hit rate and conflicts between threads writing to shared memory.
[0038] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0039] Obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model;
[0040] Based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread that reads the filter and feature map of the convolution operator is determined; wherein, the preset threshold is determined according to the size of the buffer memory;
[0041] The thread arrangement corresponding to the read mode is determined based on the constraints of the read mode, the size of the filter, and the number of callable threads; the constraints of the read mode are related to the hit rate of the buffer memory and the conflict of writing to shared memory between threads.
[0042] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0043] Obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model;
[0044] Based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread that reads the filter and feature map of the convolution operator is determined; wherein, the preset threshold is determined according to the size of the buffer memory;
[0045] The thread arrangement corresponding to the read mode is determined based on the constraints of the read mode, the size of the filter, and the number of callable threads; the constraints of the read mode are related to the hit rate of the buffer memory and the conflict of writing to shared memory between threads.
[0046] The aforementioned thread arrangement determination method, apparatus, computer device, and storage medium obtain the accumulated multiplication dimension value of the convolution operator of the network model, determine the reading mode of the threads reading the network model and feature map based on the accumulated multiplication dimension value and a preset threshold, and determine the thread arrangement method corresponding to the reading mode based on the constraints of the reading mode, the filter size, and the number of callable threads. The preset threshold is determined based on the size of the buffer memory, and the constraints of the reading mode are related to the buffer memory hit rate and the conflict of threads writing to shared memory. Since changes in the accumulated multiplication dimension value of the convolution operator affect the buffer memory hit rate and the conflict of threads writing to shared memory, in this embodiment, different reading modes are determined based on the accumulated multiplication dimension value of the convolution operator and the preset threshold. Under different reading modes, different constraints are determined based on the buffer memory hit rate and the conflict of threads writing to shared memory, so that the thread arrangement method determined based on the constraints of the reading mode can better balance the buffer memory hit rate and the conflict of threads writing to shared memory. Furthermore, by determining the reading mode of the thread that reads the filter and feature map based on the accumulated multiplication dimension value and the preset threshold, the number of times the filter and feature map are accessed can be reduced, thereby improving the overall performance of the network model. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a diagram illustrating the application environment of a thread arrangement determination method in one embodiment.
[0049] Figure 2 This is a flowchart illustrating a thread arrangement determination method in one embodiment;
[0050] Figure 3 This is a schematic diagram of convolution operation in one embodiment;
[0051] Figure 4 This is a flowchart illustrating a method for determining thread arrangement in one embodiment;
[0052] Figure 5 This is a schematic diagram illustrating the arrangement of callable thread columns in one embodiment;
[0053] Figure 6 This is a schematic diagram illustrating the arrangement of callable thread columns in another embodiment;
[0054] Figure 7 This is a schematic diagram illustrating the arrangement of callable thread columns in another embodiment;
[0055] Figure 8 This is a schematic diagram illustrating the arrangement of callable thread rows in one embodiment;
[0056] Figure 9 This is a schematic diagram illustrating the arrangement of callable thread rows in another embodiment;
[0057] Figure 10 This is a schematic diagram illustrating the arrangement of callable thread rows in another embodiment;
[0058] Figure 11 This is a flowchart illustrating a data reading method in one embodiment;
[0059] Figure 12 This is a structural block diagram of a thread arrangement determination device in one embodiment. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0061] The development of artificial intelligence technology has further promoted the development of deep learning. This can be achieved by adding MIOpen (Machine Intelligence Open) to the software technology stack (Radeon Open Computing Platform M, ROCm) to match the deep learning network library (CUDA Deep Neural Network, cuDnn) in the Compute Unified Device Architecture (CUDA).
[0062] Taking MIOpen as an example, when building a deep learning network model, MIOpen dynamically compiles multiple convolution operators adapted to the network model, and then looks up records in a database table to select the best-performing convolution operator. Because the number of convolution operators is very large, the dynamic compilation is slow, and the database lookup is time-consuming, ultimately resulting in a slow initial startup speed for the network model and a poor user experience.
[0063] Based on this, the reading threads of the convolution operators in the network model can be pre-arranged to ensure a balance between the hit rate of the buffer memory and the conflict of threads writing to shared memory, while reducing the number of accesses to read the convolution operators, which is a significant advantage for the overall performance of the network model. To address the above problems, this application provides a thread arrangement determination method, apparatus, computer device, and storage medium.
[0064] The thread arrangement determination method provided in this application embodiment can be applied to, for example, Figure 1 The application environment shown includes a GPU architecture diagram, the internal structure of which can be illustrated as follows. Figure 1 As shown, the system includes global memory 1, L2 buffer memory 2, and computing unit 3. Computing unit 1 includes a control unit, L1 buffer memory 30, shared memory 31, and register 32. Each callable thread needs to read the feature map and filter from global memory 1 to L2 buffer memory 2, then from L2 buffer memory 2 to L1 buffer memory 30, and finally perform convolution operations in register 32 to obtain the convolution result.
[0065] In one exemplary embodiment, such as Figure 2 As shown, a method for determining thread arrangement is provided, which is applied to... Figure 1 Taking calculation unit 3 as an example, the following steps are taken: S201 to S203. Wherein:
[0066] S201, obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model.
[0067] Optionally, the network model can be a convolutional neural network, or a network based on a convolutional neural network with transformations, etc., and this embodiment does not impose any limitations. As an optional implementation method, the network model can be a network model for object detection of two-dimensional images / one-dimensional data, a network model for image segmentation of two-dimensional images / one-dimensional data, or a network model for classification of two-dimensional images / one-dimensional data, etc.
[0068] Optionally, the feature map can be the input medical image, environmental image, traffic intersection image, etc. It can also be a feature map obtained by processing the input medical image, environmental image, or traffic intersection image using a network model; or feature data obtained by processing audio data, etc. Understandably, feature maps can be obtained by transforming multi-channel input two-dimensional images / one-dimensional data according to the im2col principle.
[0069] The convolution operator includes a filter, input data, and output data.
[0070] In this embodiment, the network model may include filters with multiple channels. Each filter has a width and a length. The cumulative multiplication dimension value corresponding to the convolution operator is determined based on the number of filter channels, the filter width, and the filter length. Figure 3 This is a schematic diagram of convolution operation in one embodiment. A is a filter, B is a feature map, and C is the convolution result after convolution of the filter and the feature map. Figure 3 For example, let's explain the cumulative multiplication dimension value of the convolution operator: If the number of channels of the filter is C, and the width and length of the filter are R*S, then the corresponding cumulative multiplication dimension value of the convolution operator is K = C*R*S.
[0071] in, Figure 3 In this context, M represents the number of filters, N = 0H x 0W, where 0H and 0W are the length and width of the feature map, and N is the size of the feature map. It can be seen that the size of the feature map is only related to its length and width, and does not involve information from the input channels. Therefore, it can be determined that... Figure 3 The feature map shown is determined based on an input image from one channel.
[0072] S202, based on the accumulated multiplication dimension value and the preset threshold, determine the reading mode of the thread that reads the convolution operator filter and feature map; wherein, the preset threshold is determined according to the size of the buffer memory.
[0073] Optionally, there can be one or more preset thresholds. The size of the buffer memory can be divided equally based on the number of preset thresholds and the size of the buffer memory to determine the preset thresholds. Alternatively, the size of the buffer memory can be divided unequally based on the number of preset thresholds to obtain the preset thresholds. For example, with two preset thresholds and a buffer size of 8192, the size of the buffer memory can be divided unequally, with the first threshold set to 256 and the second threshold set to 4096.
[0074] In this embodiment, taking the first threshold of 256 and the second threshold of 4096 as an example, when the accumulated multiplication dimension value is less than 256, the reading mode of the thread reading the filter and feature map is determined to be small mode; when the accumulated multiplication dimension value is greater than or equal to 256 and less than 4096, the reading mode of the thread reading the filter and feature map is determined to be medium mode; and when the accumulated multiplication dimension value is greater than or equal to 4096, the reading mode of the thread reading the filter and feature map is determined to be large mode.
[0075] If the cumulative multiplication dimension value is less than the preset threshold when the preset threshold is 1, the reading mode of the thread reading the filter and feature map can be determined to be small mode; if the cumulative multiplication dimension value is not less than the preset threshold, the reading mode of the thread reading the filter and feature map can be determined to be large mode.
[0076] S203, based on the constraints of the read mode, the size of the filter, and the number of callable threads, determine the thread arrangement corresponding to the read mode; the constraints of the read mode are related to the cache hit rate and the conflict of threads writing to shared memory.
[0077] The callable threads can be divided into two thread groups: row threads and column threads. Furthermore, the number of row threads and column threads can be determined based on the number of callable threads. For example, if the number of callable threads is 256, then there can be 16 row threads (Y0-Y15) and 16 column threads (X0-X15).
[0078] In this embodiment, the thread arrangement methods corresponding to the read mode include row thread arrangement and column thread arrangement.
[0079] Among them, the constraints of the read mode are related to the cache hit rate and the conflict of writing to shared memory between threads. That is, the constraints need to ensure that when the cumulative multiplication dimension of the convolution operator is small, the impact of the cache hit rate is less than the conflict of writing to shared memory between threads. As the cumulative multiplication dimension of the convolution operator increases, the impact of the cache hit rate gradually increases. When the cumulative multiplication dimension is large, the impact of the cache hit rate is greater than the conflict of writing to shared memory between threads.
[0080] In this embodiment, we continue to use an example with 256 callable threads, including 16 column threads and 16 row threads. (Combined with the above...) Figure 3 The filter size is M*K. If each row thread controls the reading of m*n data points from the filter, then each column thread reads p*q data points from each m*n data point, i.e., 16*(p*q) = m*n. In this case, the column thread arrangement affects the buffer memory hit rate and the conflict of writing to shared memory between threads. Therefore, in this scenario, the constraint corresponding to the small read mode is to increase the number of cross-channels by arranging the column threads, thereby reducing the conflict of writing to shared memory between threads. Furthermore, the column thread arrangement is determined based on the number of callable thread column directions and the constraints in the corresponding read mode. Then, based on the column thread arrangement, the number of callable thread row directions, and the filter size, the row thread arrangement corresponding to the read mode is determined.
[0081] In another possible implementation, let's continue with the example of 256 callable threads, comprising 16 column threads and 16 row threads. Combining the above... Figure 3The filter size is M*K. If each column thread controls the reading of m*n data points from the filter, then each row thread reads p*q data points from each m*n data point, i.e., 16*(p*q) = m*n. In this case, the arrangement of the row threads affects the cache hit rate and the conflict of writing to shared memory between threads. Therefore, in this scenario, the constraint corresponding to the small read mode is to increase the number of cross-channels by arranging the row threads to reduce the conflict of writing to shared memory between threads. The row thread arrangement is determined based on the number of callable thread row thread directions and the constraints in the corresponding mode. Then, based on the row thread arrangement, the number of callable thread column thread directions, and the filter size, the column thread arrangement corresponding to the read mode is determined.
[0082] In the aforementioned thread arrangement determination method, the accumulated multiplication dimension value of the convolution operator of the network model is obtained. Based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread reading the network model and feature map is determined. The thread arrangement corresponding to the reading mode is determined based on the constraints of the reading mode, the filter size, and the number of callable threads. The preset threshold is determined based on the size of the buffer memory, and the constraints of the reading mode are related to the buffer memory hit rate and the conflict of threads writing to shared memory. Since changes in the accumulated multiplication dimension value of the convolution operator affect the buffer memory hit rate and the conflict of threads writing to shared memory, in this embodiment, different reading modes are determined based on the accumulated multiplication dimension value of the convolution operator and the preset threshold. Under different reading modes, different constraints are determined based on the buffer memory hit rate and the conflict of threads writing to shared memory, so that the thread arrangement determined based on the constraints of the reading mode can better balance the buffer memory hit rate and the conflict of threads writing to shared memory. Furthermore, by determining the reading mode of the thread that reads the filter and feature map based on the accumulated multiplication dimension value and the preset threshold, the number of times the filter and feature map are accessed can be reduced, thereby improving the overall performance of the network model.
[0083] Figure 4 This is a flowchart illustrating a method for determining thread arrangement in one embodiment, as shown below. Figure 4 As shown, this application embodiment relates to a possible implementation of how to determine the thread arrangement corresponding to the read mode based on the constraints of the read mode, the size of the filter, and the number of callable threads. The above S203 includes the following steps:
[0084] S401, based on the number of callable threads, determine the number of callable thread column thread directions and the number of callable thread row thread directions.
[0085] In this embodiment, since the callable threads include two thread groups: row threads and column threads, the callable threads are divided according to their number, resulting in the number of callable threads in the column direction and the number of callable threads in the row direction. For example, if the number of callable threads is 64, then the number of callable threads in the column direction is 8, and the number of callable threads in the row direction is 8.
[0086] S402, based on the constraints of the read mode and the number of callable thread directions, determine the column thread arrangement corresponding to the read mode.
[0087] The constraints corresponding to the read mode can be determined based on the accumulated multiplication dimension value of the read mode, the buffer hit rate, and the conflict of inter-thread writes to shared memory. The principle of determining the constraints of the read mode is explained below: In this embodiment, when the accumulated multiplication dimension value of the convolution operator is small, the impact of cross-channel data reading on data continuity is small; that is, when the accumulated multiplication dimension value of the convolution operator is small, the impact of the buffer hit rate is less than the conflict of inter-thread writes to shared memory. Conversely, when the accumulated multiplication dimension value of the convolution operator is large, the impact of cross-channel data reading on data continuity is large; that is, when the accumulated multiplication dimension value of the convolution operator is large, the impact of the buffer hit rate is greater than the conflict of inter-thread writes to shared memory. Therefore, based on the relationship between the buffer hit rate and the conflict of inter-thread writes to shared memory under different accumulated multiplication dimension values, the constraints of different read modes can be determined. In other words, in small mode, minimize conflicts between threads writing to shared memory and increase the number of cross-channels to improve the cache hit rate; as the accumulated multiplier dimension increases, increase conflicts between threads writing to shared memory and reduce the number of cross-channels.
[0088] For example, if the number of callable thread directions is 16, specifically X0-X15, taking the three modes mentioned above as examples: Figure 5 As shown, in the small mode, since the accumulated multiplication dimension of the convolution operator is relatively small, based on the principle of the above constraints, the corresponding constraint in the small mode can be determined as increasing the number of cross-channels by arranging the column threads, thereby reducing conflicts in writing shared memory between threads. Furthermore, based on the constraints corresponding to the small mode, the arrangement of the column threads from X0 to X15 can be determined as 1*16. With this thread arrangement, the GPU fires 16 column threads each time, and each column thread reads 4 data points vertically along the direction of the accumulated multiplication dimension of the convolution operator, spanning 16 channels. Because the accumulated multiplication dimension is small, even when reading across channels, the data continuity is still relatively good. Simultaneously, with this arrangement, if the number of channels in the shared memory is 32, there are no write conflicts between threads in the same channel when each column thread writes data to the shared memory.
[0089] Taking the middle mode of the above three modes as an example, such as Figure 6 As shown, compared to the small mode, the cumulative multiplication dimension of the convolution operator in the medium mode is larger. Based on the principle of the above constraints, the constraint for the medium mode can be determined as follows: by arranging the column threads, the number of cross-channel operations is gradually reduced compared to the small mode, while the conflict of writing to shared memory between threads is gradually increased. Furthermore, based on the constraints of the medium mode, the column thread arrangement can be determined as 2*8. This way, the column threads are arranged in a 2x8 pattern along the cumulative multiplication dimension of the convolution operator, with 8 columns. The GPU fires 16 column threads each time, and each column thread reads 4 data points vertically along the cumulative multiplication dimension. Two column threads continuously read 8 data points, spanning 8 channels. Even with cross-channel reading, the data continuity is still relatively good. Simultaneously, with this arrangement, if the number of shared memory channels is 32, the conflict between threads in the same channel when each column thread writes data to shared memory is 2.
[0090] Taking the above three major modes as an example, such as Figure 7 As shown, in this mode, the accumulated multiplication dimension value of the convolution operator is relatively large, and the impact of the cache hit rate is greater than the conflict of threads writing to shared memory. Based on the principle of the above constraints, the constraint corresponding to the large mode can be determined as follows: by arranging the column threads, compared with the first mode, the number of cross-channels is reduced, and the conflict of threads writing to shared memory is increased. Further, based on the constraint corresponding to the medium mode, the column thread arrangement can be determined as 4*4. In this way, the column threads are scattered in the direction of the accumulated multiplication dimension value of the convolution operator by 4. The GPU fires 16 column threads each time, and each column thread reads 4 data points vertically along the direction of the accumulated multiplication dimension value. The 4 column threads read 16 data points continuously, spanning 4 channels. Since a large accumulated multiplication dimension value will affect the cache hit rate, this arrangement has fewer cross-channels when reading data, taking into account the continuous reading of data. With this arrangement, if the number of shared memory channels is 32, when the threads in the column thread direction of each callable thread write data to shared memory, the conflict between threads in the same channel is 4.
[0091] S403, determine the row thread arrangement method corresponding to the read mode based on the column thread arrangement method corresponding to the read mode, the filter size, and the number of callable thread row thread directions.
[0092] In this embodiment, the number of columns corresponding to the row threads is obtained based on the column thread arrangement and filter size corresponding to the read mode. Then, the row thread read filter arrangement corresponding to the read mode is obtained based on the number of columns corresponding to the row threads and the number of callable thread row thread directions. For example, the number of callable thread row thread directions is 16, Y0-Y15, and the filter size is M*K, where M is 64. Taking the above three modes as examples... Figure 8 As shown, if the column thread arrangement corresponding to the read mode is 1*16, based on the filter size of 64 and the number of callable thread column directions of 16, it can be determined that the row thread corresponding to the read mode is 4 columns. That is, the row thread read filter arrangement corresponding to the read mode is 4*4, and each row thread includes 1*16 column threads. Figure 8 Only the column threads included in row threads Y0 and Y4 are shown; the other row threads are the same.
[0093] like Figure 9 As shown, if the column thread arrangement corresponding to the read mode is 2*8, based on the filter size of 64 and the number of callable thread columns of 8, it can be determined that the row thread corresponding to the read mode has 8 columns. That is, the row thread read filter arrangement corresponding to the read mode is 2*8, and each row thread includes 2*8 column threads. Figure 9 Only the column threads included in row threads Y0 and Y8 are shown; the other row threads are the same.
[0094] like Figure 10 As shown, if the column thread arrangement corresponding to the read mode is 4*4, based on the size of the convolution operator (64) and the number of columns of the callable thread (4), it can be determined that the row thread corresponding to the read mode has 16 columns. That is, the row thread read filter arrangement corresponding to the read mode is 1*16, and each row thread includes 4*4 column threads. Figure 10 Only the column threads included in row thread Y0 are shown; the other row threads are the same.
[0095] In this embodiment, the number of callable thread column directions and the number of callable thread row directions are determined based on the number of callable threads. The column thread arrangement corresponding to the read mode is determined based on the constraints of the read mode and the number of callable thread column directions. Then, the row thread arrangement corresponding to the read mode is determined based on the column thread arrangement, the filter size, and the number of callable thread row directions. This embodiment primarily determines the column thread arrangement based on the constraints of the read mode and the number of callable thread column directions, and then determines the row thread arrangement based on the column thread arrangement. This considers the dynamic balance between buffer memory hit rate and inter-thread shared memory writes during global reading of filters and feature maps. Furthermore, it can reduce the amount of data read from filters and feature maps, thereby improving the performance of the network model.
[0096] In one embodiment, the preset threshold includes multiple thresholds; S202 above includes: determining the reading mode of the thread of the reading filter and feature map based on the accumulated multidimensional value and the multiple thresholds.
[0097] In this embodiment, the reading mode of the thread reading the filter and feature map can be determined based on the relationship between the accumulated multiplication dimension value of the convolution operator and multiple thresholds. For example, if the preset thresholds include two thresholds, the reading mode of the thread reading the filter and feature map can be determined as small mode, medium mode, and large mode by the relationship between the accumulated multiplication dimension value of the convolution operator and these two thresholds; if the preset thresholds include three thresholds, the reading mode of the thread reading the filter and feature map can be determined as small mode, second smallest mode, medium mode, and large mode by the relationship between the accumulated multiplication dimension value of the convolution operator and these three thresholds.
[0098] In this embodiment, the reading mode of the thread for reading the filter and feature map is determined based on the accumulated multiplication dimension value and multiple thresholds. Multiple thresholds can be set according to the actual situation, thereby dividing the reading mode of the thread for reading the filter and feature map into multiple forms. The reading mode division is more accurate and the universality of the reading mode is improved.
[0099] In one embodiment, the multiple thresholds include a first threshold and a second threshold. Based on the accumulated multiplication dimension value and the multiple thresholds, the reading mode of the thread reading the filter and feature map is determined, including: if the accumulated multiplication dimension value is less than the first threshold, the reading mode is determined to be a first mode; if the accumulated multiplication dimension value is greater than or equal to the first threshold and less than the second threshold, the reading mode is determined to be a second mode; if the accumulated multiplication dimension value is greater than or equal to the second threshold, the reading mode is determined to be a third mode; wherein the constraints corresponding to the first mode, the second mode, and the third mode are all different.
[0100] In this embodiment, the multiple thresholds include a first threshold and a second threshold. If the accumulated multiplied dimension value is less than the first threshold, the reading mode is determined to be the first mode, i.e., the small mode corresponding to the above S402 embodiment. If the accumulated multiplied dimension value is greater than or equal to the first threshold and less than the second threshold, the reading mode is determined to be the second mode, i.e., the medium mode corresponding to the above S302 embodiment. If the accumulated multiplied dimension value is greater than or equal to the second threshold, the reading mode is determined to be the third mode, i.e., the large mode corresponding to the above S402 embodiment.
[0101] In this embodiment, multiple thresholds include a first threshold and a second threshold. Based on the relationship between the accumulated multiplier dimension value and the first and second thresholds, the read mode is divided into three modes. These three modes can effectively balance the hit rate of the buffer memory and the conflict of writing to shared memory between threads. The division of read modes is simple.
[0102] In one embodiment, the method further includes: controlling the callable thread to read the filter and feature map according to the thread arrangement corresponding to the reading mode.
[0103] In this embodiment, as Figure 11 As shown, the filter and feature map are input. Based on the relationship between the cumulative multiplication dimension value of the convolution operator of the network model and the preset threshold, the target reading mode of the thread for reading the filter and feature map is determined from small mode, medium mode and large mode. According to the thread arrangement of the target reading mode, the filter and feature map are read concurrently into shared memory by multiple threads. Then, according to the thread arrangement of the target reading mode, the filter and feature map are read into the register and the convolution result is calculated.
[0104] In combination with the above Figure 3 The thread arrangement for reading data corresponding to the target reading mode is explained below. For example, if the target mode is the small mode provided in the above embodiment, the arrangement of the callable thread rows is 4*4, and each callable thread row includes 1x16 column threads. The GPU fires 16 column threads each time. Using the thread arrangement of the small mode, each column thread reads 4 data points vertically along the direction of the accumulated multiplication dimension value of the convolution operator, spanning 16 channels, which is exactly 16 data points in the M direction, and 64 data points in the direction of the accumulated multiplication dimension value.
[0105] If the target mode is medium mode, the callable thread row arrangement is 2*8, with each row containing 2x8 callable thread columns. The GPU fires 16 callable thread columns each time. Using the medium mode thread arrangement, each callable thread column reads 4 data points vertically along the direction of the accumulated multiplication dimension value, and the two callable thread columns read 8 data points, spanning 8 channels, which means exactly 16 data points are read in the M direction, and 64 data points are read in the direction of the accumulated multiplication dimension value.
[0106] If the target mode is large mode, the callable thread row arrangement is 1*16, and each callable thread row includes 4x4 callable thread columns. The GPU fires 16 callable thread columns each time. Utilizing the large mode thread arrangement, each callable thread column reads 4 data points vertically along the accumulation multiplication dimension direction of the convolution operator. The 4 callable thread columns read 16 data points, spanning 4 channels, which is exactly 16 data points in the M direction, and 64 data points in the accumulation multiplication dimension direction.
[0107] In this embodiment, the callable thread is controlled to read the filter and feature map according to the thread arrangement method corresponding to the reading mode, so as to obtain the convolution result based on the read filter and feature map. This thread arrangement method can take into account the hit rate of the buffer memory and the conflict of writing to shared memory between threads, thereby improving the overall performance of the filter.
[0108] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0109] Based on the same inventive concept, this application also provides a thread arrangement determination device for implementing the thread arrangement determination method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more thread arrangement determination device embodiments provided below can be found in the limitations of the thread arrangement determination method described above, and will not be repeated here.
[0110] In one exemplary embodiment, such as Figure 12 As shown, a thread arrangement determination device is provided, comprising: an acquisition module 11, a first determination module 12, and a second determination module 13, wherein:
[0111] Module 11 is used to obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model;
[0112] The first determining module 12 is used to determine the reading mode of the thread that reads the filter and feature map of the convolution operator based on the accumulated multiplication dimension value and a preset threshold; wherein, the preset threshold is determined based on the size of the buffer memory;
[0113] The second determining module 13 is used to determine the thread arrangement corresponding to the reading mode based on the constraints of the reading mode, the size of the filter, and the number of callable threads; the constraints of the reading mode are related to the hit rate of the buffer memory and the conflict of writing to shared memory between threads.
[0114] In one embodiment, the second determining module includes:
[0115] The first determining unit is used to determine the number of callable thread column thread directions and the number of callable thread row thread directions based on the number of callable threads;
[0116] The second determining unit is used to determine the column thread arrangement method corresponding to the reading mode based on the constraints of the reading mode and the number of callable thread column directions.
[0117] The third determining unit is used to determine the row thread arrangement corresponding to the reading mode based on the column thread arrangement method corresponding to the reading mode, the filter size, and the number of callable thread row thread directions.
[0118] In one embodiment, the first determining module is further configured to determine the reading mode of the thread reading the reading filter and the feature map based on the accumulated multidimensional value and multiple thresholds.
[0119] In one embodiment, the first determining module is further configured to determine the reading mode as a first mode if the accumulated multiplication dimension value is less than a first threshold; determine the reading mode as a second mode if the accumulated multiplication dimension value is greater than or equal to the first threshold and less than a second threshold; and determine the reading mode as a third mode if the accumulated multiplication dimension value is greater than or equal to the second threshold; wherein the constraints corresponding to the first mode, the second mode and the third mode are all different.
[0120] In one embodiment, the device further includes:
[0121] The third determining module is used to determine the constraints of the read mode based on the accumulated multiplication dimension value corresponding to the read mode, the hit rate of the buffer memory, and the conflict of writing to shared memory between threads.
[0122] In one embodiment, the device further includes:
[0123] The control module is used to control the callable threads to read the filter and feature map according to the thread arrangement corresponding to the reading mode.
[0124] Each module in the aforementioned thread arrangement determination device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0125] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0126] Obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model;
[0127] Based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread that reads the convolution operator filter and feature map is determined; whereby the preset threshold is determined based on the size of the buffer memory.
[0128] The thread arrangement corresponding to the read mode is determined based on the constraints of the read mode, the size of the filter, and the number of callable threads; the constraints of the read mode are related to the cache hit rate and the conflict of threads writing to shared memory.
[0129] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0130] Based on the number of callable threads, determine the number of thread directions in the callable thread column and the number of thread directions in the callable thread row;
[0131] Based on the constraints of the read mode and the number of callable thread directions, determine the column thread arrangement corresponding to the read mode;
[0132] The row thread arrangement corresponding to the read mode is determined based on the column thread arrangement method corresponding to the read mode, the filter size, and the number of callable thread row thread directions.
[0133] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0134] Based on the accumulated multiplication dimension value and multiple thresholds, the reading mode of the thread for reading the filter and feature map is determined.
[0135] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0136] If the accumulated multiplier dimension value is less than the first threshold, then the reading mode is determined to be the first mode;
[0137] If the accumulated multiplier value is greater than or equal to the first threshold and less than the second threshold, then the reading mode is determined to be the second mode.
[0138] If the accumulated multiplication dimension value is greater than or equal to the second threshold, the reading mode is determined to be the third mode; among them, the constraints corresponding to the first mode, the second mode and the third mode are all different.
[0139] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0140] The constraints of the read mode are determined based on the cumulative multiplication dimension value corresponding to the read mode, the cache hit rate, and the conflict of writing to shared memory between threads.
[0141] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0142] Based on the thread arrangement corresponding to the reading mode, control the callable threads to read the filter and feature map.
[0143] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0144] Obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model; the filter is used to process the feature map; the accumulated multiplication dimension value is the accumulated multiplication dimension value of the convolution kernel accumulated multiplication of the convolution operator;
[0145] The reading mode of the thread for reading the reading filter and feature map is determined based on the accumulated multiplication dimension value and the preset threshold; whereby the preset threshold is determined based on the size of the buffer memory.
[0146] The thread arrangement corresponding to the read mode is determined based on the constraints of the read mode, the size of the filter, and the number of callable threads; the constraints of the read mode are related to the cache hit rate and the conflict of threads writing to shared memory.
[0147] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0148] Based on the number of callable threads, determine the number of thread directions in the callable thread column and the number of thread directions in the callable thread row;
[0149] Based on the constraints of the read mode and the number of callable thread directions, determine the column thread arrangement corresponding to the read mode;
[0150] The row thread arrangement corresponding to the read mode is determined based on the column thread arrangement method corresponding to the read mode, the filter size, and the number of callable thread row thread directions.
[0151] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0152] Based on the accumulated multiplication dimension value and multiple thresholds, the reading mode of the thread for reading the filter and feature map is determined.
[0153] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0154] If the accumulated multiplier dimension value is less than the first threshold, then the reading mode is determined to be the first mode;
[0155] If the accumulated multiplier value is greater than or equal to the first threshold and less than the second threshold, then the reading mode is determined to be the second mode.
[0156] If the accumulated multiplication dimension value is greater than or equal to the second threshold, the reading mode is determined to be the third mode; among them, the constraints corresponding to the first mode, the second mode and the third mode are all different.
[0157] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0158] The constraints of the read mode are determined based on the cumulative multiplication dimension value corresponding to the read mode, the cache hit rate, and the conflict of writing to shared memory between threads.
[0159] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0160] Based on the thread arrangement corresponding to the reading mode, control the callable threads to read the filter and feature map.
[0161] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0162] Obtain the accumulated multiplication dimension value corresponding to the convolution operator of the network model;
[0163] Based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread that reads the convolution operator filter and feature map is determined; whereby the preset threshold is determined based on the size of the buffer memory.
[0164] The thread arrangement corresponding to the read mode is determined based on the constraints of the read mode, the size of the filter, and the number of callable threads; the constraints of the read mode are related to the cache hit rate and the conflict of threads writing to shared memory.
[0165] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0166] Based on the number of callable threads, determine the number of thread directions in the callable thread column and the number of thread directions in the callable thread row;
[0167] Based on the constraints of the read mode and the number of callable thread directions, determine the column thread arrangement corresponding to the read mode;
[0168] The row thread arrangement corresponding to the read mode is determined based on the column thread arrangement method corresponding to the read mode, the filter size, and the number of callable thread row thread directions.
[0169] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0170] Based on the accumulated multiplication dimension value and multiple thresholds, the reading mode of the thread for reading the filter and feature map is determined.
[0171] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0172] If the accumulated multiplier dimension value is less than the first threshold, then the reading mode is determined to be the first mode;
[0173] If the accumulated multiplier value is greater than or equal to the first threshold and less than the second threshold, then the reading mode is determined to be the second mode.
[0174] If the accumulated multiplication dimension value is greater than or equal to the second threshold, the reading mode is determined to be the third mode; among them, the constraints corresponding to the first mode, the second mode and the third mode are all different.
[0175] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0176] The constraints of the read mode are determined based on the cumulative multiplication dimension value corresponding to the read mode, the cache hit rate, and the conflict of writing to shared memory between threads.
[0177] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0178] Based on the thread arrangement corresponding to the reading mode, control the callable threads to read the filter and feature map.
[0179] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0180] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0181] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0182] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for determining thread arrangement, characterized in that, The method includes: Obtain the accumulated multiplication dimension value of the convolution operator of the network model; the accumulated multiplication dimension value is determined based on the product of the number of channels of the filter, the width of the filter, and the length of the filter in the network model; Based on the accumulated multiplication dimension value and a preset threshold, the reading mode of the thread that reads the filter and feature map of the convolution operator is determined; wherein, the preset threshold is determined according to the size of the buffer memory; The thread arrangement corresponding to the read mode is determined based on the constraints of the read mode, the size of the filter, and the number of callable threads; the constraints of the read mode are related to the hit rate of the buffer memory and the conflict of writing to shared memory between threads.
2. The method according to claim 1, characterized in that, The step of determining the thread arrangement corresponding to the read mode based on the constraints of the read mode, the size of the filter, and the number of callable threads includes: Based on the number of callable threads, determine the number of callable thread column directions and the number of callable thread row directions; Based on the constraints of the read mode and the number of callable thread column directions, determine the column thread arrangement corresponding to the read mode; The row thread arrangement corresponding to the read mode is determined based on the column thread arrangement method corresponding to the read mode, the size of the filter, and the number of callable thread row thread directions.
3. The method according to claim 1, characterized in that, The preset threshold includes multiple thresholds; the step of determining the reading mode of the thread reading the filter and feature map of the convolution operator based on the accumulated multiplication dimension value and the preset threshold includes: Based on the accumulated multiplication dimension value and the multiple thresholds, the reading mode of the thread that reads the filter and the feature map is determined.
4. The method according to claim 3, characterized in that, The plurality of thresholds includes a first threshold and a second threshold. Determining the reading mode of the thread reading the filter and the feature map based on the accumulated multiplication dimension value and the plurality of thresholds includes: If the accumulated multiplication dimension value is less than the first threshold, then the reading mode is determined to be the first mode; If the accumulated multiplication dimension value is greater than or equal to the first threshold and less than the second threshold, then the reading mode is determined to be the second mode; If the accumulated multiplication dimension value is greater than or equal to the second threshold, then the reading mode is determined to be the third mode; wherein the constraints corresponding to the first mode, the second mode and the third mode are all different.
5. The method according to claim 1, characterized in that, The method further includes: The constraints of the read mode are determined based on the cumulative multiplication dimension value corresponding to the read mode, the hit rate of the buffer memory, and the conflict of writing to shared memory between threads.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: Based on the thread arrangement corresponding to the reading mode, the callable thread is controlled to read the filter and the feature map.
7. A thread arrangement determination device, characterized in that, The device includes: The acquisition module is used to acquire the accumulated multiplication dimension value corresponding to the convolution operator of the network model; the accumulated multiplication dimension value is determined based on the product of the number of channels of the filter, the width of the filter, and the length of the filter in the network model; The first determining module is used to determine the reading mode of the thread that reads the filter and feature map of the convolution operator based on the accumulated multiplication dimension value and a preset threshold; wherein the preset threshold is determined based on the size of the buffer memory; The second determining module is used to determine the thread arrangement corresponding to the reading mode based on the constraints of the reading mode, the size of the filter, and the number of callable threads; the constraints of the reading mode are related to the hit rate of the buffer memory and the conflict of writing to shared memory between threads.
8. A computer device comprising a buffer memory and a processor, wherein the buffer memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Convolutional neural network acceleration method and system based on Cortex-M processor, and medium
CN114282662A
Image encoding and decoding method and apparatus
TW202324308A