Method for storing data in buffer, medium, logic and integrated circuit

Through the dynamic addressing scheme in the CNN hardware accelerator, data is evenly distributed to the memory group according to the input data and filter format parameters, which solves the problem of inconsistent data throughput caused by different layer data formats and filter sizes, and improves hardware performance and efficiency.

CN118690809APending Publication Date: 2024-09-24IMAGINATION TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410818221.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2016-10-06
Filing Date
2017-10-09
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

When the convolutional neural network (CNN) hardware accelerator processes input data, it faces the problem of inconsistent data throughput and low efficiency caused by different data formats and filter sizes of different layers.

Method used

A dynamic addressing scheme is used to evenly allocate data to multiple memory banks based on the input data and filter format parameters, ensuring maximum and consistent data storage and reading within each read cycle, avoiding grouping. conflicts to improve data throughput.

Benefits of technology

It improves the data throughput and processing speed of CNN hardware, reduces power consumption, adapts to the data formats and filter dimensions of different layers, and ensures the improvement of hardware performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690809A
    Figure CN118690809A
Patent Text Reader

Abstract

The invention relates to a method for storing data in a buffer, a medium, logic and an integrated circuit. A method of storing input data for a layer of a convolutional neural network in a buffer comprising NB groups for processing, each group comprising a plurality of words, the method comprising: receiving input data comprising input data values to be processed in a layer of the convolutional neural network, the input data comprising P planes, each plane has X columns and Y rows; identifying a value WordsPerLine, the value WordsPerLine indicating a number of words of each group required to store a row of the input data; determining an address in the buffer at which each of the input data values is to be stored based on the WordsPerLine and a filter width m or a filter height N of a filter to be applied to the input data; and storing the received input data value at the determined address in the buffer for retrieval for processing in the tier.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the original invention patent application with application number 201710931313.2 (application date: October 9, 2017, original invention name: Buffer addressing for convolutional neural networks). Technical Field

[0002] The present application relates to buffer addressing for convolutional neural networks. Background Art

[0003] A convolutional neural network (CNN) is a type of artificial neural network that can be used in machine learning applications. In particular, CNN can be used in signal processing applications, including image processing and computer vision applications.

[0004] In order to implement CNN, a hardware accelerator can be produced. The hardware accelerator can be a specific hardware implementation configured to implement a specific CNN, or it can be a general hardware implementation configured to implement different CNNs (or any CNN). In some hardware accelerators for implementing CNN, hardware may be required to process a large amount of input data at a high rate of throughput. Therefore, the hardware must buffer the input data in a manner that ensures that the rate of data input to the computing part of the hardware is maintained constant. Ideally, each layer of the CNN is processed by the hardware with a relatively similar amount of time. This is particularly challenging for the hardware implementing CNN because the input data has different dimensions at each layer in a typical CNN application. The addressing scheme for determining the memory address for storing input data in a buffer for retrieval when the input data is processed by the CNN can be configured to effectively store input data for some layers, but may not be suitable for the data format of other layers.

[0005] Therefore, there is a need for an improved method to improve the performance and data throughput of hardware configured to implement CNNs. Summary of the invention

[0006] This Summary is provided to introduce some concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.

[0007] Hardware logic such as hardware accelerators can be configured to implement one or more convolutional neural networks (CNNs). In order to maximize the input data throughput in the computing part of the hardware for implementing CNN, it is desirable to buffer the input data read from the memory before processing. In order to improve data throughput, data can be evenly stored in the memory group based on the way it will be retrieved. An addressing scheme is described herein, which allocates input data to the input data buffer in the following manner: the mode enables the input data to be evenly distributed across multiple data packets based on the format parameters related to the format of the input data and the filter for processing the input data. Therefore, data is retrieved from the packet memory with high throughput. More specifically, when the number of filters used for each pass is small, for example, when a large filter size (due to coefficient buffer constraints) needs to be processed at one time, the input buffer performance may be crucial. In this way, for some layers, it may take longer to transfer data to the computing part than to process it in the convolution engine. Therefore, loading input data into the convolution engine may be a limiting factor in the performance of hardware for implementing CNN.

[0008] A method for receiving input data for a layer of a convolutional neural network (CNN) for processing is provided, the method comprising: receiving input data including input data, the input data being processed in the layer of the CNN; determining an address in a packet memory of a buffer at which the received data value is to be stored based on format data, the format data indicating format parameters of the input data in the layer and indicating format parameters of a filter to be used to process the input data in the layer; and storing the received input data value at the determined address in the buffer for retrieval for processing in the layer.

[0009] Provided is hardware logic for implementing a convolutional neural network configured to receive input data for a layer of a convolutional neural network "CNN", the convolutional neural network being configured to: receive input data including input data, input data values ​​to be processed in the layer of the CNN; determine an address in a packet memory of a buffer at which the received data values ​​are to be stored based on format data indicating format parameters of the input data in the layer and format parameters of a filter to be used to process the input data in the layer; and store the received input data values ​​at the determined address in the buffer for retrieval for processing in the layer.

[0010] A convolutional neural network may be embodied in hardware on an integrated circuit. A method of manufacturing hardware for implementing a convolutional neural network at an integrated circuit manufacturing system may be provided. An integrated circuit defining data set may be provided that, when processed in an integrated circuit manufacturing system, configures the system to manufacture hardware for implementing a convolutional neural network. A non-transitory computer-readable storage medium having a computer-readable description of an integrated circuit stored thereon may be provided, the computer-readable description, when processed, causing a layout processing system to generate a circuit layout description for use in the integrated circuit manufacturing system to manufacture hardware for implementing a convolutional neural network.

[0011] An integrated circuit manufacturing system can be provided, comprising: a non-transitory computer-readable storage medium having a computer-readable integrated circuit description stored thereon that describes hardware for implementing a convolutional neural network; a layout processing system configured to process the integrated circuit description to generate a circuit layout description of an integrated circuit that implements the hardware for implementing the convolutional neural network; and an integrated circuit generation system configured to manufacture the hardware for implementing the convolutional neural network based on the circuit layout description.

[0012] A computer program code for performing the method as claimed in any one of the preceding claims may be provided. A non-transitory computer readable storage medium having computer readable instructions stored thereon may be provided which, when executed at a computer system, cause the computer system to perform the method as claimed in any one of the preceding claims.

[0013] As will be apparent to those skilled in the art, the above-described features may be combined as appropriate and may be combined with any aspect of the embodiments described herein. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Examples will now be described in detail with reference to the accompanying drawings, in which:

[0015] Figure 1 shows an example format of input data used in a layer of a convolutional neural network;

[0016] Figure 2 An example hardware accelerator for implementing a CNN is shown;

[0017] Figure 3 An example of filter traversal across input data for a layer of a convolutional neural network is shown;

[0018] Figure 4 An example input data buffer including a plurality of memory banks is shown;

[0019] Figure 5 shows addressing of input data values ​​in an input data buffer according to a first embodiment;

[0020] Figure 6 (a) to (f) show the filter traversing multiple stages of input data according to the first embodiment;

[0021] Figure 7(a) to Figure 7(f) shows a plurality of cycles of reading data from an input data buffer according to a first embodiment;

[0022] Figure 8 shows an example format of data according to a first example of the second embodiment;

[0023] Fig. 9 shows addressing of input data values ​​in an input data buffer according to a first example of a second embodiment;

[0024] Fig.10 (a) and (b) show different methods of reading data from an input data buffer according to a first example of the second embodiment;

[0025] Fig.11 shows an example format of data according to a second example of the second embodiment;

[0026] Fig.12 shows addressing of input data values ​​in an input data buffer according to a second example of a second embodiment;

[0027] Figure 13(a) to Figure 13(d) shows a different method of reading data from an input data buffer according to a second example of the second embodiment;

[0028] Fig.14 (a) to (d) show the filter according to the third embodiment traversing multiple stages of input data;

[0029] Fig.15 shows addressing of input data values ​​in an input data buffer according to a third embodiment;

[0030] Figure 16(a) to Figure 16(l) shows a plurality of cycles of reading data from an input data buffer according to a third embodiment;

[0031] Fig.17 shows reading data from an input data space according to a fourth embodiment;

[0032] Fig.18 (a) to (f) show the filter according to the fourth embodiment traversing multiple stages of input data;

[0033] Fig.19 shows the addressing of input data values ​​in an input data buffer according to a fourth embodiment;

[0034] Figure 20(a) to Figure 20(i) shows a plurality of cycles of reading data from an input data buffer according to a fourth embodiment;

[0035] Fig.21 An example method of implementing an addressing scheme is shown;

[0036] Fig. 22 A computer system is shown in which a convolutional neural network hardware accelerator is implemented; and

[0037] Fig.23 An integrated circuit manufacturing system for generating an integrated circuit implementing a convolutional neural network hardware accelerator is shown.

[0038] The accompanying drawings show various examples. It will be appreciated by those skilled in the art that the element boundaries (e.g., boxes, box groups, or other shapes) shown in the accompanying drawings represent one example of boundaries. It is possible that, in some examples, one element may be designed as multiple elements, or multiple elements may be designed as one element. Where appropriate, common reference numerals are used throughout the accompanying drawings to represent similar features. DETAILED DESCRIPTION

[0039] The following description is given by way of example to enable those skilled in the art to make and use the invention.The present invention is not limited to the embodiments described herein, and various modifications of the disclosed embodiments will be apparent to those skilled in the art.

[0040] Embodiments will now be described by way of example only.

[0041] A convolutional neural network (CNN) is a form of artificial neural network that includes multiple interconnected layers with weights associated with them. CNNs are configured to perform signal processing tasks, including computer vision tasks. The functionality of a CNN is represented by the weights applied to the input data for each layer.

[0042] CNN is configured to process a set of input data for each layer by performing convolution of the input data and the weights (filters) associated with the layer. For the first layer, the "input data" can be considered as the initial first input to the CNN, which can represent the RGB values ​​of the image for the first layer, where each plane represents one of the red, green and blue values. Since CNNs typically utilize a power of 2 number of input planes, a fourth plane containing zero values ​​may also exist in the RGB layer. In the first layer, the input data is processed and a first set of intermediate data is generated that is passed to the second layer. The generated set of intermediate data can form the input data for the subsequent (second) layer.

[0043] The first set of intermediate data can be considered to form input data for the second layer, and the second layer processes the first intermediate data to produce output data in the form of second intermediate data. In the case where the CNN includes a third layer, the third layer receives the second intermediate data as input data and processes the data to produce the third intermediate data as output data. This process is repeated until the last layer produces output data that can be considered as the output of the CNN.

[0044] Figure 1 An example format of input data used in a specific layer of a CNN is shown in Figure 1 It can be seen that the input data for a layer includes a total of P planes 500 of input data, and the input data for a particular layer with the same number of planes may have multiple planes in each layer. The data plane has a width X and a height Y. A CNN is defined using multiple layers, each layer having F filters w1…w associated with it. F , where F is greater than 1. Filter w1…W F Each has dimensions m×n×P, and as Figure 2 As shown, the filter is convolved with the input data by traversing a plurality of steps in the X and Y directions in a gridded manner according to the corresponding horizontal and vertical stride lengths s and t. A specific value in the input data can be identified using three coordinates in the three-dimensional input data space, i.e., coordinates (x, y, p), where x represents the horizontal position in the space, y represents the vertical position in the space, and p represents the plane index.

[0045] The example hardware logic 100 for implementing a CNN is Figure 2 . The example hardware logic 100 can be regarded as a hardware accelerator for implementing CNN. The hardware logic 100 can be an independent hardware module configured to receive input data to be processed by the CNN implemented by the hardware logic, define the filter data of the CNN to be implemented by the hardware logic, and define the control flow of the data required to implement the CNN, such as the format data of at least one of the input data and the filter logic, and other features, such as the number of layers of the CNN that the hardware logic needs to implement and the data format used. For example, the control flow may include control information for controlling the operation of the hardware, and format information indicating the format in which the input data and the filter data should be processed. In some arrangements, the hardware logic 100 may be an independent module configured to receive the data from an external source. In other embodiments, the hardware logic 100 may be implemented next to a processor such as a CPU and / or a GPU. The hardware logic 100 may be implemented in a system on chip (SoC).

[0046] The hardware logic 100 includes a coefficient buffer 400 and an input data buffer 200, the input data buffer 200 being configured to receive data from a memory 600, wherein the memory 600 may be located inside or outside the hardware logic 100. The coefficient buffer 400 is configured to store weight data (also referred to as coefficient data) received from the memory 600. The weight data may be considered as data defining filter values ​​convolved with input data values. The input data buffer 200 is configured to store input data received from the memory 600. Before being passed to the convolution engine 300, the weights and input data stored in the memory are passed to the coefficient buffer 400 and the input data buffer 200 for buffering, respectively, and the convolution engine 300 includes i convolution engines 310-1 to 310-i, where i may correspond to the maximum width in a particular CNN or may be fixed.

[0047] Each of the i convolution engines 310-1 to 310-i is configured to perform convolution of filter data received from the coefficient buffer 400 and input data received from the input data buffer 200. In each cycle, each of the convolution engines 310-1 to 310-i performs convolution of the same set of weights in the plurality of weights with windows corresponding to different output positions.

[0048] For example, a window of input data may be processed at a particular processing stage of a convolution engine. At this stage, the window may be confined to a particular location based on the size of the weights in the layer being processed. For this example, assume m=3 and n=3. Thus, a window of data of size 3×3 is retrieved from the input data buffer 200 and passed to each convolution engine. The exemplary window 550 is in Figure 3As shown in . Each convolution engine 310-1 to 310-i is provided with the same filter among multiple filters to be applied to a specific layer, and then a convolution operation is performed. Then, for each convolution engine with the provided filter, a window of input data is passed to the convolution engine. Each filter at each convolution engine is applied to a specific window position. The filters applied across convolution engines can be considered as a set of windows each located at a different position in the input data space. In a subsequent read cycle, if not all input data required to complete the processing has been passed to the convolution engine for a specific window set (for example, not all P data planes of this set of windows have been passed to the convolution engine), the additional input data of the set of windows is passed to the convolution engine. Once all data of a specific set of windows has been processed by the convolution engine, the window set applied across convolution engines 310-1 to 310-I is moved to a new set of positions along the data space, and the process is repeated. This transformation of a window set across the input data can be performed in a rasterized manner, where the window set is effectively traversed in the horizontal direction from an origin position at the upper left corner of the input plane (i.e., coordinate y is fixed and coordinate x increases). Once a row of input data is traversed, the data wraps around to the beginning of the next row (or multiple rows of input data are traversed depending on the span t of the filter). At each (x, y) position, all data values ​​from coordinate p=0 to p=P can be read from the input data buffer before increasing x.

[0049] Therefore, for each window applied to the input data, the input data is read from the input data buffer 200 and passed to the convolution engine 300. However, the input data buffer may require multiple clock cycles to retrieve data from the input data buffer 200. For example, the input data may be large (e.g., x, y, or p is large). In this case, a relatively large amount of data may need to be passed to the convolution engine 300 for a single layer of the CNN. The limiting factor when reading data from the input data buffer 200 is the amount of data that can be physically read from the input data buffer within a specific read cycle (e.g., a single clock cycle). Therefore, it is desirable to implement an input data buffer that maximizes the data throughput from the input data buffer to the convolution engine.

[0050] In some arrangements, input data may be stored in the memory 600 in a quasi-planar format, wherein multiple quasi-planar planes may be stored in an interleaved format. Data may be stored in the memory 600 in planes of fixed size. The fixed size may correspond to the burst size of the memory 600. Specifically, data values ​​at a particular position (x, y) are stored together in the memory 600 for a fixed predetermined number of planes. For example, data values ​​at positions (x, y) may be stored in consecutive memory locations between plane indices 0 to P. Data may be stored in the memory 600 and read continuously from the memory 600. In other arrangements, the number of planes stored continuously may be larger, so that the quasi-planar planes are separated into multiple sub-planes, each sub-plane storing a fixed number of planes for data at a particular position (x, y). An example of this data format for coordinates (x, y, p) is shown in the following table, where P = 16, but only eight plane values ​​are stored continuously together:

[0051]

[0052]

[0053] The subsequent plane for 8≤p≤15 is as follows:

[0054]

[0055] As described above, the size of each quasi-planar plane is typically defined according to the burst size of memory 600. Thus, all input data values ​​for a particular sub-range of a plane (e.g., 8≤p≤15) may fit within the quasi-plane, provided that X and Y are small enough so that the input data for a particular sub-range of the plane (e.g., 8≤p≤15) fits within the burst size of memory 600. If the total amount of data to be stored for the quasi-planar plane is less than the burst size, the memory is padded with the remainder of the memory equivalent to the burst, and the next quasi-planar plane is stored in the next portion of the memory.

[0056] However, in other arrangements, the dimensions of X and Y may be such that not all data values ​​for a particular plane fit within the quasi-plane. In this case, the input data for a particular sub-range of the plane is divided into a plurality of quasi-planar planes.

[0057] Depending on the data format, the memory 600 may store all values ​​at coordinates (x, y) across all planes (or predetermined sub-ranges of planes) at consecutive locations within the memory. In this way, these values ​​may be retrieved from the memory 600 consecutively in the following order: (0, 0, 0), (0, 0, 1), ..., (0, 0, P-1), where (0, 0, 0) represents the leftmost value of the plane. In some arrangements, each plane stored in the memory 600 has a fixed size. In this way, the amount of data stored in the plane is fixed, but in addition to the size of the plane (defined by X and Y), the proportion of the sequence stored in a single quasi-planar plane will depend on the total number of planes P. Each position is stored in the memory 600 and is therefore retrieved from the memory 600 consecutively in a rasterized manner. In this way, for a sub-range of the plane, the first row of values ​​from (0, 0) to (X-1, 0) is stored consecutively. Then, the second row of values ​​from (0,1) to (X-1,1) is stored, and the process is repeated until the last row (0,Y-1) to (X-1,Y-1) is stored.

[0058] Thus, the data stored in the memory 600 is stored in a manner that provides locality to the stored data. In a CNN, a filter is applied to the input data within a window and then the filter is applied to a subsequent window such that the filter is applied across a plane in a gridded format (e.g., Figure 3 ), which is limited by the defined filter stride. By storing the data in the memory 600 in this way, a large number of consecutive values ​​do not need to be loaded from the memory in order to obtain and retain the input data values ​​required for the next filter to be applied in the input data buffer. Similarly, the filter is applied to positions across all planes. In this way, the data can be retrieved in a manner related to the order in which the data is processed within the CNN. Therefore, it is efficient to retrieve data from the memory in a burst manner while minimizing the number of bursts required to retrieve useful data from the memory 600.

[0059] The input data retrieved from the memory 600 is stored in a plurality of different groups 210-0 to 210-(N) in the input data buffer 200. B -1). The number of groups in the input data buffer 200 is determined by N B , and is typically a power of 2. Since the data read from memory 600 is read in a sequential manner and has some local geometry related to the order in which the convolution engine will use the data, it is desirable to determine an addressing scheme for storing and retrieving data to and from the groups in a manner that reduces or eliminates group conflicts and maximizes throughput. In addition, since the size of the input data and filters may differ between layers, it is desirable to determine an addressing scheme that is adaptable between the data formats of different layers.

[0060] In some arrangements, only a single address in each group of the input data buffer 200 may be read in each clock cycle. In this way, the inventors have recognized the need to establish an addressing scheme that can ensure that the amount of data read from the input data buffer is maximized and consistent for each read cycle. In other words, the inventors have recognized that multiple input data values ​​that need to be read from the same group of memory during a read cycle may cause group conflicts or collisions within the memory. Such conflicts mean that one of two or more data elements that need to be accessed during the same read cycle needs to be read during a subsequent read cycle, which reduces the data throughput (and consistency of data throughput) from the input data buffer 200 to the convolution engine 300, and thereby reduces the processing speed of the hardware implementation of the CNN and reduces power consumption.

[0061] Specifically, in some arrangements, it may be necessary to place the input data into the memory groups of the input data buffer in a manner that ensures that the data output from the group can be maximized. This means that, at each read cycle of the input data buffer, the input data value from each group of the buffer is accessed. To this end, an addressing scheme needs to be established for the groups of the input data buffer to ensure that the data is correctly allocated to the various groups of memory.

[0062] The inventors have recognized that, although a static addressing scheme can be determined that maximizes the data throughput from the input data buffer 200 to the convolution engine 300 for a particular set of parameters for a given layer of a CNN, i.e., for a given dimension of the input data and weight (filter) data, certain addressing schemes may be less preferred for other layers having different dimensions. For example, in a CNN, the dimensions of the input data may vary between layers, such that an addressing scheme that provides a high throughput for the first layer may not provide useful throughput for subsequent layers. In the example of image processing, the data format of the first layer may involve the resolution of the image in RGB space.

[0063] The addressing scheme according to one or more examples of the present disclosure is as follows. The addressing scheme set forth herein is dynamic because the precise addressing scheme used for a particular layer may be different from the addressing scheme used in other layers. In other words, the addressing scheme can adapt to the format of the input data and the format of the filter data in each layer. The addressing scheme may depend on the dimension of the input data and the dimension of the filter weights of a particular layer and the way the convolution engine processes the input data. Since the dimension of the filter to be applied changes, the addressing scheme can be configured to correspond to the dimension of the input data of the layer. Similarly, the specific input data required by the convolution module may depend on the dimension of the filter to be applied. In this way, the addressing scheme to be used depends on the dimension of the filter to be applied. The addressing scheme described herein provides a method for storing input data in a group of memories of an input data buffer, regardless of the data and filter dimensions.

[0064] Fig.21 A method of implementing an addressing scheme that can be performed for each layer of a CNN to be implemented according to the present disclosure is shown. For example, a method 2100 is shown, wherein input data is received at step 2110. The input data includes input data values ​​to be processed in a layer of the CNN. The method 2100 also includes determining an address in a group memory of a buffer at step 2120, wherein the received data value is to be stored according to format parameters indicating the input data in the layer and format parameters indicating the filter to be used to process the input data in the layer. At step 2130, the input data value is stored at the determined address in the buffer for retrieval for processing in the layer. An example of a solution and its implementation is provided below.

[0065] like Figure 4 As shown, the input data buffer 200 is configured as a memory N B Groups (210-0 to 210-(N B -1)), where N B Typically the number of groups is a power of 2. Each group has MEMSIZE addresses, so that the total size of the input data buffer 200 is N B *MEMSIZE is given.

[0066] For the purposes of describing the examples listed below, it is assumed that each memory word is used to store a single input data value. In some arrangements, a dynamic number of planes and a dynamic number of data values ​​may be packed into a single memory word. To implement this, the values ​​P and X may be replaced by the corresponding values ​​in the following equations: and To replace, where PK p is the number of plane units packed into a single memory word, where PUW is the number of planes P of multiple planes packed into a single plane unit, and where PKx is the number of x positions packed into a single memory word. In the case where multiple planes or data values ​​are stored in a single memory word, the values ​​P, M, X, x, and p will be replaced by the following corresponding values ​​in the address calculation, the replacement values ​​corresponding to the original values ​​but with the character "'":

[0067]

[0068] Typically, memory locations in the input data buffer 200 can be addressed using two values. A first value, BANKSEL, indicates the bank of memory where the data value is located, where 0≤BANKSEL≤N B -1. The second value MEMADDR represents the memory location of a particular group, where 0≤MEMADDR≤MEMSIZE-1. Figure 4 Four example locations in the input data buffer 200 are shown represented by hash lines. The first location is shown in group 0 and has a BANKSEL value of 0 and a MEMADDR value of 128. The second location is shown in group 1 and has a BANKSEL value of 1 and a MEMADDR value of 57. The third location is shown in group 2 and has a BANKSEL value of 2 and a MEMADDR value of 193. The fourth location is shown in group N B -1 is shown, and the BANKSEL value is N B -1, MEMADDR value is 234.

[0069] Addressing Scheme - First Implementation

[0070] In a first example of an addressing scheme, input data values ​​are stored in the external memory in an interleaved manner which may be referred to as an M*N*P read method.

[0071] The addressing scheme determines the location in the input data buffer of each value of input data read from the memory so that there is a one-to-one correspondence between the (x, y, p) coordinates in the input data space and the BANKSEL and MEMADDR values ​​in the input data buffer. Specifically, the addressing scheme is used to generate the MEMADDR and BANKSEL values. Each input data value is then stored in the input data buffer at a location based on the values ​​calculated for MEMADDR and BANKSEL.

[0072] Before calculating the MEMADDR and BANKSEL values ​​for the input data values, the value WordsPerLine is identified for the particular layer to be processed. This value can be calculated based on the received parameter values, or it can be provided explicitly. The WordsPerLine value provides information about the number of lines across all N BThe value WordsPerLine indicates the number of words of memory to be used in each group to represent a row of input data values ​​across all input planes P. For example, P*X is the number of input data values ​​across rows or lines of the input data space. The value WordsPerLine indicates the number of words of each group of memory required to store a row of input data. This calculation effectively performs "rounding" to the next complete number of words across all memory groups. That is, if a row of input data is written to memory before the last memory group is reached, the next memory address is filled with the remaining groups for that row.

[0073]

[0074] For example, if N B =8 and (P*X)=5, Then round the value down to 1 and multiply by N B To obtain the value WordsPerLine = 8. Therefore, to represent a line of input data values ​​(across all P planes), 8 words of memory are required. In this way, a line of memory is used to represent the input data values. In another example, if N B =8 and (P*X)=10, then When rounded down, this results in WordsPerLine=16. Therefore, more than 8 words of memory are required to store a row of input data values. Therefore, two complete rows of memory are used to represent the values ​​in a single row of input data, even though the last row will be partially filled. Although this reduces memory usage efficiency, since the individual input data rows are stored separately from each other, this approach makes it possible to avoid group conflicts.

[0075] Subsequently, the values ​​of MEMADDR and BANKSEL are determined for each input data value. Specifically, MEMADDR is determined by the following equation, where x, y, p represent the coordinates of the input data value, P represents the total number of planes of the input data, p represents the plane index, and m represents the filter width:

[0076]

[0077] BANKSEL(x,y,p)=(x*P+p+y*m*P)%N B

[0078] exist Figure 5 to Figure 7(f) An example of application of the addressing scheme of an embodiment is shown in B =8, m=2, X=3 and P=5. Figure 5Memory locations of an input data buffer storing input data values ​​are shown. Memory locations may be identified by a group number from 0 to 7 and an address location (MEMADDR) in the corresponding group. For example, the upper left memory location is identified by MEMADDR=0 and BANKSEL=0, and the lower right value is identified by MEMADDR=7 and BANKSEL=7. In this example, each memory location stores a single input data value. Each input data value stored in a memory location is represented by three coordinates (x, y, p), which represent the corresponding coordinates at which the value is retrieved from the input data space. The location of the input data value in the input data buffer is determined according to the addressing scheme equations described above, and according to this example, the resulting value is as shown. Figure 5 Arrangement shown.

[0079] from Figure 5 As you can see, four cells are highlighted with vertical lines. These cells represent new rows for entering data. Figure 5 It can also be seen that due to the WordsPerLine calculation, there are memory locations for padding (referenced using the term "PAD" in the figure).

[0080] Figure 6 The example of shows data read from the input buffer and provided to the convolution engine through multiple read cycles. Specifically, Figure 6 Shown according to Figure 5 Example of data read from the input data buffer and provided to the convolution engine during the application of a 2×2 filter to a plane of input data. At each stage, the filter is applied to all P planes of four different (x,y) positions of the input data. The filter traverses the input data in a rasterized manner by traversing a row of the input data according to the horizontal stride s, and then repeats the traversal at increasing vertical positions based on the vertical stride t. Figure 6 In the first stage shown in (a), the filter is applied to all P planes at positions (0,0,p), (0,1,p), (1,0,p), and (1,1,p). Figure 6 In the second stage shown in (b), the filter is applied to all P planes at positions (1,0,p), (2,0,p), (1,1,p), and (2,1,p). Figure 6 In (c), the filter is applied to positions (0,1,p), (1,1,p), (0,2,p), and (1,2,p) in the third stage. Figure 6 In (d), the filter is applied to positions (1,1,p), (2,1,p), (1,2,p), and (2,2,p) in the fourth stage. Figure 6In (e), the filter is applied to positions (0,2,p), (1,2,p), (0,3,p), and (1,3,p) in the fifth stage. Figure 6 In (f), the filter is applied to positions (1,2,p), (2,2,p), (1,3,p) and (2,3,p) in the sixth stage. It should be understood that, as will be explained later, in other arrangements, the filter can traverse the input data in a different manner.

[0081] Figure 6 The multiple stages of retrieving input data values ​​from the input data buffer to be passed to the convolution engine are shown. The input data retrieved from the input data buffer is based on the convolution engine, which Figure 5 The input data is requested by traversing the filter across the input data as shown. It will be appreciated that the memory 600 can be configured so that this stage can be divided into multiple read cycles according to the read bandwidth of the memory. The read bandwidth can be considered to be limited by the number of groups, because only one word can be read from each group in a single read cycle. Therefore, it is expected that each read cycle will retrieve N from the input data buffer. B The READ_READ_CYCLE_READ_FULL_ADDRESS_SCHEMA_01 can read words (e.g., input data values) without a bank conflict. A bank conflict occurs when two or more input data values ​​required in a single read cycle are located in the same bank of memory. As shown in the following example, by using the example addressing scheme, bank conflicts are avoided for each read cycle.

[0082] Figure 7(a) to Figure 7(c) Each shows the data buffer for reading from the input Figure 6 The first stage shown in (a) requires consecutive read cycles of input data. As further detailed below, three read cycles are required to read Figure 6 All input data values ​​in the first stage of (a).

[0083] FIG. 7( a) shows memory locations in the input data buffer read during a first read cycle. Specifically, the dashed lines represent memory locations read during a read cycle. As can be seen from FIG. 7( a), eight input data values ​​are read from the input data buffer, one data value from each group of the input data buffer. All eight input data values ​​read from the input data buffer are stored in different memory groups and can therefore all be read in a single cycle without a group conflict.

[0084] Figure 7(b) shows the memory locations in the input data buffer that are read during the second read cycle. As can be seen from Figure 7(b), eight different input data values ​​are read from the input data buffer, one data value from each of the eight memory groups. In Figure 7(b), it can be seen that some data values ​​are read from different MEMADDR locations. Specifically, the values ​​(1,0,3) and (1,0,4) are read from MEMADDR=1, and the values ​​(0,1,0), (0,1,1), (0,1,2), (0,1,3), (0,1,4), (1,1,0) are read from MEMADDR=2. However, since each value is read from a different memory group, all eight values ​​can be read in the same read cycle without bank conflicts. Figure 7(c) shows Figure 6 (a) The third read cycle of the filter position, where the last four input data values ​​are read.

[0085] Figure 6 (b) shows the second filter position during processing of the input data by the filter, Figure 7(d) to Figure 7(f) The reading cycles in the three reading cycles for reading the input data values ​​required for the convolution engine to perform calculations from the input data buffer are shown respectively. Specifically, FIG. 7( d ) shows the first reading cycle of the second filter position, in which eight input data values ​​are read from the input data buffer. As can be seen from FIG. 7( d ), eight input data values ​​are read without group conflicts.

[0086] Furthermore, it should be noted that during the read cycle of FIG. 7( d ), some of the input data values ​​read during the read cycle of FIG. 7( a ) are also read, namely (1,0,0), (1,0,1), and (1,0,2). This corresponds to Figure 6 7(a) and (b). The addressing scheme used to store the input data values ​​in the input data buffer ensures that reading these values ​​during the read cycle of Figure 7(a) or Figure 7(d) does not result in a group conflict with other input data values ​​to be read during the corresponding read cycle. For example, in the arrangement of Figure 7(d), the other five input data values ​​to be read from the input data buffer are to be read from MEMADDR=1, BANKSEL=0 to 4. As can be seen in the second and third read cycles of the second filter position shown in Figures 7(e) and 7(f), respectively, no group conflict occurs and the amount of data output from the input data buffer is N. B .

[0087] Due to the structure of the input data, it can be shown that N can be written effectively in one horizontal position B For fixed x and y , in p%N BThere is a one-to-one correspondence with (y*M*P + x*P + p)%N B Therefore, the BANKSEL value is different for each p%N B and there are no group conflicts.

[0088] Addressing Scheme - Second Implementation

[0089] The arrangement of the first embodiment is configured such that the input data will be read from the input data buffer in the order p->x->y. That is, the input data values at the position (0,0) from each plane are first read and passed to the convolution engine for processing. Then, the x coordinate is incremented, and all the input data values at (1,0) from each plane are read and passed to the convolution engine for processing. Once the row (x,0) is completed, the coordinate y is incremented, and the process is repeated for the row (x,1).

[0090] In some embodiments, it may be desirable to read a single plane value at each (x,y) coordinate position from an external memory into the input data buffer. In other embodiments, it may be desirable to read a subset of the plane values at each (x,y) coordinate position from the external memory into the input data buffer. By retrieving data from the external memory in this way, the data can be efficiently stored in the input data buffer to allow writing a subset of the plane into the input data buffer in a row. This method is effective in the context where the data is formatted in subsets of planes in the external memory. Thus, when the data is sorted in subsets of planes in the external memory, for example, by taking advantage of the burst of memory reads, the data can be efficiently retrieved from the external memory in that format. However, storing the data across the rows of the input data buffer in the order received may result in inefficient subsequent reads of the input data buffer.

[0091] In the second embodiment described herein, a modified addressing scheme is provided, which is configured to enable the input data values to be stored in the input data buffer in a subset of the planes of the input data. The second addressing scheme is applied according to the following equation, where NPU = the largest power of 2 that divides P, up to N B , For any value 0 ≤ x < NPU, Reverse(x) is defined as the result of reversing all Log2(NPU) binary digits of x.

[0092]

[0093] In Figure 8 , Fig. 9 and Fig.10 a first example of the second embodiment is listed, where P = 2, W = 8 and N B=8. Figure 8 , Fig. 9 and Fig.10 The difference from the figure of the first embodiment is that the shaded parts of the memory indicate input data values ​​loaded into the input data buffer during a single write cycle (in the first embodiment, they indicated input data values ​​read from the input data buffer during a single write cycle).

[0094] Figure 8 The input data dimensions for a first example of the second embodiment are shown. In this first example, data is read from external memory and written to the input data buffer a single plane at a time. Fig. 9 The input data values ​​for the first two rows to be written to the input data buffer are shown.

[0095] Figure 8 , Fig. 9 and Fig.10 The embodiment shown differs from the first embodiment in that an additional variable NPW is provided to the hardware during the reading of data from the external memory and the writing of data to the input data buffer. NPW represents the number of planes read from the external memory into the input data buffer at one time. In the following example, NPW is a power of 2 that is less than or equal to NPU, where NPU is the largest power of 2 divided by P, up to N B The maximum value of .

[0096] Fig.10 (a) and (b) show two different examples of writing data into the input data buffer. Fig.10 In (a), NPW=1, and therefore the input data values ​​are written to the input data buffer one plane at a time. Fig.10 The shaded memory locations in (a) show the input data values ​​that are written to the input data buffer during the first write cycle (as well as a visual representation of the locations of those data values ​​in the input data space). Fig.10 As can be seen from (a), data is written to the input data buffer without group conflict. Similarly, Fig.10 (b) shows an arrangement where NPW = 2. Again, Fig.10 The shaded memory locations in (b) show the input data values ​​written to the memory during the first write cycle. Fig.10 In the case of (b), no bank conflicts occur during writing of data to the input data buffer. The second implementation allows data to be read from memory at a single x,y position at a time (and across all planes). For example, from Fig.10As can be seen from (a) and (b), by reading row 0 of the input data buffer, input data values ​​at two planes of x,y coordinates (0,0), (1,0), (2,0) and (3,0) can be read from a row of the input data buffer.

[0097] exist Fig.11 , Fig.12 and Figure 13(a) to Figure 13(d) Another example of the second arrangement is shown in , where P=8. Fig.11 shows the data dimensions, Fig.12 shows the resulting input data values ​​to be stored in memory, Figure 13(a) to Figure 13(d) Many different methods for writing data to an input data buffer of NPW of different values ​​are shown. Figure 13(a) shows an arrangement in which data has been read from an external memory into an input data buffer of NPW=8. Therefore, during the first write cycle, all data planes are read for each location, so only the input data values ​​of p=0 are read from the external memory and loaded into the input data buffer, i.e., values ​​(0,0,0) to (7,0,0). The shaded locations in Figure 13(a) show the input data values ​​written to the input data buffer in the first write cycle. It can be seen from Figure 13(a) that during the first write cycle, eight different values ​​are written to the input data buffer without group conflicts occurring during the first write cycle.

[0098] FIG. 13( b) shows an alternative arrangement in which data has been read from memory into an input data buffer with NPW=4. In this arrangement, the first four planes from each (x, y) coordinate are read in sequence. Therefore, for each x, y coordinate, the coordinates (x, y, 0), (x, y, 1), (x, y, 2) and (x, y, 3) are written first. In other words, the first four plane indexes of each (x, y) position are written first. As can be seen from FIG. 13( b), during a single write cycle (each input data value written is shaded), eight values ​​are written to the input buffer without group conflicts. FIG. 13( c) shows another arrangement in which NPW=2, and FIG. 13( d) shows another arrangement in which NPW=1. In the arrangement of FIG. 13( c), two input data values ​​from consecutive x, y coordinates, i.e., the first two plane indexes, are written in a single write cycle. In the arrangement of FIG. 13( d), a single input data value, i.e., the first plane index, is read at consecutive x, y coordinates in the input data buffer. As can be seen from Figures 13(c) and 13(d), the number of MEMADDR locations to which input data values ​​are written in a single write cycle increases as NPW decreases. Figure 13(a) to Figure 13(d) From all the examples, it can be seen that although the input data is received in a different order from the first embodiment, group conflicts are avoided.

[0099] In these arrangements, it can be seen that the addressing scheme of the second implementation stores the input data in the input data buffer in a manner that avoids conflicts, regardless of the different possible schemes (based on the value of NPW) for writing the data into the input data buffer. In these arrangements, NPW can be a power of 2 that is greater than or equal to NPU, where NPU is the largest power of 2 divided by P, up to N B The maximum value of .

[0100] Addressing Scheme - Third Implementation

[0101] The first and second embodiments described above have particular application in the layers of CNNs where the vertical stride t is set to 1. In some embodiments, such as in certain layers, the vertical stride t may be greater than 1. When t=1, the filter is applied along a particular row of input data, and the vertical position of the filter is incremented by 1, resulting in n-1 rows of filter overlap. The filter is then passed along the row input data before the vertical position of the filter is incremented by 1 again. Conversely, when t>1, the vertical position of the filter is incremented by t, and the filter overlap is nt.

[0102] exist Figure 14 to Figure 16(l) An example of a filter traversing input data with a horizontal stride of 2 is shown in FIG. Fig.14 In (a) and (b), the first pass along the input data line is performed by the filter. Fig.14 In (c), the filter has completed a pass along the input data row, and the filter returns to the beginning of the row to perform a subsequent pass. However, unlike the previously described arrangement, the filter is not incremented in vertical position by 1. Instead, the filter's vertical position is incremented by 2. Fig.14 In (d), the second pass of the filter is complete. It can be thought that this change in the vertical stride can change the number of rows that are effectively "consumed" during the pass along the input data row. For example, in Figure 6 After the first pass in the arrangement is complete, subsequent passes no longer need the first row of data. This can be done in Figure 6 As can be seen in (c) and (d), the first row of input data is not used. Therefore, the first row of data is considered "consumed" and can be replaced by other input data for later use. In contrast, Fig.14 After the first pass of the filter in , two rows are "consumed". This can be seen in Fig.14 As can be seen in (c) and (d), the first two lines are no longer used and can therefore be replaced.

[0103] A third implementation of the addressing scheme modifies the addressing scheme to account for filter strides greater than 1. The third implementation implements the addressing scheme according to the following equation:

[0104]

[0105] BANKSEL(x,y,p)=(x*p+p+y*m*P)%N B

[0106] Where t represents the vertical stride of the filter and y0 represents the vertical position of the first row of the filter to be processed, where the first row of the filter is not the first row of input data. Therefore, y0 represents an offset in the position of the filter based on the stride to be applied. As can be seen from the above equation, the calculation of the BANKSEL value for each input data value is the same as the corresponding BANKSEL calculation of the first embodiment described above. The difference in the MEMADDR calculation between the first and third embodiments is that the MEMADDR calculation can be divided into two different calculations. The first calculation determines the MEMADDR unwr A value that is an unwrapped version of the MEMADDR value that is not wrapped to MEMSIZE using the modulus calculation. The MEMADDR calculation is performed using the modified x, y, and p coordinates for the particular input data value. In particular, the y coordinate is modified based on the y0 offset value.

[0107] The result of using this method to store input data values ​​in an input data buffer is that, when compared to the first implementation, the MEMADDR rows in the input data buffer storing data using this method are interleaved relative to the first implementation. This addressing scheme has particular application where the size of the input buffer is only large enough to process the input data for a particular layer of the CNN. In some cases, for efficient processing, the input buffer may need to hold at least n+t-1 rows of data. This is because in the previously described implementation, when processing a row of the input data space, only a single row of data is "consumed" (i.e., a single row of data is no longer needed and can be overwritten). If the input data buffer holds n rows of data, then for t>1, if a row of data is completed, the buffer must wait for t-1 rows of data to be fetched from memory before continuing processing, which may result in a gap in processing.

[0108] The input data buffer is designed to receive and generate data streams, and due to the MEMADDR calculation involving %MEMSIZE, the MEMADDR locations wrap around the input data buffer memory. In practice, the range of "unwrapped" addresses held in the input data buffer can be artificially limited to MEMSIZE so that new data input into the input data buffer does not overwrite data still to be processed in the filter window.

[0109] The extreme case is where t=n (where n>1). In this case, the MEMADDR requires addresses that span a row, but the adjusted MEMADDR calculation of the third embodiment maintains all relevant data for the output locations in consecutive addresses. Therefore, the input data buffer can handle arbitrarily large image widths, thereby maintaining a limited address range.

[0110] Fig.15 An example of a third implementation of the addressing scheme is listed in FIG. 16( l ). Fig.15 The arrangement corresponds to Figure 5 Specifically, Figure 5 and 15 In the two arrangements, P = 5, m = 2, X = 3 and N B The difference in the arrangement is that in Figure 5 In, t = 1, Fig.15 , t=2 and y0=0. Fig.15 1 shows the contents of the first eight MEMADDR rows of the input data buffer after the received input data has been stored in the input data buffer according to the addressing scheme of the third arrangement. It can be seen that the input data value rows are relative to Figure 5 Specifically, when comparing the data values ​​stored according to the first and third embodiments, the input data values ​​at MEMADDR=1 and MEMADDR=2 effectively swap positions, with input data values ​​at MEMADDR=5 and MEMADDR=6.

[0111] Figure 16(a) to Figure 16(l) The number of read cycles according to the third embodiment is shown for t=2. As can be seen from these figures, every read cycle input data value is read from the input data buffer and no bank conflicts occur.

[0112] In some arrangements, the addressing scheme for the second embodiment may be combined with the addressing scheme for the third implementation to perform addressing where a subset of planes are selected and where the vertical stride t > 1. In this way, MEMADDR calculations may be performed according to the third embodiment and BANKSEL calculations may be performed according to the second embodiment.

[0113] Addressing Scheme - Fourth Implementation

[0114] In some arrangements, it may be desirable to retrieve data from the input data buffer in a different order. This is particularly applicable to certain layers of the CNN, such as normalization and pooling layers. The previous embodiments may be used for embodiments in which data is read from the input data buffer 200 in an order referred to below as p->x->y order, because the data is read in an order in which the p coordinate is first incremented for a particular (x, y) position, until all appropriate values ​​are read. Then, for each incremented x position, the x coordinate is incremented, and the appropriate p values ​​are read continuously until the entire row is read. Finally, the y coordinate is incremented and the next row is read.

[0115] In another embodiment, the input data may be read from the input data buffer in a different order referred to herein as a "flat column major" read format. This reading method may be considered to be a p->y->x order. After all the associated p values ​​for a particular (x,y) position are read, the y coordinate is incremented instead, and the process repeats until all the associated p values ​​for all y positions for a particular column are read. The x coordinate is then incremented to the next column, and the process repeats from the top of the following columns. Thus, where the previous method referred to reading data in a rasterized format, the method used in this embodiment switches the x and y coordinates to read the data in a column-by-column manner. An example of a data reading order is as follows: Fig.17 shown.

[0116] In this arrangement, a fourth implementation of the addressing scheme may be used. In this fourth implementation, an algorithm may be applied to assign memory locations within the input data buffer to input data values. The following pseudo code may be used to define the algorithm:

[0117] if(N2<=N B )

[0118] {

[0119] N'=inverse of(N / N2)modulo(N B / N2)

[0120] Hash(x,y;N)=(x+N'*(y / N2))%(N B / N2)+((x / N2+y)%N2)*(N B / N2)

[0121] }

[0122] else

[0123] {

[0124] Hash(y,N)=y

[0125] }

[0126] if(P2<=N B )

[0127] {

[0128] P'=inverse of(P / P2)modulo(N B / P2)

[0129] Hash(0,p;P)=(P'*(p / N2))%(N B / P2)+(p%N2)*(N B / P2)

[0130] }

[0131] else

[0132] {

[0133] Hash(0,p;P)=p

[0134] }

[0135] MEMSEL(x,y,p)=Hash(x+Hash(0,p;P),y,N)%NB

[0136] MEMADDR(x,y,p)=((WordsPerLine*y+P*x+p) / N B )%MEMSIZE

[0137] Where N2 is calculated as N B and the minimum of the maximum power of 2 over N, where N defines the height of the filter applied to the input data, and where P2 is calculated as N B and the minimum of the largest powers of 2 over P. N' is calculated as N / N2 modulo N B / N2 is the inverse function. For example, the inverse function of 3 modulo 16 is 11, because (3*11) modulo 16 is 1.

[0138] Figures 18 to 20(i) An example of the fourth embodiment defined above is listed in B =4, P=1, X=5, s=t=1, and m=n=3. Fig.18 Six different window positions for the filter during the processing of a layer in the fourth embodiment are shown. In contrast to the previously described arrangement, the data is retrieved in a different order. For example, in Fig.18 In (a), the filter is located at the upper left corner of the data space. Then, the filter is passed down the column until the data in that column is read, as shown in Fig.18 Then, as Fig.18 As shown in (d), the filter position increases horizontally according to the horizontal step s. Fig.19 1 shows the location in the input data buffer where data values ​​are stored using the addressing scheme of the fourth embodiment described above. Fig.19 As shown, four groups of memory are provided, each group being represented by a column where the leftmost column is group 0 and the rightmost column is group 3. The MEMADDR value is Fig.19 Portions of the memory in which no data values ​​are stored (ie, padding locations) are referenced by the term "PAD".

[0139] Figure 20(a) to Figure 20(i) Each shows a separate read cycle for reading data which together allows Fig.18 Figure 20(a) shows the window positions from (a) to (c) of the image processing unit. Fig.18 (a) The window position of the required part of the data is read in the first read cycle. Figure 20(b) shows the read Fig.18 (a) is a second read cycle for the second portion of the data required. In FIG. 20(c), the Fig.18 The last part of the data required by (a) is executed. Fig.18 The filter position shown in (b) (see Figures 20 (d) to (f) and Fig.18 The filter position shown in (c) (see Figure 20(g) to Figure 20(i) ) (in this example three for each filter position in the data space).

[0140] from Figures 18 to 20(i) As can be seen from the fourth embodiment, data is read in column-by-column order. In this arrangement, data is located across memory banks in a manner that is aware of the data and filter formats. Therefore, data can be read from banks without (or otherwise minimized) bank conflicts. In this way, data throughput from the input data buffer to the convolution engine is fast and consistent. It should be understood that the degree of filling (and therefore the efficiency of using the capacity of the input data buffer) depends on the specific dimensions of the input data buffer and the filter. Some formats may use less filling than other formats.

[0141] cursor

[0142] The implementation of the above arrangement can be simplified by eliminating some of the arithmetic required. Specifically, arithmetic can be eliminated from the implementation of addition and subtraction of variables derived from layer parameters (i.e., filter and data format information). In some arrangements, format values can be passed from an external source to the hardware accelerator (e.g., via a driver that provides the values). For example, (s*P) and (t*WordsPerLine) can be provided as pre-computed values (along with or instead of specific format parameters). In some arrangements, these values can be computed by the hardware accelerator, as calculations such as multiplication can be performed relatively efficiently.

[0143] Arithmetic can be eliminated by retaining "cursor" values to significant positions, such as:

[0144] The (0,0,0) filter value at the start of the current output row and column;

[0145] The (0,y,0) filter value at the start of the current output row and column;

[0146] The (x,y,0) filter value at the start of the current output row and column; and

[0147] The (x,y,p) filter value at the start of the current output row and column.

[0148] Where x < X, y < Y and p < P. When one of these cursor values needs to be updated, it can be derived by a small change to itself or a previous cursor value. In one implementation, the cursor can be considered as a binary array of the following form:

[0149] Cursor(x,y,p) = (RasterAddr(x,y,p),RAMSEL(x,y,p)

[0150] Where

[0151] RasterAddr(x,y,p) = (x*P + p + y*WordsPerLine) % (RAMSIZE*N B )

[0152] Such that For any layer parameters Δx, Δy and Δp (e.g., where Δx is the change in x, Δt = 0 and Δp = 0). In some layouts, the value of Cursor(x+Δx,y+Δy,p+Δp) can be computed efficiently by the following pseudocode for the first implementation described previously:

[0153] RasterAddr’ = RasterAddr(x,y,p) + Δx*P + Δp + Δy*WordsPerLine

[0154] if RasterAddr' <MEMSIZE*N B

[0155] RasterAddr(x+Δx,y+Δy,p+Δp)=RasterAddr'

[0156] else

[0157] RasterAddr(x+Δx,y+Δy,p+Δp)=RasterAddr'–MEMSIZE*N B

[0158] endif

[0159] RAMSEL(x+Δx,y+Δy,p+Δp)=(RAMSEL(x,y,p)+Δy*M*P+Δx*P+Δp)%N B .

[0160] Similar cursor calculations may be performed for other implementations.

[0161] The addressing scheme described herein is used for an input data buffer configured for use in a hardware implementation of a CNN. The input data buffer is configured to retain or hold the input data, for example, in a volatile memory. In this way, the input data buffer 200 differs from the memory 600 in that it can be inside the CNN hardware implementation and can temporarily store input data values ​​of values ​​to be provided to the convolution engine. The input data buffer reduces the need to read data multiple times from a memory (e.g., an external memory). In this way, the improved input data buffer addressing scheme also improves the memory bandwidth of the system.

[0162] In some arrangements, the hardware logic (e.g., a hardware accelerator) may be configured to implement a CNN. In some arrangements, the hardware logic may be configured to implement any CNN. For example, the hardware logic may be configured to receive data defining the format of the filter of the CNN to be implemented and the data to be processed at each layer so as to process the input data according to the filter. In the hardware logic configured to implement the CNN, the data output from the convolution engine 310 may be passed (directly or indirectly) to the input data buffer or memory 600. In this way, the data output from the convolution engine in the first layer may be passed back (looped) through the convolution engine 310 and processed in the second layer. As previously described, the data output from the first layer may form the input data to the subsequent layers, and the dimensions of the input data and the filter of the first layer may be different from the dimensions of the next second layer.

[0163] Therefore, the input data buffer 200 may be provided with a control flow including control flow data for each layer to be processed. When configuring the hardware accelerator or before processing the input data in the CNN, the control flow data may be received from an external data source. The control flow data may include data indicating at least one format parameter of the input data. Additionally or alternatively, the control data stream may include data indicating at least one format parameter of the filter data. For example, each format parameter may indicate one or more dimensions of the input data or filter data for processing the layer. For example, the format parameter may indicate one or more of the filter width m, filter height n, data width X, data height Y, number of planes P, number of filters F, vertical filter stride t and / or horizontal filter stride s. The control flow may include at least one format parameter for each layer. In some arrangements, at least one format parameter may be different between multiple layers, and therefore should be determined by the controller before the layer is processed.

[0164] In some embodiments, other mechanisms may be used to provide format parameters rather than receiving data as part of the control flow. For example, the format parameters may be stored in memory and retrieved when the layer is processed.

[0165] In some arrangements, the grouped memory of the input data buffer 200 may be a volatile memory configured to enable data to be retrieved in a single read cycle per memory group. For example, in some arrangements, the grouped memory may take the form of a grouped RAM memory. In other arrangements, the input data buffer may be formed of other types of volatile memory. As described below, the input data may be formed of a grouped non-volatile memory.

[0166] The addressing scheme provided herein is applicable to the input data buffer addressing scheme in the CNN hardware accelerator. Due to the geometry of the input data space and the geometry of the filter and the sequence of two sets of value convolutions, the examples listed in this application have special applications in CNN. Since the addressing scheme can utilize data related to the dimensions of the input data and / or filter data, the addressing scheme can improve throughput. For CNN, a known set of parameters is used to define the dimensions of the input data and filter data. In this way, the relative geometry and shape of the input data and the filter data and the way in which the two are applied to each other enable the implementation of an addressing scheme that provides high throughput. Those skilled in the art will appreciate that the concepts set forth herein can be applied to other technical fields, wherein there is a geometric relationship between the data and the order in which it should be retrieved from the buffer.

[0167] For example, in other applications, the addressing scheme may take into account one or more dimensions of the data to be stored in the buffer and / or information about the dimensions of other data to which the stored data is to be applied. For example, the addressing scheme may also be applicable to data sharding for a geographic information system utilizing grouped non-volatile memory.

[0168] In some embodiments, the hardware logic 100 (e.g., a hardware accelerator) may include control logic or a control module (not shown) configured to manage the addressing scheme used by the input data buffer 200. For example, the control logic may be configured to receive at least one format parameter for the input data and at least one format parameter for the filter data of the layer being processed, and perform addressing calculations based on the format parameters. The control logic may also be configured to control the input data buffer 200 to place the input data into the input data buffer according to the calculated address location. The control logic may also be configured to receive subsequent format data for at least one of the input and filter data, and use the format data in a subsequent layer to process the subsequent layer.

[0169] Fig. 22 A computer system is shown in which the convolutional neural network hardware accelerator described herein can be implemented. The computer system includes a CPU 902, a GPU 904, a memory 906, and other devices 914, such as a display 916, a speaker 918, and a camera 106. A processing block 910 is implemented on the GPU 904. In other examples, the processing block 910 can be implemented on the CPU 902. The components of the computer system can communicate with each other via a communication bus 920. A storage repository 912 is implemented as part of the memory 906.

[0170] Fig. 22 The convolutional neural network hardware accelerator is shown as including multiple functional blocks. This is only a schematic diagram and is not intended to define a strict division between the different logical elements of these entities. Each functional block can be provided in any suitable manner. It should be understood that the intermediate values ​​described herein as being formed by the convolutional neural network do not need to be physically generated by the convolutional neural network at any point, and may only represent logical values ​​that conveniently describe the processing performed by the convolutional neural network between its input and output.

[0171] The convolutional neural network hardware accelerator described herein can be implemented in hardware on an integrated circuit. The convolutional neural network hardware accelerator described herein can be configured to perform any of the methods described herein. Generally, any of the above functions, methods, techniques, or components can be implemented in software, firmware, hardware (e.g., fixed logic circuits), or any combination thereof. The terms "module," "function," "component," "element," "unit," "block," and "logic" may be used herein to represent software, firmware, hardware, or any combination thereof. In the case of a software implementation, a module, function, component, element, unit, block, or logic represents a program code that performs a specified task when executed on a processor. The algorithms and methods described herein can be executed by one or more processors executing a code that causes the processor to execute the algorithm / method. Examples of computer-readable storage media include random access memory (RAM), read-only memory (ROM), optical disks, flash memory, hard disk storage, and other storage devices that can use magnetic, optical, and other technologies to store instructions or other data and can be accessed by a machine.

[0172] The terms computer program code and computer readable instructions as used herein refer to any type of executable code for a processor, including code expressed in machine language, interpreted language, or scripting language. Executable code includes binary code, machine code, bytecode, code defining an integrated circuit (such as a hardware description language or netlist), and code expressed in programming language code such as C, Java, or OpenCL. Executable code can be, for example, any type of software, firmware, script, module, or library that, when properly executed, processed, interpreted, compiled, executed in a virtual machine or other software environment, causes a processor of a computer system supporting the executable code to perform the tasks specified by the code.

[0173] A processor, computer or computer system may be any kind of device, machine or special circuit or a collection or part thereof having processing capabilities so that it can execute instructions. A processor may be any type of general or special processor, such as a CPU, GPU, system on a chip, state machine, media processor, application specific integrated circuit (ASIC), programmable logic array, programmable gate array (FPGA), etc. A computer or computer system may include one or more processors.

[0174] It is also intended to include software that defines the configuration of hardware as described herein, such as HDL (Hardware Description Language) software for designing integrated circuits or for configuring programmable chips to perform desired functions. That is, a computer-readable storage medium having computer-readable program code in the form of an integrated circuit defining data set encoded thereon may be provided, which data set, when processed in an integrated circuit manufacturing system, configures the system to manufacture a convolutional neural network hardware accelerator configured to perform any of the methods described herein, or to manufacture a convolutional neural network hardware accelerator that includes any of the devices described herein. The integrated circuit defining data set may be, for example, an integrated circuit description.

[0175] Thus, a method of manufacturing a convolutional neural network hardware accelerator as described herein at an integrated circuit manufacturing system may be provided. In addition, an integrated circuit defining data set may be provided, which, when processed in an integrated circuit manufacturing system, causes the method of manufacturing a convolutional neural network hardware accelerator to be implemented.

[0176] The integrated circuit definition data set may be in the form of computer code, for example, as a netlist, code for configuring a programmable chip, as a hardware description language that defines any level of integrated circuit, including as register transfer level (RTL) code, as a high-level circuit representation such as Verilog or VHDL, and as a low-level circuit representation such as OASIS (RTM) and GDSII. A higher-level representation that logically defines an integrated circuit (such as RTL) may be processed at a computer system configured to generate a manufacturing definition of the integrated circuit in the context of a software environment that includes definitions of circuit elements and rules for combining these elements to generate a manufacturing definition of the integrated circuit defined by the representation. Typically, as with software executed at a computer system to define a machine, one or more intermediate user steps (e.g., providing commands, variables, etc.) may be required in order for a computer system configured to generate a manufacturing definition of an integrated circuit to execute code that defines the integrated circuit in order to generate a manufacturing definition of the integrated circuit.

[0177] Now refer to Fig.23 An example of processing an integrated circuit defining dataset at an integrated circuit manufacturing system to configure the system to manufacture a convolutional neural network hardware accelerator is described.

[0178] Fig.23An example of an integrated circuit (IC) manufacturing system 1002 is shown that includes a layout processing system 1004 and an integrated circuit generation system 1006. The IC manufacturing system 1002 is configured to receive an IC-defining data set (e.g., defining a convolutional neural network hardware accelerator as described in any example herein), process the IC-defining data set, and generate an IC (e.g., which implements a convolutional neural network hardware accelerator as described in any example herein) based on the IC-defining data set. The processing of the IC-defining data set configures the IC manufacturing system 1002 to manufacture an integrated circuit that implements a convolutional neural network hardware accelerator as described in any example herein.

[0179] The layout processing system 1004 is configured to receive and process an IC definition data set to determine a circuit layout. Methods for determining a circuit layout from an IC definition data set are known in the art and may, for example, involve synthesizing RTL code to determine a gate-level representation of a circuit to be generated, for example, in terms of logic components (e.g., NAND, NOR, AND, OR, MUX, and FLIP-FLOP components). The circuit layout may be determined from the gate-level representation of the circuit by determining location information for the logic components. This may be done automatically or in conjunction with the user to optimize the circuit layout. When the layout processing system 1004 has determined the circuit layout, it may output the circuit layout definition to the IC generation system 1006. The circuit layout definition may be, for example, a circuit layout description.

[0180] As is known in the art, IC generation system 1006 generates ICs according to circuit layout definitions. For example, IC generation system 1006 may implement a semiconductor device manufacturing process for generating ICs, which may involve a multi-step sequence of photolithography and chemical processing steps during which electronic circuits are gradually formed on a wafer made of semiconductor material. The circuit layout definition may be in the form of a mask that may be used in a photolithography process to generate ICs according to the circuit definition. Alternatively, the circuit layout definition provided to IC generation system 1006 may be in the form of a computer-readable code that IC generation system 1006 may use to form a suitable mask for use in generating the IC.

[0181] The different processes performed by IC manufacturing system 1002 may all be performed at one location (e.g., by one party). Alternatively, IC manufacturing system 1002 may be a distributed system such that certain processes may be performed at different locations and by different parties. For example, some of the following stages may be performed at different locations and / or by different parties: (i) synthesizing RTL code representing an IC-defining data set to form a gate-level representation of a circuit to be generated, (ii) generating a circuit layout based on the gate-level representation, (iii) forming a mask based on the circuit layout, and (iv) manufacturing the integrated circuit using the mask.

[0182] In other examples, processing of an integrated circuit definition data set at an integrated circuit manufacturing system may configure the system to manufacture a convolutional neural network hardware accelerator without processing the IC definition data set to determine a circuit layout. For example, the integrated circuit definition data set may define a configuration of a reconfigurable processor such as an FPGA, and processing of the data set may configure the IC manufacturing system to generate a reconfigurable processor having the defined configuration (e.g., by loading the configuration data into the FPGA).

[0183] In some embodiments, when processed in an integrated circuit manufacturing system, the integrated circuit manufacturing definition data set may cause the integrated circuit manufacturing system to generate an apparatus as described herein. Fig.23 Configuration of an integrated circuit manufacturing system in the manner described may result in the devices as described herein being manufactured.

[0184] In some examples, the integrated circuit defining the data set may include software running on or in combination with hardware defined at the data set. Fig.23 In the example shown, the IC generation system may also be configured by the integrated circuit definition dataset to load firmware onto the integrated circuit or provide program code to the integrated circuit for use with the integrated circuit when manufacturing the integrated circuit according to the program code defined at the integrated circuit definition dataset.

[0185] Applicants hereby disclose each individual feature described herein and any combination of two or more such features, as long as such feature or combination can be performed according to the common general knowledge of those skilled in the art according to this specification as a whole, regardless of whether such feature or combination of features solves any problem disclosed herein. In view of the above description, it will be apparent to those skilled in the art that various modifications can be made within the scope of the invention.

Claims

1. A method of storing the input data of a convolutional neural network layer in a B A method for processing in a buffer of groups, each group comprising a plurality of words, the method comprising: receiving input data, the input data comprising input data values ​​to be processed in a layer of the convolutional neural network, the input data comprising P planes, each plane having X columns and Y rows; identifying a value WordsPerLine indicating the number of words of each group required to store one line of the input data; determining an address in the buffer where each of the input data values ​​will be stored based on the WordsPerLine and a filter width m or a filter height N of a filter to be applied to the input data; as well as The received input data value is stored at the determined address in the buffer for retrieval for processing in the layer.

2. The method according to claim 1, wherein: The WordsPerLine is equal to:

3. The method according to claim 1 or claim 2, wherein: The WordsPerLine is provided explicitly.

4. A method according to any preceding claim, wherein: Each input data value has a position in the input data defined by x, y and p coordinates reflecting the column, row and plane of the input data value respectively, and the address in the buffer where the input data value is to be stored is further based on the x, y and p coordinates of the input data value.

5. The method according to claim 4, wherein: Each address in the buffer is defined by a first value BANKSEL indicating a bank of the buffer and a second value MEMADDR indicating a memory location within the bank, and the MEMADDR of the address in the buffer where the input data value is to be stored is determined by the following equation: where MEMSIZE is the number of addresses in each group.

6. The method according to claim 4, wherein: Each address in the buffer is defined by a first value BANKSEL indicating a bank of the buffer and a second value MEMADDR indicating a memory location within the bank, and the MEMADDR of the address in the buffer where the input data value is to be stored is determined by the following equation: in, MEMSIZE is the number of addresses in each group, t is the vertical stride of the filter, and y0 is the vertical position of the first row of the filter.

7. The method according to claim 5 or claim 6, wherein: The BANKSEL of the address in the buffer storing the input data value is determined by the following equation: (x*P+p+y*m*P)%N B 。 8. The method according to claim 5 or claim 6, wherein: The BANKSEL of the address in the buffer storing the input data value is determined by the following equation: Where NPU is the maximum power of 2 divided by P, up to N B The maximum value of And Reverse(x) is the result of reversing all the Log2(NPU) binary digits of x.

9. The method according to claim 7 or claim 8, wherein: The method also includes reading the input data values ​​from the buffer in plane, column, row order, and passing the read input data values ​​to a convolution engine for processing.

10. The method according to claim 5, wherein: The BANKSEL of the address in the buffer storing the input data value is determined by the following equation: Hash(x+Hash(0,p;P),y;N)%N B , Among them, if N2≤N B ,but mold is the inverse function of Otherwise hash(x,y;N)=y; Among them, if P2≤N B ,but mold is the inverse function of Otherwise hash(0,p;P)=p; Where N2 is N B The minimum value of and the maximum power of 2 divided by N; Where P2 is N B The minimum value of and the maximum power of 2 divided by P.

11. The method according to claim 10, wherein: The method also includes reading the input data values ​​from the buffer in plane, row, column order, and passing the read input data values ​​to a convolution engine for processing.

12. The method according to any preceding claim, further comprising: receiving second input data, the second input data comprising a second input data value to be processed in a subsequent layer of the convolutional neural network, wherein the second input data is different from the input data; determining an address in the buffer where each of the second input data values ​​is to be stored; and The second input data value is stored at the determined address in the buffer for retrieval for processing in the subsequent layer.

13. A hardware logic for implementing a convolutional neural network, the hardware logic being configured to: receiving input data, the input data comprising input data values ​​to be processed in a layer of the convolutional neural network, the input data comprising P planes, each plane having X columns and Y rows; identifying a value WordsPerLine indicating the number of words of each group required to store one line of the input data; determining an address in the buffer where each of the input data values ​​will be stored based on the WordsPerLine and a filter width m or a filter height N of a filter to be applied to the input data; and The received input data value is stored at the determined address in the buffer for retrieval for processing in the layer.

14. A computer-readable storage medium having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by a computer system, the computer system is caused to perform the method according to any one of claims 1 to 12.

15. A computer readable storage medium having stored thereon a computer readable description of an integrated circuit, the computer readable description, when processed in an integrated circuit manufacturing system, causing the integrated circuit manufacturing system to manufacture the hardware logic of claim 13.

16. A method of storing the input data of a layer of a convolutional neural network in a B A method for processing in a buffer of groups, each group comprising a plurality of words, the method comprising: receiving input data, the input data comprising input data values ​​to be processed in a layer of the convolutional neural network, the input data comprising P planes, each plane having X columns and Y rows, each input data value having a position in the input data defined by x, y, and p coordinates reflecting the column, row, and plane of the input data value, respectively; Identify the value WordsPerLine, where WordsPerLine is equal to: determining an address in the buffer where each of the input data values ​​will be stored based on the WordsPerLine, the x, y, and p coordinates of the input data values, and a filter width m or a filter height N of a filter to be applied to the input data, wherein each address in the buffer is defined by a first value BANKSEL indicating a bank of the buffer and a second value MEMADDR indicating a memory location within the bank; storing the received input data value at the determined address in the buffer; and Reading the input data values ​​from the buffer in plane, column, row order, and passing the read input data values ​​to a convolution engine for processing; Wherein, the MEMADDR of the address in the buffer where the input data value will be stored is determined by the following equation: Where MEMSIZE is the number of addresses in each group; Wherein, the BANKSEL of the address storing the input data value in the buffer is determined by the following equation: (x*P+p+y*m*P)%N B , Or determined by the following equation: Where NPU is the maximum power of 2 divided by P, up to N B The maximum value of And Reverse(x) is the result of reversing all the Log2(NPU) binary digits of x.

17. A method of storing the input data of a layer of a convolutional neural network in a B A method for processing in a buffer of groups, each group comprising a plurality of words, the method comprising: receiving input data, the input data comprising input data values ​​to be processed in a layer of the convolutional neural network, the input data comprising P planes, each plane having X columns and Y rows, each input data value having a position in the input data defined by x, y, and p coordinates reflecting the column, row, and plane of the input data value, respectively; Identify the value WordsPerLine, where WordsPerLine is equal to: determining an address in the buffer where each of the input data values ​​will be stored based on the WordsPerLine, the x, y, and p coordinates of the input data values, and a filter width m or a filter height N of a filter to be applied to the input data, wherein each address in the buffer is defined by a first value BANKSEL indicating a bank of the buffer and a second value MEMADDR indicating a memory location within the bank; storing the received input data value at the determined address in the buffer; and Reading the input data values ​​from the buffer in plane, column, row order, and passing the read input data values ​​to a convolution engine for processing; Wherein, the MEMADDR of the address in the buffer where the input data value will be stored is determined by the following equation: in, MEMSIZE is the number of addresses in each group, t is the vertical stride of the filter, and y0 is the vertical position of the first row of the filter; Wherein, the BANKSEL of the address storing the input data value in the buffer is determined by the following equation: (x*P+p+y*m*P)%N B , Or determined by the following equation: Where NPU is the maximum power of 2 divided by P, up to N B The maximum value of And Reverse(x) is the result of reversing all the Log2(NPU) binary digits of x.

18. A method of storing the input data of a layer of a convolutional neural network in a B A method for processing in a buffer of groups, each group comprising a plurality of words, the method comprising: receiving input data, the input data comprising input data values ​​to be processed in a layer of the convolutional neural network, the input data comprising P planes, each plane having X columns and Y rows, each input data value having a position in the input data defined by x, y, and p coordinates reflecting the column, row, and plane of the input data value, respectively; Identify the value WordsPerLine, where WordsPerLine is equal to: determining an address in the buffer where each of the input data values ​​will be stored based on the WordsPerLine, the x, y, and p coordinates of the input data values, and a filter width m or a filter height N of a filter to be applied to the input data, wherein each address in the buffer is defined by a first value BANKSEL indicating a bank of the buffer and a second value MEMADDR indicating a memory location within the bank; storing the received input data value at the determined address in the buffer; and Reading the input data values ​​from the buffer in plane, column, row order, and passing the read input data values ​​to a convolution engine for processing; Wherein, the MEMADDR of the address in the buffer where the input data value will be stored is determined by the following equation: Where MEMSIZE is the number of addresses in each group; Wherein, the BANKSEL of the address storing the input data value in the buffer is determined by the following equation: Hash(x+Hash(0,p;P),y;N)%N B , Among them, if N2≤N B ,but mold is the inverse function of Otherwise hash(x,y;N)=y; Among them, if P2≤N B ,but mold is the inverse function of Otherwise hash(0,p;P)=p; Where N2 is N B The minimum value of and the maximum power of 2 divided by N; Where P2 is N B The minimum value of and the maximum power of 2 divided by P.

19. The method of claim 16, claim 17 or claim 18, wherein: The WordsPerLine is provided explicitly.

20. The method of claim 16 or claim 17, wherein: The BANKSEL of the address in the buffer storing the input data value is determined by the following equation: (x*P+p+y*n*P)(N B 。 21. The method of claim 16 or claim 17, wherein: The BANKSEL of the address in the buffer storing the input data value is determined by the following equation:

22. The method of claim 16, claim 17 or claim 18, further comprising: receiving second input data, the second input data comprising a second input data value to be processed in a subsequent layer of the convolutional neural network, wherein the second input data is different from the input data; determining an address in the buffer where each of the second input data values ​​will be stored; and The second input data value is stored at the determined address in the buffer for retrieval for processing in the subsequent layer.

23. The method of claim 16, claim 17 or claim 18, further comprising: The input data is received from an external memory.

24. An integrated circuit for implementing a convolutional neural network, the integrated circuit being configured to perform the method of claim 16, claim 17 or claim 18.

25. A computer readable storage medium having stored thereon a computer readable description of an integrated circuit according to claim 24, said computer readable description, when processed in an integrated circuit manufacturing system, causing said integrated circuit manufacturing system to manufacture said integrated circuit.