WO2024048868A1 - Computation method in neural network and device therefor - Google Patents

Computation method in neural network and device therefor Download PDF

Info

Publication number
WO2024048868A1
WO2024048868A1 PCT/KR2022/021128 KR2022021128W WO2024048868A1 WO 2024048868 A1 WO2024048868 A1 WO 2024048868A1 KR 2022021128 W KR2022021128 W KR 2022021128W WO 2024048868 A1 WO2024048868 A1 WO 2024048868A1
Authority
WO
WIPO (PCT)
Prior art keywords
variable
value
array
instruction
predetermined
Prior art date
Application number
PCT/KR2022/021128
Other languages
French (fr)
Korean (ko)
Inventor
정태영
Original Assignee
오픈엣지테크놀로지 주식회사
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 오픈엣지테크놀로지 주식회사 filed Critical 오픈엣지테크놀로지 주식회사
Publication of WO2024048868A1 publication Critical patent/WO2024048868A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/15Correlation function computation including computation of convolution operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/15Correlation function computation including computation of convolution operations
    • G06F17/153Multidimensional correlation or convolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means

Definitions

  • the present invention relates to a method of performing calculations in a computing device to implement a neural network and a hardware accelerator to which this method is applied.
  • FIG. 1 shows the computational structure of CNN according to one embodiment. Hereinafter, the description will be made with reference to FIG. 1.
  • convolution layers 52 can be created by performing a convolution operation using a plurality of kernels on the input image data 51 stored in the internal memory.
  • the step of generating the convolution layers 52 may include performing a non-linear operation (e.g., ReLU, Sigmoid, or tanH) on a plurality of feature maps obtained as a result of performing the convolution operation.
  • a non-linear operation e.g., ReLU, Sigmoid, or tanH
  • pooling layers 53 can be created by performing pooling on the convolutional layers 52.
  • Each convolutional layer 52 may include data that can be expressed in the form of an M*N matrix.
  • a pooling window which is a window with a smaller dimension than the convolution layer 52, may be defined.
  • the pooling window may have sizes of Mp and Np in the row and column directions, respectively.
  • the pooling is an operation that generates a smaller number of data, for example, 1 data, from Mp*Np data selected by overlapping the pooling window on the convolution layer.
  • MAX pooling is an operation that selects and outputs the largest value among the Mp*Np pieces of data.
  • average pooling is an operation that outputs the average value of the Mp*Np pieces of data. Pooling that follows other rules may be defined. The number of cases in which the pooling window can be overlapped with the convolution layer varies. Depending on the embodiment, rules for moving the pooling window on the convolutional layer may be limited. For example, when the pooling window is limited to move by skipping SM columns along the row direction of the convolutional layer, the row direction Stride of the pooling operation is referred to as SM, and the pooling window is referred to as SM in the column direction of the convolutional layer.
  • the column direction stride of the pooling operation can be referred to as SN (SM and SN are natural numbers).
  • SN the column direction stride of the pooling operation
  • the size of Stride increases, the size of the pooling layer output as a result of the pooling operation can become smaller.
  • the specific concept of the pooling operation is well presented in prior art explaining CNN.
  • flattening can be performed on the pooling layers 53 to create an array to be input to the neural network 54.
  • the array can then be input into the neural network 54 to generate an output from the neural network 54.
  • Figure 1 shows one embodiment of a CNN
  • the pooling operation is used to implement CNN in Figure 1, the pooling operation can also be used in other computing technology fields other than CNN.
  • the amount of computation for pooling operations tends to increase as the size of the pooling window increases, and tends to decrease as the size of Stride becomes smaller. Additionally, the smaller the Stride size, the more likely it is that the same operation will be repeated during the pooling operation.
  • variable array In the process of generating the convolutional layer and executing the pooling, an array, referred to herein as a variable array, can be created and used as follows.
  • a convolution operation is performed between the first input data and the first kernel.
  • N1 output values are generated, and the variable array is generated to generate each output value.
  • the variable array is an array that includes part or all of the first input data.
  • an operation is performed between the elements of the created variable array and the elements of the first kernel.
  • the size of the variable array may be the same as the size of the first kernel.
  • the operation process between the elements of the generated variable array and the elements of the first kernel is executed N1 times, and the value of the variable array changes each time the operation process is executed. It can be.
  • N2 output values can be generated as a result of pooling the generated convolutional layer.
  • the variable array can be created to generate each of the output values.
  • the variable array is an array containing some or all of the data of the convolutional layer.
  • pooling can be performed on the elements of the created variable array.
  • the size of the variable array may be the same as the size of the pooling window.
  • pooling of elements of the generated variable array is performed N2 times, and each time the pooling is performed, the value of the variable array may be changed.
  • the present invention seeks to provide a method for determining each value of data that must be prepared to execute operations such as convolution and pooling operations in a neural network, and instructions for executing this method.
  • instructions for preparing data necessary for calculation in a neural network can be provided.
  • the value of a specific element of the array required for calculation in the neural network is determined.
  • the array required for calculation in the neural network may be referred to as a 'variable array'.
  • all values of the variable array can be determined by executing the instruction M times.
  • variable array can be used in various calculation processes such as convolution and pooling operations in a neural network.
  • the instructions provided according to one aspect of the present invention may be stored in a memory referenced by the CPU of the computing device and may be executed by the CPU.
  • the instruction may be stored in a memory referenced by the control unit of the hardware accelerator of the computing device and may be executed by the control unit.
  • an instruction execution method in which a computing device executes an instruction includes: a first step of comparing a first variable (lpad) with a predetermined first constant when the instruction is called; and a second step of terminating execution of the instruction after storing a predetermined padding value in the first register or a value stored in the memory.
  • the second step if the first variable is greater than the first constant, the predetermined padding value is stored in the first register, and the first variable is decreased by 1, and then the first variable is The execution of the instruction is terminated, and if the first variable is not greater than the first constant, the second variable (valid) is compared with a predetermined second constant.
  • the second variable is not greater than the first constant
  • the second variable (valid) is compared with the second constant. If it is greater than the constant, the value stored at the memory address indicated by the third variable (s_idx) is stored in the first register, the second variable is decreased by 1, and the third variable is set to a predetermined third value.
  • the execution of the first instruction is terminated after incrementing the first instruction, and if the second variable is not greater than the second constant, the predetermined padding value is stored in the first register and then the first instruction is executed. Execution is terminated.
  • the method may further include the step of initializing the first variable (lpad), the second variable (valid), and the third variable (s_idx) before the instruction is called.
  • the first variable (lpad) is initialized to have the maximum number of padding used in a pre-planned operation
  • the second variable (valid) is initialized to have the size of the target array that is the target of the pre-planned operation.
  • the third variable (s_idx) may be initialized to have the first address among addresses representing an area of memory containing information corresponding to the target array.
  • the predetermined third value may be a difference value between addresses representing two adjacent pieces of data in one area of the memory.
  • the first constant may be 0 (zero)
  • the second constant may be 0 (zero).
  • the predetermined operation may be a pooling operation.
  • the pre-planned operation may be a convolution operation.
  • an operation method in which a computing device executes a predetermined operation.
  • This method includes initializing a first variable (lpad), a second variable (valid), and a third variable (s_idx); determining the values of all elements of a predetermined variable array by executing a predetermined instruction execution method once or repeatedly; and executing the pre-planned operation on the variable array for which the values of all the elements have been determined, thereby generating data for at least some of the pre-planned output array.
  • the predetermined instruction execution method includes a first step of comparing the first variable (lpad) with a predetermined first constant when a call to the predetermined instruction occurs, and a predetermined padding value or a value stored in memory.
  • An instruction execution step including a second step of terminating execution of the instruction after storing in a first register, and writing the value stored in the first register to the variable array.
  • the first variable (lpad) is initialized to have the maximum number of padding used in the pre-planned operation
  • the second variable (valid) is initialized to have the size of the target array that is the target of the pre-planned operation.
  • the third variable (s_idx) may be initialized to have the first address among addresses representing an area of memory containing information corresponding to the target array.
  • the predetermined padding value is stored in the first register, and the first variable is decreased by 1, and then the first variable is The execution of the instruction is terminated, and if the first variable is not greater than the first constant, the second variable (valid) is compared with a predetermined second constant. If the second variable is not greater than the first constant, the second variable (valid) is compared with the second constant. If it is greater than the constant, the value stored at the memory address indicated by the third variable (s_idx) is stored in the first register, the second variable is decreased by 1, and the third variable is set to a predetermined third value. The execution of the first instruction is terminated after incrementing the first instruction, and if the second variable is not greater than the second constant, the predetermined padding value is stored in the first register and then the first instruction is executed. It may be set to terminate execution.
  • the first constant is 0 (zero)
  • the second constant is 0 (zero)
  • the predetermined third value is a difference value between addresses representing two adjacent data in one area of the memory. You can.
  • the pre-planned operation is a pooling operation
  • the size of the variable array may be the same as the size of the pooling window for the pooling operation.
  • the pre-planned operation is a convolution operation
  • the size of the variable array may be the same as the size of the kernel used for the convolution operation.
  • the value stored in the first register may be written to an element pointed to by a predetermined first pointer in the variable array. And each time the instruction execution method is executed, the element of the variable array pointed to by the first pointer may be changed.
  • a computing device including a main processor 160 and a storage unit 170 may be provided. Instruction codes for executing the above-described instruction execution method or calculation method are recorded in the storage unit 170, and the main processor is configured to read the instruction code and execute the instruction execution method or the calculation method.
  • a computing device including a hardware accelerator 110 may be provided.
  • the hardware accelerator is configured to execute the above-described instruction execution method or the above-described calculation method.
  • an instruction execution method in which a computing device executes an instruction includes comparing a first variable (lpad) with a predetermined first constant (0) when the instruction is called; If the first variable is greater than the first constant, storing a predetermined padding value in a first register, decreasing the first variable by 1, and then terminating execution of the first instruction; If the first variable is not greater than the first constant, comparing a second variable (valid) with a predetermined second constant (0); If the second variable is greater than the second constant, the value stored at the memory address indicated by the third variable (s_idx) is stored in the first register, the second variable is decreased by 1, and the second variable is decreased by 1. increasing the third variable by a predetermined third value and terminating execution of the first instruction; If the second variable is not greater than the second constant, storing the predetermined padding value in the first register and terminating execution of the first instruction.
  • a method for determining each value of data that must be prepared to execute operations such as convolution operation and pooling operation in a neural network and instructions for executing this method can be provided.
  • FIG. 1 shows the computational structure of CNN according to one embodiment. Hereinafter, the description will be made with reference to FIG. 1.
  • Figure 2 shows the main structure of some of the computing devices used in one embodiment of the present invention.
  • Figure 3 shows the concepts of a target array, kernel, and variable array used when executing a convolution operation according to an embodiment of the present invention.
  • Figure 4 is a diagram explaining the concept of a method of performing a convolution operation using a predetermined target array and kernel.
  • FIGS. 5A, 5B, 5C, and 5D are flowcharts showing a convolution operation method provided according to an embodiment of the present invention.
  • Figure 6 shows an actual example of the convolution operation method provided according to an embodiment of the present invention shown in Figures 5a, 5b, 5c, and 5d.
  • Figure 7 shows the concepts of a target array and a variable array used when performing a pooling operation according to an embodiment of the present invention.
  • Figure 8 is a diagram explaining the concept of a method of performing a pooling operation on a predetermined target array using a pooling window.
  • FIGS. 9A, 9B, 9C, and 9D are flowcharts showing a pooling operation method provided according to an embodiment of the present invention.
  • Figure 10 shows an actual example of the pooling operation method provided according to an embodiment of the present invention shown in Figures 9a, 9b, 9c, and 9d.
  • Figure 11a shows the process of initializing three variables required for execution of the first instruction provided according to an embodiment of the present invention.
  • Figure 11b is a flowchart showing a one-time execution process of the first instruction provided according to an embodiment of the present invention.
  • Figure 12a shows the process of initializing four variables required for execution of the second instruction provided according to another embodiment of the present invention.
  • Figure 12b is a flowchart showing a one-time execution process of the second instruction provided according to another embodiment of the present invention.
  • Figure 2 shows the main structure of some of the computing devices used in one embodiment of the present invention.
  • the computing device 1 includes a dynamic random access memory (DRAM) 130, a hardware accelerator 110, a bus 700 connecting the DRAM 130 and the hardware accelerator 110, and other devices connected to the bus 700. It may include hardware 99 and a main processor 160.
  • DRAM dynamic random access memory
  • the computing device 1 may further include a power supply unit, a communication unit, a user interface, a storage unit 170, and peripheral device units not shown.
  • the bus 700 may be shared by the hardware accelerator 110, other hardware 99, and the main processor 160.
  • the storage unit 170 may be integrally coupled to the computing device 1 or may be detachably coupled to the computing device 1.
  • the hardware accelerator 110 includes a DMA unit (Direct Memory Access part) 20, a control unit 40, an internal memory 30, an input buffer 650, a data operation unit 610, and an output buffer 640. can do.
  • DMA unit Direct Memory Access part
  • Some or all of the data temporarily stored in the internal memory 30 may be provided from the DRAM 130 through the bus 700. At this time, in order to move data stored in the DRAM 130 to the internal memory 30, the control unit 40 and the DMA unit 20 may control the internal memory 30 and the DRAM 130.
  • Data stored in the internal memory 30 may be provided to the data calculation unit 610 through the input buffer 650.
  • Output values generated by the operation of the data calculation unit 610 may be stored in the internal memory 30 through the output buffer 640.
  • the output values stored in the internal memory 30 may be written to the DRAM 130 under the control of the control unit 40 and the DMA unit 20.
  • the control unit 40 can collectively control the operations of the DMA unit 20, the internal memory 30, and the data operation unit 610.
  • the data calculation unit 610 may perform a first calculation function during a first time period and a second calculation function during a second time period.
  • one data operation unit 610 is shown within the hardware accelerator 110.
  • a plurality of data calculation units 610 shown in FIG. 2 may be provided in the hardware accelerator 110 to perform operations requested by the control unit 40 in parallel. there is.
  • the data calculation unit 610 may output the output data sequentially according to a given order over time, rather than all at once.
  • Figure 3 shows the concepts of a target array, kernel, and variable array used when executing a convolution operation according to an embodiment of the present invention.
  • Reference number 80 illustrates memory data 80, which is data stored in memory.
  • the first row represents the address of the memory, and the second row represents the value of the data stored at that address.
  • 'v0', 'v1', etc. may each be one piece of data.
  • the memory may be the DRAM 130 or the internal memory 30 shown in FIG. 2.
  • Reference number 81 is data extracted and read from the memory and is the target array 81 that is the target of the convolution operation.
  • the first row represents the index of the target array 81
  • the second row represents the value of data stored at the index.
  • the values constituting the target array 81 may be read from the DRAM 130 and stored in the internal memory 30 .
  • the indices of the target array 81 may each correspond to addresses of portions of the memory data 80 corresponding to the target array 81.
  • Reference number 90 is a kernel 90 composed of values used for convolution operations.
  • the first row represents the index of the kernel 90, and the second row represents the value of data stored at the index.
  • the values constituting the kernel 90 may be predetermined constant values.
  • the values constituting the kernel 90 may be read from the DRAM 130 and stored in the internal memory 30 .
  • Reference number 70 is a variable array 70 in which the kernel 90 and values actually operated are stored.
  • the first row represents the index of the variable array 70
  • the second row represents the value of data stored at the index. All values constituting the variable array 70 may be obtained from the target array 81. Alternatively, some of the values constituting the variable array 70 may be composed of predetermined padding values, and the remainder may be obtained from the target array 81.
  • the padding value may be a predetermined value such as '0'.
  • Reference number 60 denotes the output array 60, which is data generated by performing a convolution operation on the target array 81 using the kernel 90.
  • the size of the output array 60 may be determined according to the specific definition of the convolution operation method to be executed.
  • data obtained by referring to the index of the kernel 90 and data obtained by referring to the index of the variable array 70 are used in the operation. You can use it.
  • the size of the variable array 70 and the kernel 90 may be smaller than the size of the target array 81.
  • Figure 4 is a diagram explaining the concept of a method of performing a convolution operation using a predetermined target array and kernel.
  • the target array 81 and kernel 90 shown in FIG. 3 are presented as the predetermined target array and kernel. At this time, the size of the kernel 90 is 4.
  • the convolution operation may consist of a total of 8 steps, from steps 21 to 28. For each step, the relative position of the kernel 90 with respect to the target array 81 may be changed by stride 1.
  • each step at least one piece of data of the target array 81 and the kernel 90 may correspond to each other.
  • the data of the target array 81 and the data of the kernel 90 that correspond to each other can be used in a multiplication operation.
  • the padding value (vp) can be multiplied.
  • the padding value (vp) may be, for example, 1.
  • step 21 data p3 of kernel 90 corresponds to data v1 of target array 81.
  • the data of the target array 81 corresponding to the data p0, p1, and p2 of the kernel 90 is not defined.
  • step 24 data p0, p1, p2, and p3 of kernel 90 correspond to data v1, v2, v3, and v4 of target array 81, respectively.
  • step 25 data p0, p1, p2, and p3 of kernel 90 correspond to data v2, v3, v4, and v5 of target array 81, respectively.
  • step 27 data p0 and p1 of the kernel 90 correspond to data v4 and v5 of the target array 81, respectively. However, the data of the target array 81 corresponding to data p2 and p3 of the kernel 90 is not defined.
  • step 28 data p0 of kernel 90 corresponds to data v5 of target array 81.
  • the target array 81 data corresponding to the data p1, p2, and p3 of the kernel 90 is not defined.
  • the values 'maximum number of left padding' and 'maximum number of right padding' are defined.
  • the number of data (ex: p0, p1, p2) that does not correspond to the value of the target array among the data of the kernel 90 is calculated as the number of left padding. It is defined as the maximum number. In the example of the convolution operation method shown in FIG. 4, the maximum number of left paddings is determined to be 3.
  • the number of data (ex: p1, p2, p3) that does not correspond to the value of the target array among the data of the kernel 90 is set to the maximum right padding. It can be defined as a number. In the example of the convolution operation method shown in FIG. 4, the maximum number of right paddings is determined to be 3.
  • the size of the output array 60 is determined to be 8.
  • FIGS. 5A, 5B, 5C, and 5D are flowcharts showing a convolution operation method provided according to an embodiment of the present invention.
  • FIGS. 5A, 5B, 5C, and 5D may be collectively referred to as FIG. 5.
  • step S110 the main processor 160 or the control unit 40 may obtain the start address and end address where the target array 81 is stored among the addresses of the memory.
  • the target array 81 may refer to a set of data that is the target of an operation according to the present invention among data stored in the memory. And the data constituting the target array 81 may be stored in consecutive memory addresses. For example, data constituting the target array 81 of FIG. 3 may be stored in addresses 1 to 5 of the memory.
  • the values of two addresses indicating the locations of two adjacent pieces of data among the data included in the target array 81 may have a difference of 1. If the values of two addresses indicating the locations of two adjacent data have a difference value of size k, k can be normalized to the value of 1 and used. That is, in the present invention, the difference between the address values of two adjacent pieces of data included in the target array is defined as 1.
  • the actual values of the addresses where data v1 and adjacent data v2 are stored, respectively may be addr1 and addr2, and in this case, the actual value obtained by subtracting addr1 from addr2 may not be 1. there is.
  • the actual value obtained by subtracting addr1 from addr2 can be considered to be converted to a scale of 1.
  • the target array 81 may also be referred to as a third array in this specification.
  • source index s_idx
  • lpad valid
  • rpad valid
  • two pointers a variable array pointer (first pointer) and an output array pointer (second pointer), may be further defined.
  • the computing device used to implement the convolution operation method stores the values of source index (s_idx), lpad, valid, and rpad, respectively.
  • the source index register (s_idx_reg), Lpad register (lpad_reg), valid register (valid_reg), and Rpad register (rpad_reg), which are registers, can be allocated to the memory space.
  • the specific value can be viewed as being assigned to the corresponding variable.
  • the value stored in each register is changed, the value of the corresponding variable can be viewed as changed. And if you want to change the value of each variable, change the value stored in the corresponding register.
  • step S120 the computing device may perform an initialization operation.
  • the initialization task includes the tasks listed below.
  • the first index of the target array can be assigned to the source index (s_idx).
  • the first index of the target array may be an address of the memory where the first data of the target array is stored.
  • the maximum number of left paddings used in a pre-planned convolution operation can be assigned to lpad.
  • the size of the target array can be assigned to the valid.
  • the maximum number of right paddings used in the planned convolution operation can be assigned to the rpad.
  • variable array 70 of the same size as the kernel 90 can be prepared. That is, the computing device can allocate memory space for the variable array 70.
  • the size of the variable array 70 is 4.
  • the variable array 70 may be referred to as a second array in this specification.
  • the value of the first pointer may be initialized so that the variable array pointer (first pointer) points to the first index of the variable array 70.
  • the first pointer may be initialized to point to index 1, which is the first index of the variable array 70.
  • the value of the output array pointer can be initialized so that it points to the first index of the output array 60 prepared in advance.
  • the second pointer may be initialized to point to index 0, which is the first index of the output array 60.
  • step S130 it is determined whether lpad is greater than 0. If lpad is greater than 0, the process proceeds to step S210. Otherwise, the process proceeds to step S310.
  • step S310 it is determined whether the valid is greater than 0. If the valid is greater than 0, the process proceeds to step S320. Otherwise, the process proceeds to step S410.
  • a predetermined padding value (vp) may be stored in the position indicated by the variable array pointer in the variable array 70.
  • lpad may be decreased by a first value.
  • the first value may be, for example, 1.
  • step S230 the value of the variable array pointer (first pointer) may be increased by the word size. And at this time, the increase may be a circulation increase. Then, the process may return to step S130 of FIG. 5A.
  • the cyclic increase means that if the first pointer currently points to the last index of the variable array 70, the first pointer points to the first index of the variable array 70.
  • the value of the last index is greater than the value of the first index.
  • step S320 the value of the target array 81 pointed to by the source index (s_idx) can be stored in the position pointed to by the variable array pointer (first pointer) of the variable array 70. .
  • step S330 the valid may be decreased by a second value and the source index (s_idx) may be increased by a third value.
  • the second value may be, for example, 1.
  • the third value may be a difference value between addresses representing two adjacent pieces of data in one area of the memory.
  • step S340 the calculated value of the variable array 70 and the kernel 90 may be stored in the position pointed to by the output array pointer (second pointer) of the output array 60.
  • the operation may be a convolution operation.
  • step S350 the value of the variable array pointer (first pointer) may be cyclically increased by the word size, and the output array pointer (second pointer) may be increased by the word size. Then, the process may return to step S130 of FIG. 5A.
  • step S410 it can be determined whether rpad is greater than 1 in step S410. If rpad is greater than 1, the process proceeds to step S420. Otherwise, the convolution calculation method ends.
  • a predetermined padding value (vp) may be stored in the position indicated by the variable array pointer in the variable array 70.
  • rpad may be decreased by a fourth value.
  • the fourth value may be, for example, 1.
  • step S440 the value calculated by the variable array 70 and the kernel 90 may be stored in the position pointed to by the output array pointer (second pointer) of the output array 60.
  • the operation may be a convolution operation.
  • step S450 the value of the variable array pointer may be cyclically increased by the word size, and the output array pointer (second pointer) may be increased by the word size. Then, the process may return to step S130 of FIG. 5A.
  • the first value, the second value, and the fourth value may refer to index difference values between adjacent elements in a given array.
  • Figure 6 shows an actual example of the convolution operation method provided according to an embodiment of the present invention shown in Figure 5.
  • FIG. 6 is an example of applying the convolution operation method shown in FIG. 5 to the target array 81 and kernel 90 illustrated in FIG. 3.
  • Figure 6 shows the register table 50, variable array 70, kernel 90, and output showing the values of source index (s_idx), lpad, valid, and rpad.
  • Array 60 was presented.
  • the output array 60 presented only some elements where the output array pointer (second pointer) was located, and did not present the remaining elements.
  • Each value of the output array 60 illustrated in FIG. 3 can be determined by calculating the values of the variable array 70 and the kernel 90 with each other. Since at least some of the element values of the variable array 70 are not determined in steps 0 to 3, an operation for determining an element of the output array 60 cannot be performed in steps 0 to 3.
  • each element of the output array 60 is determined.
  • step 0 of FIG. 6 the values of source index (s_idx), lpad, valid, and rpad are 1, 3, 5, respectively, by step S120 of FIG. 5A. It is determined to be 3, and the value of the first pointer is initialized so that the first pointer points to the first index (0) of the variable array 70. In Figure 6, the location of the first pointer is indicated by a black inverted triangle.
  • step (S130) in the k-th step shows the state just before execution.
  • 'vp' is a predefined padding value, and the symbol '?' indicates that the value of the element is not a valid value.
  • step 1 of FIG. 6 The state shown in step 1 of FIG. 6 is the result of executing steps S130, S210, S220, and S230 of FIG. 5. As a result, the padding value is stored at index 0 of the variable array 70.
  • step 1 lpad was decreased by 1 in step S220, but the result is presented in step 2.
  • step 2 the value of the first pointer is increased by 1 in step S230, but the result is presented in step 2.
  • step 2 of FIG. 6 The state shown in step 2 of FIG. 6 is the result of sequentially executing steps S130, S210, S220, and S230 in FIG. 5. As a result, the padding value is stored at index 1 of the variable array 70.
  • step 3 of FIG. 6 The state shown in step 3 of FIG. 6 is the result of sequentially executing steps S130, S210, S220, and S230 in FIG. 5. As a result, the padding value is stored at index 2 of the variable array 70.
  • steps S130, S310, S320, S330, S340, and S350 of FIG. 5 are sequentially performed. This is the result of running .
  • the result value (co[ ]) of calculating the values stored in the variable array 70 and the values stored in the kernel 90 is stored in the location of the output array 60 indicated by the second pointer.
  • step (S130), step (S310), step (S410), step (S420), step (S430), step (S440), and step (S440) of FIG. (S450) is the result of sequential execution.
  • the result value (co[ ]) of calculating the values stored in the variable array 70 and the values stored in the kernel 90 is stored in the location of the output array 60 indicated by the second pointer.
  • step 11 of FIG. 6 The state shown in step 11 of FIG. 6 is the result of sequentially executing steps S130, S310, S410, and S500 of FIG. 5.
  • a result value (co[ ]) of calculating the values stored in the variable array 70 and the values stored in the kernel 90 is stored in the location of the output array 60 pointed to by the second pointer, and the convolution The calculation method ends.
  • the last index value of the kernel 90 corresponds to the index value pointed to by the first pointer in the variable array 70.
  • the value of the index cyclically increased by n from the last index of the kernel 90 corresponds to the value of the index cyclically increased by n from the index pointed to by the first pointer.
  • the corresponding values can be operated with each other. That is, in FIG. 6, in the kernel 90 and the variable array 70, data indicated by a square icon is operated, data indicated by a circular icon is calculated, data indicated by a triangle icon are calculated, and Data indicated by the black inverted triangle icon can be operated on.
  • Figure 7 shows the concepts of a target array and a variable array used when performing a pooling operation according to an embodiment of the present invention.
  • Reference number 80 illustrates memory data 80, which is data stored in memory.
  • Reference number 81 is data extracted and read from the memory and is the target array 81 that is the target of the pooling operation.
  • Reference number 70 is a variable array 70. All values constituting the variable array 70 may be obtained from the target array 81. Alternatively, some of the values constituting the variable array 70 may be composed of predetermined padding values, and the remainder may be obtained from the target array 81.
  • the padding value may be a predetermined value such as '0'.
  • Reference number 160 indicates the output array 160, which is data generated by performing a pooling operation on the target array 81.
  • the size of the output array 160 may be determined according to the specific definition of the pooling operation method to be executed.
  • the size of the variable array 70 may be smaller than the size of the target array 81.
  • the size of the variable array 70 is the same as the size of the pooling window used in the defined pooling operation.
  • Figure 7 an example where the size of the pooling window is 4 is presented.
  • Figure 8 is a diagram explaining the concept of a method of performing a pooling operation on a predetermined target array using a pooling window.
  • the target array 81 shown in FIG. 7 is presented as the predetermined target array.
  • the size of the pooling window is 4.
  • the position of the pooling window is indicated by a dotted line.
  • the pooling operation may consist of a total of 8 steps, including steps 121 to 128. For each step, the relative position of the pooling window to the target array 81 may be changed by stride 1.
  • v1, v2, v3, v4, and v5 are assumed to have values of 1, 2, 3, 4, and 5, respectively. It is assumed that the pooling operation applied in FIG. 8 is MAX pooling, which outputs the largest value among the values existing in the pooling window.
  • the values 'maximum number of left padding' and 'maximum number of right padding' are defined.
  • the number of areas in the pooling window that do not correspond to the value of the target array is defined as the maximum number of left padding.
  • the maximum number of left paddings is determined to be 3.
  • the number of areas in the pooling window that do not correspond to the value of the target array can be defined as the maximum number of right padding.
  • the maximum number of right paddings is determined to be 3.
  • the size of the output array 160 is determined to be 8.
  • FIGS. 9A, 9B, 9C, and 9D are flowcharts showing a pooling operation method provided according to an embodiment of the present invention.
  • FIGS. 9A, 9B, 9C, and 9D may be collectively referred to as FIG. 9.
  • step S1110 the main processor 160 or the control unit 40 may obtain the start address and end address of the area in the memory where data of the target array 81 is stored.
  • Data constituting the target array 81 of FIG. 7 may be stored in addresses 1 to 5 of the memory.
  • source index s_idx
  • lpad valid
  • rpad valid
  • two pointers a variable array pointer (first pointer) and an output array pointer (second pointer), may be further defined.
  • the computing device used to implement the pooling operation method stores the values of source index (s_idx), lpad, valid, and rpad, respectively.
  • the registers source index register (s_idx_reg), Lpad register (lpad_reg), valid register (valid_reg), and Rpad register (rpad_reg) can be allocated to the memory space.
  • step S1120 the computing device may perform an initialization operation.
  • the initialization task includes the tasks listed below.
  • the first index of the target array 81 can be assigned to the source index (s_idx).
  • the maximum number of left paddings used in a pre-planned pooling operation can be assigned to lpad.
  • the size of the target array 81 can be assigned to the valid.
  • the maximum number of right paddings used in the planned pooling operation can be assigned to the rpad.
  • variable array (second array) 70 having the same size as the size of the pooling window used in the pooling operation can be prepared.
  • variable array pointer (first pointer) can be initialized so that the variable array pointer (first pointer) points to the first index of the variable array 70.
  • the variable array pointer (first pointer) may be initialized to point to index 1, which is the first index of the variable array 70.
  • the value of the output array pointer can be initialized so that it points to the first index of the output array 160 prepared in advance.
  • the second pointer may be initialized to point to index 0, which is the first index of the output array 160.
  • step S1130 it is determined whether lpad is greater than 0. If lpad is greater than 0, the process proceeds to step S1210. Otherwise, the process proceeds to step S1310.
  • step S1310 it is determined whether the valid is greater than 0. If the valid is greater than 0, the process proceeds to step S1320. Otherwise, the process proceeds to step S1410.
  • a predetermined padding value may be stored in the position indicated by the variable array pointer in the variable array 70.
  • the padding value (vp) may be the smallest value that can be expressed.
  • the padding value (vp) may be defined as a different value. For example, if the pooling operation is average pooling, which outputs the average value of data within the pooling window, the padding value (vp) may be 0 (0).
  • step S1220 lpad may be reduced by the first value.
  • step S1230 the value of the variable array pointer (first pointer) may be increased by the word size. And at this time, the increase may be a circulation increase. Then, the process may return to step S1130 of FIG. 9A.
  • step S1320 the value of the target array 81 indicated by the source index (s_idx), that is, the source, is placed at the position pointed to by the variable array pointer (first pointer) of the variable array 70.
  • the value of the element of the target array 81 pointed to by the index (s_idx) can be stored.
  • step S1330 the valid may be decreased by the second value and the source index (s_idx) may be increased by the third value.
  • step S1340 the result of the pooling operation on the data of the variable array 70 may be stored in the position pointed to by the output array pointer (second pointer) of the output array 160.
  • step S1350 the value of the variable array pointer (first pointer) may be cyclically increased by the word size, and the output array pointer (second pointer) may be increased by the word size. Then, the process may return to step S1130 of FIG. 9A.
  • step S1410 it can be determined whether rpad is greater than 1 in step S1410. If rpad is greater than 1, the process proceeds to step S1420. Otherwise, the process proceeds to step S1500 and the pooling operation method is terminated.
  • the predetermined padding value (vp) may be stored in the position indicated by the variable array pointer in the variable array 70.
  • step S1430 the rpad may be decreased by the fourth value.
  • step S1440 the result of the pooling operation on the data of the variable array 70 may be stored in the position pointed to by the output array pointer (second pointer) of the output array 160.
  • step S1450 the value of the variable array pointer may be cyclically increased by the word size, and the output array pointer (second pointer) may be increased by the word size. Then, the process may return to step S1130 of FIG. 9A.
  • Figure 10 shows an actual example of the pooling operation method provided according to an embodiment of the present invention shown in Figure 9.
  • FIG. 10 is an example of applying the pooling operation method shown in FIG. 9 to the target array 81 illustrated in FIG. 7.
  • Figure 10 shows the register table 50, variable array 70, and output array 160 showing the values of source index (s_idx), lpad, valid, and rpad. presented.
  • the output array 160 presented only some elements where the output array pointer (second pointer) was located, and did not present the remaining elements.
  • steps 100 to 103 shown in FIG. 10 the values of the variable array 70 are not confirmed.
  • Each value of the output array 160 illustrated in FIG. 7 may be determined by performing a pooling operation targeting the variable array 70. Since at least some of the element values of the variable array 70 are not determined in steps 100 to 103, an operation for determining an element of the output array 160 cannot be performed in steps 100 to 103.
  • each element of the output array 160 is determined.
  • step 100 of FIG. 10 the values of source index (s_idx), lpad, valid, and rpad are 1, 3, 5, respectively, by step S1120 of FIG. 9a. It is determined to be 3, and the value of the first pointer is initialized to point to the first index (0) of the variable array 70. In Figure 10, the location of the first pointer is indicated by a black inverted triangle.
  • 'vp' is a predefined padding value, and the symbol '?' indicates that the value of the element is not a valid value.
  • step 101 of FIG. 10 The state shown in step 101 of FIG. 10 is the result of executing steps S1130, S1210, S1220, and S1230 of FIG. 9. As a result, the padding value is stored at index 0 of the variable array 70.
  • step 102 of FIG. 10 The state shown in step 102 of FIG. 10 is the result of sequentially executing steps S1130, S1210, S1220, and S1230 in FIG. 9. As a result, the padding value is stored at index 1 of the variable array 70.
  • step 103 of FIG. 10 The state shown in step 103 of FIG. 10 is the result of sequentially executing steps S1130, S1210, S1220, and S1230 in FIG. 9. As a result, the padding value is stored at index 2 of the variable array 70.
  • steps S1130, S1310, S1320, S1330, S1340, and S1350 of FIG. 9 are sequentially performed. This is the result of running .
  • the result value (po[ ]) of the pooling operation on the values stored in the variable array 70 is stored in the location of the output array 160 pointed to by the second pointer.
  • steps 109 to 110 of FIG. 10 are step (S1130), step (S1310), step (S1410), step (S1420), step (S1430), step (S1440), and step (S1440) of FIG. 9. This is the result of (S1450) being executed sequentially.
  • the result value (po[ ]) of the pooling operation on the values stored in the variable array 70 is stored in the location of the output array 160 pointed to by the second pointer.
  • the state shown in step 111 of FIG. 10 is the result of sequentially executing steps S1130, S1310, S1410, and S1500 in FIG. 9.
  • the result value (po[ ]) of the pooling operation on the values stored in the variable array 70 is stored in the location of the output array 160 pointed to by the second pointer, and the pooling operation method is terminated.
  • the above-described embodiment of the convolution operation and the embodiment of the pooling operation include a process for determining the value to be stored in the variable array 70. This process is explained with reference to Figures 11A and 11B.
  • Figure 11a shows the process of initializing three variables required for execution of the first instruction provided according to an embodiment of the present invention.
  • Figure 11b is a flowchart showing a one-time execution process of the first instruction provided according to an embodiment of the present invention.
  • Executing the first instruction by a computing device may mean executing steps executed by the first instruction.
  • the values of the three variables necessary for executing the first instruction are initialized, and the first instruction is initialized so that the first instruction can control the values of the three variables. may need to be associated with the above three variables.
  • the three variables are initialized, each time the first instruction is executed, values required for a pre-planned operation may be determined and loaded into the first register.
  • a value stored in memory may be loaded into the first register, but under certain conditions, a specific predetermined constant value may be loaded into the first register.
  • the specific predetermined constant value may be referred to as a padding value.
  • the name of the first instruction provided according to an embodiment of the present invention may be, for example, LwP1 or LoadWithPad1, but is not limited thereto.
  • variable initialization method for executing the first instruction includes the following steps.
  • the computing device may obtain the first address of the area of the memory corresponding to the target array that is the target of the pre-planned operation.
  • the memory may be DRAM or SRAM.
  • the address of the memory may be referred to as an index.
  • step S2120 the computing device assigns the obtained first address to s_idx, assigns the maximum number of left paddings used in the preplanned operation to lpad, and assigns the size of the target array to valid. can do.
  • the steps S2110 and S2120 may be understood as initializing a set of variables including lpad, s_idx, and valid.
  • step S2100 can be understood as a step of initializing a set of variables including lpad, s_idx, and valid.
  • the size of the target array may be the number of data elements included in the target array.
  • the method for executing the first instruction begins.
  • the method of executing the first instruction requires control rights to a set of variables including pad, s_idx, and valid, write rights to a predetermined first register, and read rights to memory.
  • a method of executing the first instruction provided according to an embodiment of the present invention includes the following steps.
  • step S2130 it is checked whether lpad is greater than 0 (zero). If it is greater than 0, proceed to step (S2210), and if not greater than 0, proceed to step (S2310).
  • step S2310 it is checked whether valid is greater than 0 (zero). If it is greater than 0, proceed to step (S2320), and if not greater than 0, proceed to step (S2420).
  • step S2210 a predetermined padding value is stored in the first register.
  • step S2220 lpad is decreased by the first value and then execution of the first instruction is terminated.
  • step S2320 the value stored at the memory address indicated by s_idx is stored in the first register.
  • step S2330 valid is decreased by the second value, s_idx is increased by the third value, and execution of the first instruction is terminated.
  • s_idx may be increased by ndv instead of 1 in step S2330.
  • step S2420 the predetermined padding value is stored in the first register and then execution of the first instruction is terminated.
  • the first instruction When the first instruction is executed once, at least one of the lpad, the valid, and the s_idx is changed. In this way, the first instruction may be executed again with at least one of the lpad, valid, and s_idx changed.
  • a higher-level application using the first instruction may call the first instruction N times after executing the variable initialization method for executing the first instruction once.
  • the value stored in the first register can be updated N times.
  • the higher-level application can use the value of the first register updated N times in real time or store it in a separate array (eg, the variable array) and use it for a pre-planned operation.
  • the pre-planned operation may be a convolution operation
  • the higher-level application may be an operation that executes the convolution operation.
  • the pre-planned operation may be a pooling operation and the higher level application may be a program that executes the pooling operation.
  • the pre-planned operation may be an arbitrary operation and the higher level application may be a program that executes the arbitrary operation.
  • Figure 12a shows the process of initializing four variables required for execution of the second instruction provided according to another embodiment of the present invention.
  • Figure 12b is a flowchart showing a one-time execution process of the second instruction provided according to another embodiment of the present invention.
  • the values of four variables required for executing the second instruction are initialized, and the second instruction is initialized so that the second instruction can control the values of the four variables. may need to be associated with the above four variables.
  • values required for a pre-planned operation may be determined and loaded into the first register.
  • the name of the second instruction provided according to another embodiment of the present invention may be, for example, LwP2 or LoadWithPad2, but is not limited thereto.
  • a variable initialization method for executing a second instruction includes the following steps.
  • the computing device may obtain the first address of the area of the memory corresponding to the target array that is the target of the pre-planned operation.
  • step S2120 the computing device assigns the obtained first address to s_idx, assigns the maximum number of left paddings used in the preplanned operation to lpad, and assigns the size of the target array to valid. , and the maximum number of right paddings used in the preplanned operation can be given to rpad.
  • the steps S2110 and S2120 may be understood as initializing a set of variables including lpad, s_idx, valid, and rpad.
  • step S2100 can be understood as a step of initializing a set of variables including lpad, s_idx, valid, and rpad.
  • the size of the target array may be the number of data elements included in the target array.
  • the second instruction execution method begins.
  • the second instruction execution method requires control rights to a set of variables including pad, s_idx, valid, and rpad, write rights to a predetermined first register, and read rights to memory.
  • a method of executing the second instruction provided according to another embodiment of the present invention includes the following steps.
  • step S2130 it is checked whether lpad is greater than 0 (zero). If it is greater than 0, proceed to step (S2210), and if it is not greater than 0, proceed to step (S2310).
  • step S2310 it is checked whether valid is greater than 0 (zero). If it is greater than 0, proceed to step (S2320), and if not greater than 0, proceed to step (S2410).
  • step S2410 it is checked whether rpad is greater than 1. If it is greater than 1, it proceeds to step (S2420), and if it is not greater than 1, it ends.
  • step S2210 a predetermined padding value is stored in the first register.
  • step S2220 lpad is decreased by the first value and then execution of the second instruction is terminated.
  • step S2320 the value stored at the memory address indicated by s_idx is stored in the first register.
  • step S2330 valid is decreased by the second value, s_idx is increased by the third value, and execution of the second instruction is terminated.
  • s_idx can be increased by ndv in step S2330.
  • step S2420 the predetermined padding value is stored in the first register. Otherwise, in step S2430, rpad is decreased by the fourth value and then execution of the second instruction is terminated.

Abstract

Disclosed is an instruction execution method by which a computing device executes an instruction. The method comprises: a first step of, when the instruction is called, comparing a first variable with a predetermined first constant; and a second step of storing, in a first register, a predetermined padding value or a value stored in a memory, and then terminating execution of the instruction.

Description

신경망에서의 연산방법 및 이를 위한 장치Neural network calculation method and device for this
본 발명은 신경망의 구현을 위해 컴퓨팅 장치에서 연산을 수행하는 방법 및 이 방법이 적용된 하드웨어 가속기에 관한 것이다.The present invention relates to a method of performing calculations in a computing device to implement a neural network and a hardware accelerator to which this method is applied.
CNN은 풀링 연산을 포함하는 복수 개의 연산단계를 수행한다. 미국등록특허 US10713816에는 심층 CNN 풀링 레이어를 특징으로서 이용하는 물체검출 방법이 제시되어 있다.CNN performs multiple computational steps including pooling operations. US registered patent US10713816 proposes an object detection method using a deep CNN pooling layer as a feature.
도 1은 일 실시예에 따른 CNN의 연산구조를 나타낸 것이다. 이하 도 1을 참조하여 설명한다.Figure 1 shows the computational structure of CNN according to one embodiment. Hereinafter, the description will be made with reference to FIG. 1.
우선, 내부메모리에 저장된 입력 이미지 데이터(51)에 복수 개의 커널들을 이용한 콘볼루션 연산을 수행하여 콘볼루션 레이어들(52)을 생성할 수 있다. 콘볼루션 레이어들(52)을 생성하는 단계는 상기 콘볼루션 연산을 수행한 결과 얻은 복수 개의 피쳐 맵들에 대하여 비선형 연산(ex: ReLU, Sigmoid, 또는, tanH)을 수행하는 단계를 포함할 수 있다. First, convolution layers 52 can be created by performing a convolution operation using a plurality of kernels on the input image data 51 stored in the internal memory. The step of generating the convolution layers 52 may include performing a non-linear operation (e.g., ReLU, Sigmoid, or tanH) on a plurality of feature maps obtained as a result of performing the convolution operation.
그 다음 콘볼루션 레이어들(52)에 대한 풀링을 수행하여 풀링 레이어들(53)을 생성할 수 있다. 각각의 콘볼루션 레이어(52)는 M*N 행렬 형태로 표현될 수 있는 데이터를 포함할 수 있다. 이때, 풀링을 수행하기 위하여 상기 콘볼루션 레이어(52)보다 작은 디멘젼을 갖는 윈도우인 풀링 윈도우가 정의될 수 있다. 풀링 윈도우는 행 및 열 방향에 대하여 각각 Mp 및 Np의 크기를 가질 수 있다. 풀링 윈도우의 크기는 콘볼루션 레이어의 크기보다 작을 수 있다(M>=Mp 이고 N>Np, 또는 M>Mp 이고 N>=Np). 상기 풀링은 상기 콘볼루션 레이어에 상기 풀링 윈도우를 겹쳐 선택하는 Mp*Np 개의 데이터들로부터 이 보다 더 작은 개수의 데이터, 예컨대 1개의 데이터를 생성하는 연산이다. 예컨대 MAX 풀링은 상기 Mp*Np 개의 데이터들 중에서 가장 큰 값 1개를 선택하여 출력하는 연산이다. 예컨대 average 풀링은 상기 Mp*Np 개의 데이터들의 평균값을 출력하는 연산이다. 그 밖에 다른 규칙을 따르는 풀링이 정의될 수 있다. 상기 콘볼루션 레이어에 상기 풀링 윈도우를 겹칠 수 있는 경우의 수는 다양하다. 실시예에 따라 상기 콘볼루션 레이어 상에서 상기 풀링 윈도우를 이동시키는 규칙을 제한할 수 있다. 예컨대, 상기 풀링 윈도우를 상기 콘볼루션 레이어의 행 방향을 따라 SM 칸 씩 건너뛰어서 이동하도록 제한 경우 상기 풀링 연산의 행 방향 Stride는 SM인 것으로 지칭하고, 상기 풀링 윈도우를 상기 콘볼루션 레이어의 열 방향을 따라 SN 칸 씩 건너뛰어서 이동하도록 제한 경우 상기 풀링 연산의 열 방향 Stride는 SN인 것으로 지칭할 수 있다(SM 및 SN 는 자연수). Stride 의 크기가 커질수록, 풀링 연산의 결과로서 출력되는 풀링 레이어의 크기는 더 작아질 수 있다. 상술한 설명 외에도, 풀링 연산에 대한 구체적인 개념은 CNN을 설명하는 선행기술에 잘 제시되어 있다. Next, pooling layers 53 can be created by performing pooling on the convolutional layers 52. Each convolutional layer 52 may include data that can be expressed in the form of an M*N matrix. At this time, in order to perform pooling, a pooling window, which is a window with a smaller dimension than the convolution layer 52, may be defined. The pooling window may have sizes of Mp and Np in the row and column directions, respectively. The size of the pooling window may be smaller than the size of the convolutional layer (M>=Mp and N>Np, or M>Mp and N>=Np). The pooling is an operation that generates a smaller number of data, for example, 1 data, from Mp*Np data selected by overlapping the pooling window on the convolution layer. For example, MAX pooling is an operation that selects and outputs the largest value among the Mp*Np pieces of data. For example, average pooling is an operation that outputs the average value of the Mp*Np pieces of data. Pooling that follows other rules may be defined. The number of cases in which the pooling window can be overlapped with the convolution layer varies. Depending on the embodiment, rules for moving the pooling window on the convolutional layer may be limited. For example, when the pooling window is limited to move by skipping SM columns along the row direction of the convolutional layer, the row direction Stride of the pooling operation is referred to as SM, and the pooling window is referred to as SM in the column direction of the convolutional layer. If the movement is limited to skipping SN columns at a time, the column direction stride of the pooling operation can be referred to as SN (SM and SN are natural numbers). As the size of Stride increases, the size of the pooling layer output as a result of the pooling operation can become smaller. In addition to the above description, the specific concept of the pooling operation is well presented in prior art explaining CNN.
그 다음, 상기 풀링 레이어들(53)에 대한 플래트닝(flattening)을 수행하여 신경망(54)에 입력할 어레이를 생성할 수 있다. Next, flattening can be performed on the pooling layers 53 to create an array to be input to the neural network 54.
그 다음, 상기 어레이를 상기 신경망(54)에 입력하여 상기 신경망(54)으로부터 출력을 생성할 수 있다. The array can then be input into the neural network 54 to generate an output from the neural network 54.
도 1에서는 CNN의 일 실시예를 나타내었지만, CNN을 구현하는 다양한 다른 예가 존재한다. 또한, 도 1에서 풀링 연산이 CNN의 구현을 위해 이용되었지만, 풀링 연산은 CNN이 아닌 다른 컴퓨팅 기술분야에서도 사용될 수 있다.Although Figure 1 shows one embodiment of a CNN, there are various other examples of implementing a CNN. Additionally, although the pooling operation is used to implement CNN in Figure 1, the pooling operation can also be used in other computing technology fields other than CNN.
풀링 연산의 연산량은 풀링 윈도우의 크기가 커지면 커지는 경향이 있고, Stride의 크기가 작을수록 키지는 경향이 있다. 또한 Stride의 크기가 작을수록 풀링 연산을 수행하는 과정에서 동일한 연산이 반복되는 경향이 높아진다.The amount of computation for pooling operations tends to increase as the size of the pooling window increases, and tends to decrease as the size of Stride becomes smaller. Additionally, the smaller the Stride size, the more likely it is that the same operation will be repeated during the pooling operation.
상기 콘볼루션 레이어를 생성하는 과정, 그리고 상기 풀링을 실행하는 과정에서, 본 명세서에서 가변 어레이라고 지칭하는 어레이를 다음과 같이 생성하여 이용할 수 있다. In the process of generating the convolutional layer and executing the pooling, an array, referred to herein as a variable array, can be created and used as follows.
즉, 콘볼루션 레이어를 생성하기 위해, 제1입력 데이터와 제1커널 간의 콘볼루션 연산을 수행한다. 이때, 제1입력 데이터와 제1커널 간의 콘볼루션 연산을 수행한 결과, N1 개의 출력값들이 생성되는데, 각각의 상기 출력값을 생성하기 위하여 상기 가변 어레이를 생성한다. 상기 가변 어레이는 제1입력 데이터의 일부 또는 전부를 포함하는 어레이다. 그리고, 상기 생성된 가변 어레이의 요소들과 상기 제1커널의 요소들 간의 연산을 실행한다. 이때, 상기 가변 어레이의 크기는 상기 제1커널의 크기와 동일할 수 있다. 상기 N1 개의 출력값들을 모두 생성하는 과정에서, 상기 생성된 가변 어레이의 요소들과 상기 제1커널의 요소들 간의 연산과정은 N1 번 실행되며, 상기 연산과정이 실행될 때마다 상기 가변 어레이의 값은 변경될 수 있다. That is, to create a convolution layer, a convolution operation is performed between the first input data and the first kernel. At this time, as a result of performing a convolution operation between the first input data and the first kernel, N1 output values are generated, and the variable array is generated to generate each output value. The variable array is an array that includes part or all of the first input data. Then, an operation is performed between the elements of the created variable array and the elements of the first kernel. At this time, the size of the variable array may be the same as the size of the first kernel. In the process of generating all N1 output values, the operation process between the elements of the generated variable array and the elements of the first kernel is executed N1 times, and the value of the variable array changes each time the operation process is executed. It can be.
또한, 생성된 상기 콘볼루션 레이어를 풀링한 결과 N2 개의 출력값들이 생성될 수 있다. 이때, 각각의 상기 출력값을 생성하기 위하여 상기 가변 어레이를 생성할 수 있다. 상기 가변 어레이는 상기 콘볼루션 레이어의 데이터의 일부 또는 전부를 포함하는 어레이다. 그리고 상기 생성된 가변 어레이의 요소들을 대상으로 한 풀링을 실행할 수 있다. 여기서 상기 가변 어레이의 크기는 상기 풀링 윈도우의 크기와 동일할 수 있다. 상기 N2 개의 출력값들을 모두 생성하는 과정에서, 상기 생성된 가변 어레이의 요소들을 대상으로 한 풀링은 N2 번 실행되며, 상기 풀링이 실행될 때마다 상기 가변 어레이의 값은 변경될 수 있다.Additionally, N2 output values can be generated as a result of pooling the generated convolutional layer. At this time, the variable array can be created to generate each of the output values. The variable array is an array containing some or all of the data of the convolutional layer. Then, pooling can be performed on the elements of the created variable array. Here, the size of the variable array may be the same as the size of the pooling window. In the process of generating all N2 output values, pooling of elements of the generated variable array is performed N2 times, and each time the pooling is performed, the value of the variable array may be changed.
본 발명은 신경망에서 콘볼루션 연산 및 풀링 연산 등의 연산을 실행하기 위해서 준비해야 하는 데이터의 각각의 값을 결정하는 방법 및 이 방법을 실행하는 인스트럭션을 제공하고자 한다. The present invention seeks to provide a method for determining each value of data that must be prepared to execute operations such as convolution and pooling operations in a neural network, and instructions for executing this method.
본 발명의 일 관점에 따라 신경망에서의 연산을 위해 필요한 데이터를 준비하는 인스트럭션을 제공할 수 있다. 상기 인스트럭션을 1회 실행하면 신경망에서의 연산을 위해 필요한 어레이의 특정 요소의 값이 결정된다. 본 명세서에서 상기 신경망에서의 연산을 위해 필요한 어레이를 '가변 어레이'라고 지칭할 수 있다.According to one aspect of the present invention, instructions for preparing data necessary for calculation in a neural network can be provided. By executing the above instruction once, the value of a specific element of the array required for calculation in the neural network is determined. In this specification, the array required for calculation in the neural network may be referred to as a 'variable array'.
상기 가변 어레이의 크기가 M이라면, 상기 인스트럭션을 M번 실행하면 상기 가변 어레이의 모든 값이 결정될 수 있다. If the size of the variable array is M, all values of the variable array can be determined by executing the instruction M times.
상기 가변 어레이의 모든 요소의 값이 결정되면, 상기 가변 어레이는 신경망에서의 콘볼루션 연산 및 풀링 연산과 같은 다양한 연산 과정에 이용될 수 있다. Once the values of all elements of the variable array are determined, the variable array can be used in various calculation processes such as convolution and pooling operations in a neural network.
본 발명의 일 관점에 따라 제공되는 상기 인스트럭션은 컴퓨팅 장치의 CPU가 참조하는 메모리에 저장되어 있을 수 있으며, 상기 CPU에 의해 실행될 수 있다. 또는 상기 인스트럭션은 컴퓨팅 장치의 하드웨어 가속기의 제어부가 참조하는 메모리에 저장되어 있을 수 있으며, 상기 제어부에 의해 실행될 수 있다. The instructions provided according to one aspect of the present invention may be stored in a memory referenced by the CPU of the computing device and may be executed by the CPU. Alternatively, the instruction may be stored in a memory referenced by the control unit of the hardware accelerator of the computing device and may be executed by the control unit.
본 발명의 일 관점에 따라, 컴퓨팅 장치가 인스트럭션을 실행하는 인스트럭션 실행방법이 제공될 수 있다. 이 방법은, 상기 인스트럭션의 호출이 발생하면, 제1변수(lpad)를 미리 결정된 제1상수와 비교하는 제1단계; 및 제1레지스터에 미리 결정된 패딩값 또는 메모리에 저장된 값을 저장한 후 상기 인스트럭션의 실행을 종료하는 제2단계;를 포함한다. 이때, 상기 제2단계에서, 만일 상기 제1변수가 상기 제1상수보다 크다면, 상기 미리 결정된 패딩값을 상기 제1레지스터에 저장하고, 그리고 상기 제1변수를 1 만큼 감소시킨 후 상기 제1인스트럭션의 실행을 종료하도록 되어 있고, 만일 상기 제1변수가 상기 제1상수보다 크지 않다면, 제2변수(valid)를 미리 결정된 제2상수와 비교하도록 되어 있고, 만일 상기 제2변수가 상기 제2상수보다 크다면, 제3변수(s_idx)가 가리키는 메모리 주소에 저장되어 있는 값을 상기 제1레지스터에 저장하고, 상기 제2변수를 1 만큼 감소시키고, 그리고 상기 제3변수를 소정의 제3값만큼 증가시킨 후 상기 제1인스트럭션의 실행을 종료하도록 되어 있고, 그리고 만일 상기 제2변수가 상기 제2상수보다 크지 않다면, 미리 결정된 상기 패딩값을 상기 제1레지스터에 저장한 후에 상기 제1인스트럭션의 실행을 종료하도록 되어 있다.According to one aspect of the present invention, an instruction execution method in which a computing device executes an instruction may be provided. This method includes: a first step of comparing a first variable (lpad) with a predetermined first constant when the instruction is called; and a second step of terminating execution of the instruction after storing a predetermined padding value in the first register or a value stored in the memory. At this time, in the second step, if the first variable is greater than the first constant, the predetermined padding value is stored in the first register, and the first variable is decreased by 1, and then the first variable is The execution of the instruction is terminated, and if the first variable is not greater than the first constant, the second variable (valid) is compared with a predetermined second constant. If the second variable is not greater than the first constant, the second variable (valid) is compared with the second constant. If it is greater than the constant, the value stored at the memory address indicated by the third variable (s_idx) is stored in the first register, the second variable is decreased by 1, and the third variable is set to a predetermined third value. The execution of the first instruction is terminated after incrementing the first instruction, and if the second variable is not greater than the second constant, the predetermined padding value is stored in the first register and then the first instruction is executed. Execution is terminated.
이때, 상기 방법은, 상기 인스트럭션의 호출이 발생하기 이전에, 제1변수(lpad), 제2변수(valid), 및 제3변수(s_idx)를 초기화하는 단계를 더 포함할 수 있다. 이때, 상기 제1변수(lpad)는 미리 계획된 소정의 연산에서 이용되는 패딩의 최대 개수를 갖도록 초기화되며, 상기 제2변수(valid)는 상기 미리 계획된 소정의 연산의 대상인 대상 어레이의 크기를 갖도록 초기화되고, 그리고 상기 제3변수(s_idx)는 상기 대상 어레이에 대응하는 정보를 포함하는 메모리의 일 영역을 나타내는 주소 중 첫 번째 주소를 갖도록 초기화될 수 있다.At this time, the method may further include the step of initializing the first variable (lpad), the second variable (valid), and the third variable (s_idx) before the instruction is called. At this time, the first variable (lpad) is initialized to have the maximum number of padding used in a pre-planned operation, and the second variable (valid) is initialized to have the size of the target array that is the target of the pre-planned operation. And the third variable (s_idx) may be initialized to have the first address among addresses representing an area of memory containing information corresponding to the target array.
이때, 상기 소정의 제3값은, 상기 메모리의 일 영역 중 서로 인접한 두 개의 데이터를 나타내는 주소들 간의 차이값일 수 있다. At this time, the predetermined third value may be a difference value between addresses representing two adjacent pieces of data in one area of the memory.
이때, 상기 제1상수는 0(영)이고, 상기 제2상수는 0(영)일 수 있다.At this time, the first constant may be 0 (zero), and the second constant may be 0 (zero).
이때, 상기 미리 계획된 소정의 연산은 풀링 연산일 수 있다.At this time, the predetermined operation may be a pooling operation.
이때, 상기 미리 계획된 소정의 연산은 콘볼루션 연산일 수 있다.At this time, the pre-planned operation may be a convolution operation.
본 발명의 다른 관점에 따라 컴퓨팅 장치가 미리 계획된 소정의 연산을 실행하는 연산방법이 제공될 수 있다. 이 방법은, 제1변수(lpad), 제2변수(valid), 및 제3변수(s_idx)를 초기화하는 단계; 소정의 인스트럭션 실행방법을 1회 실행하거나 또는 복수 회 반복하여 실행함으로써, 소정의 가변 어레이의 모든 요소들의 값을 결정하는 단계; 및 상기 모든 요소들의 값이 결정된 상기 가변 어레이에 대하여 상기 미리 계획된 소정의 연산을 실행하여, 미리 계획된 출력 어레이 중 적어도 일부의 데이터를 생성하는 단계;를 포함한다. 이때, 상기 소정의 인스트럭션 실행방법은, 소정의 인스트럭션에 대한 호출이 발생하면, 상기 제1변수(lpad)를 미리 결정된 제1상수와 비교하는 제1단계, 및 미리 결정된 패딩값 또는 메모리에 저장된 값을 제1레지스터에 저장한 후 상기 인스트럭션의 실행을 종료하는 제2단계를 포함하는 인스트럭션 실행단계, 및 상기 제1레지스터에 저장된 값을 상기 가변 어레이에 기록하는 단계를 포함한다. According to another aspect of the present invention, an operation method may be provided in which a computing device executes a predetermined operation. This method includes initializing a first variable (lpad), a second variable (valid), and a third variable (s_idx); determining the values of all elements of a predetermined variable array by executing a predetermined instruction execution method once or repeatedly; and executing the pre-planned operation on the variable array for which the values of all the elements have been determined, thereby generating data for at least some of the pre-planned output array. At this time, the predetermined instruction execution method includes a first step of comparing the first variable (lpad) with a predetermined first constant when a call to the predetermined instruction occurs, and a predetermined padding value or a value stored in memory. An instruction execution step including a second step of terminating execution of the instruction after storing in a first register, and writing the value stored in the first register to the variable array.
이때, 상기 제1변수(lpad)는 상기 미리 계획된 소정의 연산에서 이용되는 패딩의 최대 개수를 갖도록 초기화되며, 상기 제2변수(valid)는 상기 미리 계획된 소정의 연산의 대상인 대상 어레이의 크기를 갖도록 초기화되고, 그리고 상기 제3변수(s_idx)는 상기 대상 어레이에 대응하는 정보를 포함하는 메모리의 일 영역을 나타내는 주소 중 첫 번째 주소를 갖도록 초기화될 수 있다. At this time, the first variable (lpad) is initialized to have the maximum number of padding used in the pre-planned operation, and the second variable (valid) is initialized to have the size of the target array that is the target of the pre-planned operation. is initialized, and the third variable (s_idx) may be initialized to have the first address among addresses representing an area of memory containing information corresponding to the target array.
이때, 상기 제2단계에서, 만일 상기 제1변수가 상기 제1상수보다 크다면, 상기 미리 결정된 패딩값을 상기 제1레지스터에 저장하고, 그리고 상기 제1변수를 1 만큼 감소시킨 후 상기 제1인스트럭션의 실행을 종료하도록 되어 있고, 만일 상기 제1변수가 상기 제1상수보다 크지 않다면, 제2변수(valid)를 미리 결정된 제2상수와 비교하도록 되어 있고, 만일 상기 제2변수가 상기 제2상수보다 크다면, 제3변수(s_idx)가 가리키는 메모리 주소에 저장되어 있는 값을 상기 제1레지스터에 저장하고, 상기 제2변수를 1 만큼 감소시키고, 그리고 상기 제3변수를 소정의 제3값만큼 증가시킨 후 상기 제1인스트럭션의 실행을 종료하도록 되어 있고, 그리고 만일 상기 제2변수가 상기 제2상수보다 크지 않다면, 미리 결정된 상기 패딩값을 상기 제1레지스터에 저장한 후에 상기 제1인스트럭션의 실행을 종료하도록 되어 있을 수 있다. At this time, in the second step, if the first variable is greater than the first constant, the predetermined padding value is stored in the first register, and the first variable is decreased by 1, and then the first variable is The execution of the instruction is terminated, and if the first variable is not greater than the first constant, the second variable (valid) is compared with a predetermined second constant. If the second variable is not greater than the first constant, the second variable (valid) is compared with the second constant. If it is greater than the constant, the value stored at the memory address indicated by the third variable (s_idx) is stored in the first register, the second variable is decreased by 1, and the third variable is set to a predetermined third value. The execution of the first instruction is terminated after incrementing the first instruction, and if the second variable is not greater than the second constant, the predetermined padding value is stored in the first register and then the first instruction is executed. It may be set to terminate execution.
이때, 상기 제1상수는 0(영)이고, 상기 제2상수는 0(영)이며, 상기 소정의 제3값은, 상기 메모리의 일 영역 중 서로 인접한 두 개의 데이터를 나타내는 주소들 간의 차이값일 수 있다.At this time, the first constant is 0 (zero), the second constant is 0 (zero), and the predetermined third value is a difference value between addresses representing two adjacent data in one area of the memory. You can.
이때, 상기 미리 계획된 소정의 연산은 풀링 연산이며, 상기 가변 어레이의 크기는 상기 풀링 연산을 위한 풀링 윈도우의 크기와 동일할 수 있다. At this time, the pre-planned operation is a pooling operation, and the size of the variable array may be the same as the size of the pooling window for the pooling operation.
이때, 상기 미리 계획된 소정의 연산은 콘볼루션 연산이며, 상기 가변 어레이의 크기는 상기 콘볼루션 연산을 위해 사용되는 커널의 크기와 동일할 수 있다. At this time, the pre-planned operation is a convolution operation, and the size of the variable array may be the same as the size of the kernel used for the convolution operation.
이때, 상기 인스트럭션 실행방법이 실행될 때마다, 상기 제1레지스터에 저장된 값은, 상기 가변 어레이 중 소정의 제1포인터가 가리키는 요소에 기록되도록 되어 있을 수 있다. 그리고 상기 인스트럭션 실행방법이 실행될 때마다, 상기 제1포인터가 가리키는 상기 가변 어레이의 요소는 변경되도록 되어 있을 수 있다.At this time, each time the instruction execution method is executed, the value stored in the first register may be written to an element pointed to by a predetermined first pointer in the variable array. And each time the instruction execution method is executed, the element of the variable array pointed to by the first pointer may be changed.
본 발명의 또 다른 관점에 따라, 메인 프로세서(160), 및 저장부(170)를 포함하는 컴퓨팅 장치가 제공될 수 있다. 상기 저장부(170)에는 상술한 인스트럭션 실행방법 또는 연산방법을 실행하는 명령코드가 기록되어 있고, 그리고 상기 메인 프로세서는 상기 명령코드를 읽어서 상기 인스트럭션 실행방법 또는 상기 연산방법을 실행하도록 되어 있다. According to another aspect of the present invention, a computing device including a main processor 160 and a storage unit 170 may be provided. Instruction codes for executing the above-described instruction execution method or calculation method are recorded in the storage unit 170, and the main processor is configured to read the instruction code and execute the instruction execution method or the calculation method.
본 발명의 또 다른 관점에 따라, 하드웨어 가속기(110)를 포함하는 컴퓨팅 장치가 제공될 수 있다. 상기 하드웨어 가속기는, 상술한 인스트럭션 실행방법 또는 상술한 연산방법을 실행하도록 되어 있다.According to another aspect of the present invention, a computing device including a hardware accelerator 110 may be provided. The hardware accelerator is configured to execute the above-described instruction execution method or the above-described calculation method.
본 발명의 또 다른 관점에 따라, 컴퓨팅 장치가 인스트럭션을 실행하는 인스트럭션 실행방법이 제공될 수 있다. 이 방법은, 상기 인스트럭션의 호출이 발생하면, 제1변수(lpad)를 미리 결정된 제1상수(0)와 비교하는 단계; 만일 상기 제1변수가 상기 제1상수보다 크다면, 미리 결정된 패딩값을 제1레지스터에 저장하고 상기 제1변수를 1만큼 감소시킨 후 상기 제1인스트럭션의 실행을 종료하는 단계; 만일 상기 제1변수가 상기 제1상수보다 크지 않다면, 제2변수(valid)를 미리 결정된 제2상수(0)와 비교하는 단계; 만일 상기 제2변수가 상기 제2상수보다 크다면, 제3변수(s_idx)가 가리키는 메모리 주소에 저장되어 있는 값을 상기 제1레지스터에 저장하고, 상기 제2변수를 1만큼 감소시키고, 상기 제3변수를 소정의 제3값만큼 증가시키고, 그리고 상기 제1인스트럭션의 실행을 종료하는 단계; 만일 상기 제2변수가 상기 제2상수보다 크지 않다면, 미리 결정된 상기 패딩값을 상기 제1레지스터에 저장하고 상기 제1인스트럭션의 실행을 종료하는 단계;를 포함한다.According to another aspect of the present invention, an instruction execution method in which a computing device executes an instruction may be provided. This method includes comparing a first variable (lpad) with a predetermined first constant (0) when the instruction is called; If the first variable is greater than the first constant, storing a predetermined padding value in a first register, decreasing the first variable by 1, and then terminating execution of the first instruction; If the first variable is not greater than the first constant, comparing a second variable (valid) with a predetermined second constant (0); If the second variable is greater than the second constant, the value stored at the memory address indicated by the third variable (s_idx) is stored in the first register, the second variable is decreased by 1, and the second variable is decreased by 1. increasing the third variable by a predetermined third value and terminating execution of the first instruction; If the second variable is not greater than the second constant, storing the predetermined padding value in the first register and terminating execution of the first instruction.
본 발명에 따르면 신경망에서 콘볼루션 연산 및 풀링 연산 등의 연산을 실행하기 위해서 준비해야 하는 데이터의 각각의 값을 결정하는 방법 및 이 방법을 실행하는 인스트럭션을 제공할 수 있다. According to the present invention, a method for determining each value of data that must be prepared to execute operations such as convolution operation and pooling operation in a neural network and instructions for executing this method can be provided.
도 1은 일 실시예에 따른 CNN의 연산구조를 나타낸 것이다. 이하 도 1을 참조하여 설명한다.Figure 1 shows the computational structure of CNN according to one embodiment. Hereinafter, the description will be made with reference to FIG. 1.
도 2는 본 발명의 일 실시예에서 이용되는 컴퓨팅 장치 중 일부의 주요 구조를 나타낸 것이다.Figure 2 shows the main structure of some of the computing devices used in one embodiment of the present invention.
도 3은 본 발명의 일 실시예에 따라 콘볼루션 연산을 실행할 때에 사용되는 대상 어레이, 커널, 가변 어레이의 개념을 나타낸 것이다.Figure 3 shows the concepts of a target array, kernel, and variable array used when executing a convolution operation according to an embodiment of the present invention.
도 4는 미리 결정된 대상 어레이와 커널을 이용하여 콘볼루션 연산을 수행하는 방법의 개념을 설명하는 도면이다.Figure 4 is a diagram explaining the concept of a method of performing a convolution operation using a predetermined target array and kernel.
도 5a, 도 5b, 도 5c, 및 도 5d는 본 발명의 일 실시예에 따라 제공되는 콘볼루션 연산 방법을 나타낸 순서도이다. FIGS. 5A, 5B, 5C, and 5D are flowcharts showing a convolution operation method provided according to an embodiment of the present invention.
도 6은 도 5a, 도 5b, 도 5c, 및 도 5d에 제시한 본 발명의 일 실시예에 따라 제공되는 콘볼루션 연산 방법의 실제 사례를 나타낸 것이다. Figure 6 shows an actual example of the convolution operation method provided according to an embodiment of the present invention shown in Figures 5a, 5b, 5c, and 5d.
도 7은 본 발명의 일 실시예에 따라 풀링 연산을 실행할 때에 사용되는 대상 어레이, 가변 어레이의 개념을 나타낸 것이다.Figure 7 shows the concepts of a target array and a variable array used when performing a pooling operation according to an embodiment of the present invention.
도 8은 미리 결정된 대상 어레이를 풀링 윈도우를 이용하여 풀링 연산을 수행하는 방법의 개념을 설명하는 도면이다.Figure 8 is a diagram explaining the concept of a method of performing a pooling operation on a predetermined target array using a pooling window.
도 9a, 도 9b, 도 9c, 및 도 9d는 본 발명의 일 실시예에 따라 제공되는 풀링 연산 방법을 나타낸 순서도이다. FIGS. 9A, 9B, 9C, and 9D are flowcharts showing a pooling operation method provided according to an embodiment of the present invention.
도 10은 도 9a, 도 9b, 도 9c, 및 도 9d에 제시한 본 발명의 일 실시예에 따라 제공되는 풀링 연산 방법의 실제 사례를 나타낸 것이다. Figure 10 shows an actual example of the pooling operation method provided according to an embodiment of the present invention shown in Figures 9a, 9b, 9c, and 9d.
도 11a는 본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 실행을 위해 필요한 3개의 변수를 초기화하는 과정을 나타낸다.Figure 11a shows the process of initializing three variables required for execution of the first instruction provided according to an embodiment of the present invention.
도 11b는 본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 1회 실행 과정을 나타낸 순서도이다. Figure 11b is a flowchart showing a one-time execution process of the first instruction provided according to an embodiment of the present invention.
도 12a는 본 발명의 다른 실시예에 따라 제공되는 제2인스트럭션의 실행을 위해 필요한 4개의 변수를 초기화하는 과정을 나타낸다.Figure 12a shows the process of initializing four variables required for execution of the second instruction provided according to another embodiment of the present invention.
도 12b는 본 발명의 상기 다른 실시예에 따라 제공되는 제2인스트럭션의 1회 실행 과정을 나타낸 순서도이다. Figure 12b is a flowchart showing a one-time execution process of the second instruction provided according to another embodiment of the present invention.
이하, 본 발명의 실시예를 첨부한 도면을 참고하여 설명한다. 그러나 본 발명은 본 명세서에서 설명하는 실시예에 한정되지 않으며 여러 가지 다른 형태로 구현될 수 있다. 본 명세서에서 사용되는 용어는 실시예의 이해를 돕기 위한 것이며, 본 발명의 범위를 한정하고자 의도된 것이 아니다. 또한, 이하에서 사용되는 단수 형태들은 문구들이 이와 명백히 반대의 의미를 나타내지 않는 한 복수 형태들도 포함한다.Hereinafter, embodiments of the present invention will be described with reference to the attached drawings. However, the present invention is not limited to the embodiments described herein and may be implemented in various other forms. The terms used in this specification are intended to aid understanding of the embodiments and are not intended to limit the scope of the present invention. Additionally, as used herein, singular forms include plural forms unless phrases clearly indicate the contrary.
도 2는 본 발명의 일 실시예에서 이용되는 컴퓨팅 장치 중 일부의 주요 구조를 나타낸 것이다.Figure 2 shows the main structure of some of the computing devices used in one embodiment of the present invention.
컴퓨팅 장치(1)는, DRAM(Dynamic Random Access Memory)(130), 하드웨어 가속기(110), DRAM(130)와 하드웨어 가속기(110)를 연결하는 버스(700), 및 버스(700)에 연결된 타 하드웨어들(99) 및 메인 프로세서(160)를 포함할 수 있다. The computing device 1 includes a dynamic random access memory (DRAM) 130, a hardware accelerator 110, a bus 700 connecting the DRAM 130 and the hardware accelerator 110, and other devices connected to the bus 700. It may include hardware 99 and a main processor 160.
그 밖에 컴퓨팅 장치(1)는 도시되지 않은 전원부, 통신부, 사용자 인터페이스, 저장부(170), 및 주변 장치부들을 더 포함할 수 있다. 버스(700)는 상기 하드웨어 가속기(110)와 타 하드웨어들(99), 그리고 메인 프로세서(160)가 공유할 수도 있다.In addition, the computing device 1 may further include a power supply unit, a communication unit, a user interface, a storage unit 170, and peripheral device units not shown. The bus 700 may be shared by the hardware accelerator 110, other hardware 99, and the main processor 160.
상기 저장부(170)는 상기 컴퓨팅 장치(1)에 일체로 결합된 것일 수도 있고, 착탈 가능하게 결합된 것일 수도 있다.The storage unit 170 may be integrally coupled to the computing device 1 or may be detachably coupled to the computing device 1.
상기 하드웨어 가속기(110)는 DMA부(Direct Memory Access part)(20), 제어부(40), 내부 메모리(30), 입력버퍼(650), 데이터 연산부(610), 및 출력버퍼(640)를 포함할 수 있다. The hardware accelerator 110 includes a DMA unit (Direct Memory Access part) 20, a control unit 40, an internal memory 30, an input buffer 650, a data operation unit 610, and an output buffer 640. can do.
내부 메모리(30)에 임시 저장되는 데이터의 일부 또는 전부는 버스(700)를 통해 DRAM(130)으로부터 제공될 수 있다. 이때, DRAM(130)에 저장되어 있는 데이터를 내부 메모리(30)로 이동시키기 위하여, 제어부(40)와 DMA부(20)가 내부 메모리(30) 및 DRAM(130)을 제어할 수도 있다.Some or all of the data temporarily stored in the internal memory 30 may be provided from the DRAM 130 through the bus 700. At this time, in order to move data stored in the DRAM 130 to the internal memory 30, the control unit 40 and the DMA unit 20 may control the internal memory 30 and the DRAM 130.
내부 메모리(30)에 저장되어 있던 데이터는 입력버퍼(650)를 통해 데이터 연산부(610)에게 제공될 수 있다. Data stored in the internal memory 30 may be provided to the data calculation unit 610 through the input buffer 650.
상기 데이터 연산부(610)가 동작하여 생성된 출력값들은 출력버퍼(640)을 거쳐 상기 내부 메모리(30)에 저장될 수 있다. 상기 내부 메모리(30)에 저장된 상기 출력값들은 제어부(40) 및 DMA부(20)의 제어에 의해 DRAM(130)에 기록될 수도 있다. Output values generated by the operation of the data calculation unit 610 may be stored in the internal memory 30 through the output buffer 640. The output values stored in the internal memory 30 may be written to the DRAM 130 under the control of the control unit 40 and the DMA unit 20.
제어부(40)는 DMA부(20), 내부 메모리(30), 및 상기 데이터 연산부(610)의 동작을 총괄하여 제어할 수 있다.The control unit 40 can collectively control the operations of the DMA unit 20, the internal memory 30, and the data operation unit 610.
일 구현 예에서, 상기 데이터 연산부(610)는 제1시구간 동안에는 제1연산기능을 수행하고 제2시구간 동안에는 제2연산기능을 수행할 수 있다. In one implementation example, the data calculation unit 610 may perform a first calculation function during a first time period and a second calculation function during a second time period.
도 2에는, 상기 데이터 연산부(610)는 상기 하드웨어 가속기(110) 내에 1개가 제시되어 있다. 그러나 도시하지 않은 변형된 일 실시예에서, 도 2에 나타낸 상기 데이터 연산부(610)는 상기 하드웨어 가속기(110) 내에 복수 개 제공되어 각각 제어부(40)에 의해 요청된 연산을 병렬적으로 수행할 수도 있다.In FIG. 2, one data operation unit 610 is shown within the hardware accelerator 110. However, in a modified embodiment not shown, a plurality of data calculation units 610 shown in FIG. 2 may be provided in the hardware accelerator 110 to perform operations requested by the control unit 40 in parallel. there is.
일 구현 예에서, 상기 데이터 연산부(610)는 그 출력데이터를 한 번에 출력하지 않고 시간에 따라 주어진 순서에 따라 순차적으로 출력할 수 있다.In one implementation example, the data calculation unit 610 may output the output data sequentially according to a given order over time, rather than all at once.
<실시예 - 콘볼루션 연산><Example - convolution operation>
도 3은 본 발명의 일 실시예에 따라 콘볼루션 연산을 실행할 때에 사용되는 대상 어레이, 커널, 가변 어레이의 개념을 나타낸 것이다.Figure 3 shows the concepts of a target array, kernel, and variable array used when executing a convolution operation according to an embodiment of the present invention.
참조번호 80은 메모리에 저장된 데이터인 메모리 데이터(80)를 예시한 것이다. 참조번호 80에서 첫 번째 행(row)은 메모리의 주소를 나타내며, 두 번째 행은 해당 주소에 저장된 데이터의 값을 나타낸다. 예컨대 'v0', 'v1' 등은 각각 한 개의 데이터일 수 있다. 상기 메모리는 도 2에 도시한 상기 DRAM(130) 또는 상기 내부 메모리(30)일 수 있다. Reference number 80 illustrates memory data 80, which is data stored in memory. In reference number 80, the first row represents the address of the memory, and the second row represents the value of the data stored at that address. For example, 'v0', 'v1', etc. may each be one piece of data. The memory may be the DRAM 130 or the internal memory 30 shown in FIG. 2.
참조번호 81은 상기 메모리에서 추출하여 읽은 데이터로서 콘볼루션 연산의 대상이 되는 대상 어레이(81)이다. 상기 대상 어레이(81)에서 첫 번째 행은 상기 대상 어레이(81)의 인덱스를 나타내며, 두 번째 행은 해당 인덱스에 저장된 데이터의 값을 나타낸다. 예컨대, 상기 대상 어레이(81)를 구성하는 값들은 예컨대 상기 DRAM(130)에서 읽은 것으로서, 상기 내부 메모리(30)에 저장된 것일 수 있다. Reference number 81 is data extracted and read from the memory and is the target array 81 that is the target of the convolution operation. In the target array 81, the first row represents the index of the target array 81, and the second row represents the value of data stored at the index. For example, the values constituting the target array 81 may be read from the DRAM 130 and stored in the internal memory 30 .
상기 대상 어레이(81)의 인덱스들은 각각, 상기 대상 어레이(81)에 대응하는 메모리 데이터(80)의 일 부분의 주소들에 각각 대응할 수 있다. The indices of the target array 81 may each correspond to addresses of portions of the memory data 80 corresponding to the target array 81.
참조번호 90은 콘볼루션 연산을 위해 사용되는 값들로 구성된 커널(90)이다. 상기 커널(90)에서 첫 번째 행은 상기 커널(90)의 인덱스를 나타내며, 두 번째 행은 해당 인덱스에 저장된 데이터의 값을 나타낸다. 일 실시예에서, 상기 커널(90)을 구성하는 값들은 미리 결정된 상수값일 수 있다. 예컨대, 상기 커널(90)을 구성하는 값들은 예컨대 상기 DRAM(130)에서 읽은 것으로서, 상기 내부 메모리(30)에 저장된 것일 수 있다. Reference number 90 is a kernel 90 composed of values used for convolution operations. In the kernel 90, the first row represents the index of the kernel 90, and the second row represents the value of data stored at the index. In one embodiment, the values constituting the kernel 90 may be predetermined constant values. For example, the values constituting the kernel 90 may be read from the DRAM 130 and stored in the internal memory 30 .
참조번호 70는 상기 커널(90)와 실제로 연산되는 값들이 저장된 가변 어레이(70)이다. 상기 가변 어레이(70)에서 첫 번째 행은 상기 가변 어레이(70)의 인덱스를 나타내며, 두 번째 행은 해당 인덱스에 저장된 데이터의 값을 나타낸다. 상기 가변 어레이(70)를 구성하는 값들은 모두 상기 대상 어레이(81)로부터 획득된 것일 수 있다. 또는, 상기 가변 어레이(70)를 구성하는 값들 중 일부는 소정의 패딩값으로 이루어지고 나머지는 상기 대상 어레이(81)로부터 획득된 것일 수 있다. 상기 패딩값은 예컨대 '0'과 같은 미리 결정된 값일 수 있다. Reference number 70 is a variable array 70 in which the kernel 90 and values actually operated are stored. In the variable array 70, the first row represents the index of the variable array 70, and the second row represents the value of data stored at the index. All values constituting the variable array 70 may be obtained from the target array 81. Alternatively, some of the values constituting the variable array 70 may be composed of predetermined padding values, and the remainder may be obtained from the target array 81. The padding value may be a predetermined value such as '0'.
참조번호 60은 상기 대상 어레이(81)를 상기 커널(90)을 이용하여 콘볼루션 연산하여 생성하게 되는 데이터인 출력 어레이(60)를 나타낸 것이다. 출력 어레이(60)의 크기는 실행해야 할 콘볼루션 연산 방법의 구체적인 정의에 따라 결정될 수 있다. Reference number 60 denotes the output array 60, which is data generated by performing a convolution operation on the target array 81 using the kernel 90. The size of the output array 60 may be determined according to the specific definition of the convolution operation method to be executed.
본 발명의 일 실시에에서, 상기 커널(90)을 이용한 연산을 수행할 때에, 상기 커널(90)의 인덱스를 참조하여 얻은 데이터와 상기 가변 어레이(70)의 인덱스를 참조하여 얻은 데이터를 연산에 사용할 수 있다. In one embodiment of the present invention, when performing an operation using the kernel 90, data obtained by referring to the index of the kernel 90 and data obtained by referring to the index of the variable array 70 are used in the operation. You can use it.
상기 가변 어레이(70) 및 상기 커널(90)의 크기는 상기 대상 어레이(81)의 크기보다 작을 수 있다.The size of the variable array 70 and the kernel 90 may be smaller than the size of the target array 81.
도 4는 미리 결정된 대상 어레이와 커널을 이용하여 콘볼루션 연산을 수행하는 방법의 개념을 설명하는 도면이다.Figure 4 is a diagram explaining the concept of a method of performing a convolution operation using a predetermined target array and kernel.
도 4에서, 설명의 편의를 위하여, 상기 미리 결정된 대상 어레이 및 커널로서 도 3에 제시한 대상 어레이(81) 및 커널(90)을 제시하였다. 이때, 커널(90)의 크기는 4이다. In FIG. 4 , for convenience of explanation, the target array 81 and kernel 90 shown in FIG. 3 are presented as the predetermined target array and kernel. At this time, the size of the kernel 90 is 4.
상기 콘볼루션 연산을 스텝 21 내지 스텝 28의 총 8회의 스텝으로 구성될 수 있다. 각 스텝마다 상기 커널(90)의 대상 어레이(81)에 대한 상대적인 위치는 스트라이드 1만큼 변경될 수 있다. The convolution operation may consist of a total of 8 steps, from steps 21 to 28. For each step, the relative position of the kernel 90 with respect to the target array 81 may be changed by stride 1.
각 스텝에서 대상 어레이(81)와 커널(90)의 데이터는 적어도 한 개 이상이 서로 대응될 수 있다. 이때, 서로 대응되는 대상 어레이(81)의 데이터와 커널(90)의 데이터는 서로 곱하는 연산에 이용될 수 있다. 각 스텝마다, 커널(90)의 크기와 동일한 4회의 곱셈 연산이 수행될 수 있다. 만일, 각 스텝에서 커널(90)의 특정 데이터에 대응하는 대상 어레이(81)이 데이터가 정의되지 않을 때(=존재하지 않을 때)에, 상기 커널(90)의 특정 데이터에는 소정의 미리 결정된 값인 패딩값(vp)이 곱해질 수 있다. 상기 패딩값(vp)은 예컨대 1일 수도 있다.In each step, at least one piece of data of the target array 81 and the kernel 90 may correspond to each other. At this time, the data of the target array 81 and the data of the kernel 90 that correspond to each other can be used in a multiplication operation. For each step, four multiplication operations equal to the size of the kernel 90 may be performed. If the target array 81 corresponding to the specific data of the kernel 90 in each step is not defined (= does not exist), the specific data of the kernel 90 has a predetermined value. The padding value (vp) can be multiplied. The padding value (vp) may be, for example, 1.
스텝 21에서, 커널(90)의 데이터 p3는 대상 어레이(81)의 데이터 v1 에 대응한다. 그러나 커널(90)의 데이터 p0, p1, p2에 대응하는 대상 어레이(81)이 데이터는 정의되지 않는다. 이때, 스텝 21에 의해 생성되는 콘볼루션 연산 데이터는 co[0]= p0*vp + p1*vp + p2*vp + p3*v1 이다. In step 21, data p3 of kernel 90 corresponds to data v1 of target array 81. However, the data of the target array 81 corresponding to the data p0, p1, and p2 of the kernel 90 is not defined. At this time, the convolution operation data generated by step 21 is co[0]= p0*vp + p1*vp + p2*vp + p3*v1.
스텝 22에서, 커널(90)의 데이터 p2, p3는 대상 어레이(81)의 데이터 v1, v2에 각각 대응한다. 그러나 커널(90)의 데이터 p0, p1에 대응하는 대상 어레이(81)이 데이터는 정의되지 않는다. 이때, 스텝 22에 의해 생성되는 콘볼루션 연산 데이터는 co[1]= p0*vp + p1*vp + p2*v1 + p3*v2 이다. In step 22, data p2 and p3 of the kernel 90 correspond to data v1 and v2 of the target array 81, respectively. However, the data of the target array 81 corresponding to the data p0 and p1 of the kernel 90 is not defined. At this time, the convolution operation data generated by step 22 is co[1]= p0*vp + p1*vp + p2*v1 + p3*v2.
스텝 23에서, 커널(90)의 데이터 p1, p2, p3는 대상 어레이(81)의 데이터 v1, v2, v3에 각각 대응한다. 그러나 커널(90)의 데이터 p0에 대응하는 대상 어레이(81)이 데이터는 정의되지 않는다. 이때, 스텝 23에 의해 생성되는 콘볼루션 연산 데이터는 co[2]= p0*vp + p1*v1 + p2*v2 + p3*v3 이다. In step 23, data p1, p2, and p3 of kernel 90 correspond to data v1, v2, and v3 of target array 81, respectively. However, the data of the target array 81 corresponding to data p0 of the kernel 90 is not defined. At this time, the convolution operation data generated by step 23 is co[2]= p0*vp + p1*v1 + p2*v2 + p3*v3.
스텝 24에서, 커널(90)의 데이터 p0, p1, p2, p3는 대상 어레이(81)의 데이터 v1, v2, v3, v4에 각각 대응한다. 이때, 스텝 24에 의해 생성되는 콘볼루션 연산 데이터는 co[3]= p0*v1 + p1*v2 + p2*v3 + p3*v4 이다. In step 24, data p0, p1, p2, and p3 of kernel 90 correspond to data v1, v2, v3, and v4 of target array 81, respectively. At this time, the convolution operation data generated by step 24 is co[3]=p0*v1 + p1*v2 + p2*v3 + p3*v4.
스텝 25에서, 커널(90)의 데이터 p0, p1, p2, p3는 대상 어레이(81)의 데이터 v2, v3, v4, v5에 각각 대응한다. 이때, 스텝 25에 의해 생성되는 콘볼루션 연산 데이터는 co[4]= p0*v2 + p1*v3 + p2*v4 + p3*v5 이다. In step 25, data p0, p1, p2, and p3 of kernel 90 correspond to data v2, v3, v4, and v5 of target array 81, respectively. At this time, the convolution operation data generated by step 25 is co[4]=p0*v2 + p1*v3 + p2*v4 + p3*v5.
스텝 26에서, 커널(90)의 데이터 p0, p1, p2는 대상 어레이(81)의 데이터 v3, v4, v5에 각각 대응한다. 그러나 커널(90)의 데이터 p3에 대응하는 대상 어레이(81)이 데이터는 정의되지 않는다. 이때, 스텝 26에 의해 생성되는 콘볼루션 연산 데이터는 co[5]= p0*v3 + p1*v4 + p2*v5 + p3*vp 이다. In step 26, data p0, p1, and p2 of kernel 90 correspond to data v3, v4, and v5 of target array 81, respectively. However, the data of the target array 81 corresponding to data p3 of the kernel 90 is not defined. At this time, the convolution operation data generated in step 26 is co[5]=p0*v3 + p1*v4 + p2*v5 + p3*vp.
스텝 27에서, 커널(90)의 데이터 p0, p1는 대상 어레이(81)의 데이터 v4, v5에 각각 대응한다. 그러나 커널(90)의 데이터 p2, p3에 대응하는 대상 어레이(81)이 데이터는 정의되지 않는다. 이때, 스텝 27에 의해 생성되는 콘볼루션 연산 데이터는 co[6]= p0*v4 + p1*v5 + p2*vp + p3*vp 이다. In step 27, data p0 and p1 of the kernel 90 correspond to data v4 and v5 of the target array 81, respectively. However, the data of the target array 81 corresponding to data p2 and p3 of the kernel 90 is not defined. At this time, the convolution operation data generated by step 27 is co[6]= p0*v4 + p1*v5 + p2*vp + p3*vp.
스텝 28에서, 커널(90)의 데이터 p0는 대상 어레이(81)의 데이터 v5에 대응한다. 그러나 커널(90)의 데이터 p1, p2, p3에 대응하는 대상 어레이(81)이 데이터는 정의되지 않는다. 이때, 스텝 28에 의해 생성되는 콘볼루션 연산 데이터는 co[7]= p0*v5 + p1*vp + p2*vp + p3*vp 이다. In step 28, data p0 of kernel 90 corresponds to data v5 of target array 81. However, the target array 81 data corresponding to the data p1, p2, and p3 of the kernel 90 is not defined. At this time, the convolution operation data generated by step 28 is co[7]=p0*v5 + p1*vp + p2*vp + p3*vp.
본 발명의 일 실시예에 따라 제공되는 콘볼루션 연산 방법에서는 '좌측 패딩의 최대 개수'라는 값 및 '우측 패딩의 최대 개수'라는 값이 정의된다. In the convolution operation method provided according to an embodiment of the present invention, the values 'maximum number of left padding' and 'maximum number of right padding' are defined.
상기 콘볼루션 연산 방법의 실행과정 중 첫 번째 스텝(스텝 21)에 있어서, 커널(90)의 데이터 중 대상 어레이의 값에 대응되지 않는 데이터(ex: p0, p1, p2)의 개수를 좌측 패딩의 최대 개수라고 정의한다. 도 4에 제시한 콘볼루션 연산 방법의 예에서 상기 좌측 패딩의 최대 개수는 3으로 결정된다.In the first step (step 21) of the execution process of the convolution operation method, the number of data (ex: p0, p1, p2) that does not correspond to the value of the target array among the data of the kernel 90 is calculated as the number of left padding. It is defined as the maximum number. In the example of the convolution operation method shown in FIG. 4, the maximum number of left paddings is determined to be 3.
상기 콘볼루션 연산 방법의 실행 과정 중 마지막 스텝(스텝 28)에 있어서, 커널(90)의 데이터 중 대상 어레이의 값에 대응되지 않는 데이터(ex: p1, p2, p3)의 개수를 우측 패딩의 최대 개수라고 정의할 수 있다. 도 4에 제시한 콘볼루션 연산 방법의 예에서 상기 우측 패딩의 최대 개수는 3으로 결정된다.In the last step (step 28) of the execution process of the convolution operation method, the number of data (ex: p1, p2, p3) that does not correspond to the value of the target array among the data of the kernel 90 is set to the maximum right padding. It can be defined as a number. In the example of the convolution operation method shown in FIG. 4, the maximum number of right paddings is determined to be 3.
상술한 바와 같이 상기 좌측 패딩의 최대 개수가 3이고, 상기 우측 패딩의 최대 개수가 3이며, 그리고 스트라이드가 1인 경우, 상기 출력 어레이(60)의 크기는 8로 결정된다. As described above, when the maximum number of left paddings is 3, the maximum number of right paddings is 3, and the stride is 1, the size of the output array 60 is determined to be 8.
도 5a, 도 5b, 도 5c, 및 도 5d는 본 발명의 일 실시예에 따라 제공되는 콘볼루션 연산 방법을 나타낸 순서도이다. 도 5a, 도 5b, 도 5c, 및 도 5d를 통칭하여 도 5라고 지칭할 수 있다.FIGS. 5A, 5B, 5C, and 5D are flowcharts showing a convolution operation method provided according to an embodiment of the present invention. FIGS. 5A, 5B, 5C, and 5D may be collectively referred to as FIG. 5.
이하 도 3, 도 4, 및 도 5를 함께 참조하여 설명한다. Hereinafter, the description will be made with reference to FIGS. 3, 4, and 5.
단계(S110)에서, 상기 메인 프로세서(160) 또는 제어부(40)는 메모리의 주소들 중 대상 어레이(81)가 저장되어 있는 시작주소와 종료주소를 획득할 수 있다. In step S110, the main processor 160 or the control unit 40 may obtain the start address and end address where the target array 81 is stored among the addresses of the memory.
여기서, 상기 대상 어레이(81)는 상기 메모리에 저장되어 있는 데이터 중 본 발명에 의한 연산의 대상이 되는 데이터의 집합을 의미할 수 있다. 그리고 상기 대상 어레이(81)를 구성하는 데이터들은 연속적인 메모리 주소들에 저장된 것일 수 있다. 예컨대 도 3의 대상 어레이(81)을 구성하는 데이터들은 상기 메모리의 주소 1 내지 5에 저장된 것일 수 있다.Here, the target array 81 may refer to a set of data that is the target of an operation according to the present invention among data stored in the memory. And the data constituting the target array 81 may be stored in consecutive memory addresses. For example, data constituting the target array 81 of FIG. 3 may be stored in addresses 1 to 5 of the memory.
이때, 상기 대상 어레이(81)에 포함된 데이터들 중 서로 인접한 2개의 데이터의 위치를 나타내는 2개의 주소들의 값들은 1만큼의 차이값을 가질 수 있다. 만일 서로 인접한 2개의 데이터의 위치를 나타내는 2개의 주소들의 값들이 k라는 크기의 차이값을 갖는다면, 상기 k는 1이라는 값으로 정규화되어 사용될 수 있다. 즉, 본 발명에서 상기 대상 어레이에 포함된 인접한 2개의 데이터들의 주소값의 차이값은 1인 것으로 정의한다. 예컨대 도 3에서 참조번호 80으로 제시한 데이터에 있어서, 데이터 v1과 이와 인접한 데이터 v2가 각각 저장된 주소의 실제 값은 addr1 및 addr2일 수 있고, 이때 addr2에서 addr1을 차감한 실제값은 1이 아닐 수 있다. 그러나 도 3에 제시하였듯이, 이 경우 본 발명의 일 실시예에서는 addr2에서 addr1을 차감한 실제값이 1이라는 스케일로 환산된 것으로 간주할 수 있다.At this time, the values of two addresses indicating the locations of two adjacent pieces of data among the data included in the target array 81 may have a difference of 1. If the values of two addresses indicating the locations of two adjacent data have a difference value of size k, k can be normalized to the value of 1 and used. That is, in the present invention, the difference between the address values of two adjacent pieces of data included in the target array is defined as 1. For example, in the data shown by reference number 80 in FIG. 3, the actual values of the addresses where data v1 and adjacent data v2 are stored, respectively, may be addr1 and addr2, and in this case, the actual value obtained by subtracting addr1 from addr2 may not be 1. there is. However, as shown in FIG. 3, in this case, in one embodiment of the present invention, the actual value obtained by subtracting addr1 from addr2 can be considered to be converted to a scale of 1.
상기 대상 어레이(81)는 본 명세서에서 제3어레이라고 지칭할 수도 있다.The target array 81 may also be referred to as a third array in this specification.
한편, 본 발명의 일 실시예에 따른 콘볼루션 연산방법에 있어서, 소스인덱스(s_idx), 엘패드(lpad), 밸리드(valid), 및 알패드(rpad)의 4가지 변수가 정의되어 사용된다. Meanwhile, in the convolution operation method according to an embodiment of the present invention, four variables are defined and used: source index (s_idx), lpad, valid, and rpad. .
또한, 본 발명의 일 실시예에 따른 콘볼루션 연산방법에 있어서, 가변 어레이 포인터(제1포인터) 및 출력 어레이 포인터(제2포인터)라는 2개의 포인터가 더 정의될 수 있다. Additionally, in the convolution operation method according to an embodiment of the present invention, two pointers, a variable array pointer (first pointer) and an output array pointer (second pointer), may be further defined.
본 발명의 일 실시예에 따른 콘볼루션 연산방법을 구현하는데 사용되는 컴퓨팅 장치는, 소스인덱스(s_idx), 엘패드(lpad), 밸리드(valid), 및 알패드(rpad)의 값을 각각 저장하는 레지스터인 소스인덱스 레지스터(s_idx_reg), 엘패드 레지스터(lpad_reg), 밸리드 레지스터(valid_reg), 및 알패드 레지스터(rpad_reg)를 메모리 공간에 할당할 수 있다. 상기 각각의 레지스터에 특정 값을 저장하면, 이에 대응하는 변수에 상기 특정 값이 부여된 것으로 볼 수 있다. 상기 각각의 레지스터에 저장된 값이 변경되면, 이에 대응하는 변수의 값이 변경된 것으로 볼 수 있다. 그리고 상기 각각의 변수의 값을 변경하고자 한다면, 이에 대응하는 레지스터에 저장된 값을 변경한다. The computing device used to implement the convolution operation method according to an embodiment of the present invention stores the values of source index (s_idx), lpad, valid, and rpad, respectively. The source index register (s_idx_reg), Lpad register (lpad_reg), valid register (valid_reg), and Rpad register (rpad_reg), which are registers, can be allocated to the memory space. When a specific value is stored in each register, the specific value can be viewed as being assigned to the corresponding variable. When the value stored in each register is changed, the value of the corresponding variable can be viewed as changed. And if you want to change the value of each variable, change the value stored in the corresponding register.
단계(S120)에서 컴퓨팅 장치는 초기화 작업을 수행할 수 있다. 상기 초기화 작업은 아래에 나열한 작업들을 포함한다.In step S120, the computing device may perform an initialization operation. The initialization task includes the tasks listed below.
첫째, 상기 소스인덱스(s_idx)에 상기 대상 어레이의 첫 번째 인덱스를 할당(assign, 부여)할 수 있다. 상기 대상 어레이의 첫 번째 인덱스는 상기 대상 어레이의 첫 번째 데이터가 저장되어 있는 상기 메모리의 주소일 수 있다. 도 3 및 도 4의 예에서 상기 대상 어레이(81)의 첫 번째 인덱스는 '1'이다(s_idx=1).First, the first index of the target array can be assigned to the source index (s_idx). The first index of the target array may be an address of the memory where the first data of the target array is stored. In the examples of FIGS. 3 and 4, the first index of the target array 81 is '1' (s_idx=1).
둘째, 상기 엘패드(lpad)에 미리 계획된 콘볼루션 연산에서 이용되는 상기 좌측 패딩의 최대 개수를 할당할 수 있다. 도 3 및 도 4의 예에서 상기 좌측 패딩의 최대 개수는 3이다(lpad=3). Second, the maximum number of left paddings used in a pre-planned convolution operation can be assigned to lpad. In the examples of Figures 3 and 4, the maximum number of left paddings is 3 (lpad=3).
셋째, 상기 밸리드(valid)에 상기 대상 어레이의 크기를 할당할 수 있다. 도 3 및 도 4의 예에서 상기 대상 어레이의 크기는 5이다(valid=5). Third, the size of the target array can be assigned to the valid. In the examples of FIGS. 3 and 4, the size of the target array is 5 (valid=5).
넷째, 상기 알패드(rpad)에 상기 계획된 콘볼루션 연산에서 이용되는 우측 패딩의 최대 개수를 할당할 수 있다. 도 3 및 도 4의 예에서 상기 우측 패딩의 최대 개수는 3이다(rpad=3). Fourth, the maximum number of right paddings used in the planned convolution operation can be assigned to the rpad. In the examples of Figures 3 and 4, the maximum number of right paddings is 3 (rpad=3).
다섯째, 상기 커널(90)와 동일한 크기의 가변 어레이(제2어레이)(70)를 준비할 수 있다. 즉, 상기 컴퓨팅 장치는 상기 가변 어레이(70)를 위한 메모리 공간을 할당할 수 있다. 도 3의 예에서 상기 가변 어레이(70)의 크기는 4이다. 상기 가변 어레이(70)는 본 명세서에서 제2어레이라고 지칭될 수 있다. Fifth, a variable array (second array) 70 of the same size as the kernel 90 can be prepared. That is, the computing device can allocate memory space for the variable array 70. In the example of FIG. 3, the size of the variable array 70 is 4. The variable array 70 may be referred to as a second array in this specification.
여섯째, 상기 가변 어레이 포인터(제1포인터)가 상기 가변 어레이(70)의 첫 번째 인덱스를 가리키도록 상기 제1포인터의 값을 초기화 할 수 있다. 도 3의 예에서 상기 제1포인터는 상기 가변 어레이(70)의 첫 번째 인덱스인 인덱스 1을 가리키도록 초기화될 수 있다. Sixth, the value of the first pointer may be initialized so that the variable array pointer (first pointer) points to the first index of the variable array 70. In the example of FIG. 3, the first pointer may be initialized to point to index 1, which is the first index of the variable array 70.
일곱째, 상기 출력 어레이 포인터(제2포인터)가 미리 준비된 출력 어레이(60)의 첫 번째 인덱스를 가리키도록 상기 제2포인터의 값을 초기화할 수 있다. 도 3의 예에서 상기 제2포인터는 상기 출력 어레이(60)의 첫 번째 인덱스인 인덱스 0을 가리키도록 초기화될 수 있다. Seventh, the value of the output array pointer (second pointer) can be initialized so that it points to the first index of the output array 60 prepared in advance. In the example of FIG. 3, the second pointer may be initialized to point to index 0, which is the first index of the output array 60.
단계(S130)에서, 상기 엘패드(lpad)가 0보다 큰지 여부를 판단한다. 상기 엘패드(lpad)가 0보다 크면 단계(S210)으로 진행하고, 그렇지 않으면 단계(S310)로 진행한다. In step S130, it is determined whether lpad is greater than 0. If lpad is greater than 0, the process proceeds to step S210. Otherwise, the process proceeds to step S310.
단계(S310)에서, 상기 밸리드(valid)가 0보다 큰지 여부를 판단한다. 상기 밸리드(valid)가 0보다 크면 단계(S320)로 진행하고, 그렇지 않으면 단계(S410)로 진행한다.In step S310, it is determined whether the valid is greater than 0. If the valid is greater than 0, the process proceeds to step S320. Otherwise, the process proceeds to step S410.
도 5b를 살펴보면, 단계(S210)에서, 상기 가변 어레이(70) 중 상기 가변 어레이 포인터가 가리키는 자리에 미리 결정된 패딩값(vp)을 저장할 수 있다.Referring to FIG. 5B, in step S210, a predetermined padding value (vp) may be stored in the position indicated by the variable array pointer in the variable array 70.
단계(S220)에서, 상기 엘패드(lpad)를 제1값만큼 감소시킬 수 있다. 상기 제1값은 예컨대 1일 수 있다. In step S220, lpad may be decreased by a first value. The first value may be, for example, 1.
단계(S230)에서, 상기 가변 어레이 포인터(제1포인터)의 값을 워드 사이즈(word size)만큼 증가시킬 수 있다. 그리고 이때 상기 증가는 순환 증가일 수 있다. 그리고 다시 도 5a의 단계(S130)로 되돌아 갈 수 있다. In step S230, the value of the variable array pointer (first pointer) may be increased by the word size. And at this time, the increase may be a circulation increase. Then, the process may return to step S130 of FIG. 5A.
여기서 상기 순환 증가라는 것은, 상기 제1포인터가 현재 상기 가변 어레이(70)의 마지막 인덱스를 가리키고 있다면, 상기 제1포인터가 상기 가변 어레이(70)의 첫 번째 인덱스를 가리키도록 하는 것을 의미한다. 상기 첫 번째 인덱스의 값보다 상기 마지막 인덱스의 값이 더 크다.Here, the cyclic increase means that if the first pointer currently points to the last index of the variable array 70, the first pointer points to the first index of the variable array 70. The value of the last index is greater than the value of the first index.
도 5c를 살펴보면, 단계(S320)에서 상기 가변 어레이(70) 중 상기 가변 어레이 포인터(제1포인터)가 가리키는 자리에, 상기 소스인덱스(s_idx)가 가리키는 대상 어레이(81)의 값을 저장할 수 있다. Referring to FIG. 5C, in step S320, the value of the target array 81 pointed to by the source index (s_idx) can be stored in the position pointed to by the variable array pointer (first pointer) of the variable array 70. .
단계(S330)에서, 상기 밸리드(valid)를 제2값만큼 감소시키고 상기 소스인덱스(s_idx)를 제3값만큼 증가시킬 수 있다. In step S330, the valid may be decreased by a second value and the source index (s_idx) may be increased by a third value.
상기 제2값은 예컨대 1일 수 있다. 상기 제3값은 상기 메모리의 일 영역 중 서로 인접한 두 개의 데이터를 나타내는 주소들 간의 차이값일 수 있다.The second value may be, for example, 1. The third value may be a difference value between addresses representing two adjacent pieces of data in one area of the memory.
단계(S340)에서, 상기 가변 어레이(70)와 상기 커널(90)을 연산한 값을, 상기 출력 어레이(60) 중 상기 출력 어레이 포인터(제2포인터)가 가리키는 자리에 저장할 수 있다. 이때, 상기 연산은 콘볼루션 연산일 수 있다. In step S340, the calculated value of the variable array 70 and the kernel 90 may be stored in the position pointed to by the output array pointer (second pointer) of the output array 60. At this time, the operation may be a convolution operation.
단계(S350)에서, 상기 가변 어레이 포인터(제1포인터)의 값을 워드 사이즈만큼 순환 증가시키고, 상기 출력 어레이 포인터(제2포인터)를 워드 사이즈만큼 증가시킬 수 있다. 그리고 다시 도 5a의 단계(S130)로 되돌아 갈 수 있다. In step S350, the value of the variable array pointer (first pointer) may be cyclically increased by the word size, and the output array pointer (second pointer) may be increased by the word size. Then, the process may return to step S130 of FIG. 5A.
도 5d를 살펴보면, 단계(S410)에서 상기 알패드(rpad)가 1보다 큰지 여부를 결정할 수 있다. 상기 알패드(rpad)가 1보다 크면 단계(S420)로 진행하고, 그렇지 않으면 상기 콘볼루션 연산 방법을 종료한다.Referring to FIG. 5D, it can be determined whether rpad is greater than 1 in step S410. If rpad is greater than 1, the process proceeds to step S420. Otherwise, the convolution calculation method ends.
단계(S420)에서, 상기 가변 어레이(70) 중 상기 가변 어레이 포인터가 가리키는 자리에 미리 결정된 패딩값(vp)을 저장할 수 있다.In step S420, a predetermined padding value (vp) may be stored in the position indicated by the variable array pointer in the variable array 70.
단계(S430)에서, 상기 알패드(rpad)를 제4값만큼 감소시킬 수 있다. 상기 제4값은 예컨대 1일 수 있다. In step S430, rpad may be decreased by a fourth value. The fourth value may be, for example, 1.
단계(S440)에서, 상기 가변 어레이(70)와 상기 커널(90)을 연산한 값을, 상기 출력 어레이(60) 중 상기 출력 어레이 포인터(제2포인터)가 가리키는 자리에 저장할 수 있다. 이때, 상기 연산은 콘볼루션 연산일 수 있다. In step S440, the value calculated by the variable array 70 and the kernel 90 may be stored in the position pointed to by the output array pointer (second pointer) of the output array 60. At this time, the operation may be a convolution operation.
단계(S450)에서, 상기 가변 어레이 포인터의 값을 워드 사이즈만큼 순환 증가시키고, 상기 출력 어레이 포인터(제2포인터)를 워드 사이즈만큼 증가시킬 수 있다. 그리고 다시 도 5a의 단계(S130)로 되돌아 갈 수 있다. In step S450, the value of the variable array pointer may be cyclically increased by the word size, and the output array pointer (second pointer) may be increased by the word size. Then, the process may return to step S130 of FIG. 5A.
상기 제1값, 상기 제2값, 및 상기 제4값은, 이에 관하여 주어진 어레이에서 서로 인접한 요소들 간의 인덱스의 차이값을 의미하는 것일 수 있다. The first value, the second value, and the fourth value may refer to index difference values between adjacent elements in a given array.
도 6은 도 5에 제시한 본 발명의 일 실시예에 따라 제공되는 콘볼루션 연산 방법의 실제 사례를 나타낸 것이다. Figure 6 shows an actual example of the convolution operation method provided according to an embodiment of the present invention shown in Figure 5.
도 6은 도 5에 제시한 콘볼루션 연산 방법을 도 3에 예시한 대상 어레이(81) 및 커널(90)에 적용한 사례이다. FIG. 6 is an example of applying the convolution operation method shown in FIG. 5 to the target array 81 and kernel 90 illustrated in FIG. 3.
도 6에는 소스인덱스(s_idx), 엘패드(lpad), 밸리드(valid), 및 알패드(rpad)의 값을 나타낸 레지스터 테이블(50), 가변 어레이(70), 커널(90), 및 출력 어레이(60)를 제시하였다. 출력 어레이(60)는, 출력 어레이 포인터(제2포인터)가 위치한 일부 요소들만을 제시하였고, 나머지 요소들은 제시하지 않았다.Figure 6 shows the register table 50, variable array 70, kernel 90, and output showing the values of source index (s_idx), lpad, valid, and rpad. Array 60 was presented. The output array 60 presented only some elements where the output array pointer (second pointer) was located, and did not present the remaining elements.
도 6에 제시한 스텝 0 내지 스텝 3에서 가변 어레이(70)의 값은 아직 확정되지 않은 상태이다. In steps 0 to 3 shown in FIG. 6, the value of the variable array 70 has not yet been determined.
도 3에 예시한 출력 어레이(60)의 각 값은, 가변 어레이(70)와 커널(90)의 값을 서로 연산함으로써 결정될 수 있다. 스텝 0 내지 스텝 3에서는 가변 어레이(70)이 요소값들 중 적어도 일부가 결정되어 있지 않기 때문에, 스텝 0 내지 스텝 3에서는 출력 어레이(60)의 어떤 요소를 결정하는 연산이 수행될 수 없다. Each value of the output array 60 illustrated in FIG. 3 can be determined by calculating the values of the variable array 70 and the kernel 90 with each other. Since at least some of the element values of the variable array 70 are not determined in steps 0 to 3, an operation for determining an element of the output array 60 cannot be performed in steps 0 to 3.
도 6에 제시한 스텝 1 내지 스텝 11 중 스텝 4 내지 스텝 11의 총 8개 스텝에서는 각각 출력 어레이(60)의 각 요소를 결정한다.In a total of eight steps, including steps 4 to 11 among steps 1 to 11 shown in FIG. 6, each element of the output array 60 is determined.
도 6의 스텝 0에서는 도 5a의 단계(S120)에 의해 소스인덱스(s_idx), 엘패드(lpad), 밸리드(valid), 및, 알패드(rpad)의 값이 각각 1, 3, 5, 3 으로 결정되고, 제1포인터가 가변 어레이(70)의 첫 번째 인덱스(0)를 가리키도록 제1포인터의 값이 초기화 된다. 도 6에서 상기 제1포인터의 위치는 검은색 역삼각형으로 표시하였다.In step 0 of FIG. 6, the values of source index (s_idx), lpad, valid, and rpad are 1, 3, 5, respectively, by step S120 of FIG. 5A. It is determined to be 3, and the value of the first pointer is initialized so that the first pointer points to the first index (0) of the variable array 70. In Figure 6, the location of the first pointer is indicated by a black inverted triangle.
각각의 제k 스텝(step k)(k=1, ..., 11)은 도 5의 단계(S130)으로부터 시작될 수 있다. Each k-th step (step k) (k=1, ..., 11) may start from step S130 of FIG. 5.
이하, 제k 스텝(k=1, ..., 11)의 오른쪽에 나타낸 상기 레지스터 테이블(50)의 각 요소의 값, 그리고 상기 가변 어레이(70)의 각 요소의 값은 상기 제k 스텝에서 단계(S130)이 실행되기 직전의 상태를 나타낸 것이다. Hereinafter, the value of each element of the register table 50 shown to the right of the k-th step (k=1, ..., 11) and the value of each element of the variable array 70 are expressed in the k-th step. This shows the state just before step S130 is executed.
그리고 제k 스텝(k=1, ..., 11)의 오른쪽에 나타낸 상기 가변 어레이(70)의 위에 나타낸 제1포인터의 위치(검은색 역삼각형)는 상기 제k 스텝에서 단계(S130)이 실행되기 직전의 상태를 나타낸 것이다. And the position of the first pointer (black inverted triangle) shown on the variable array 70 shown to the right of the k-th step (k=1, ..., 11) is the step (S130) in the k-th step. It shows the state just before execution.
그리고 제k 스텝(k=1, ..., 11)의 오른쪽에 나타낸 상기 출력 어레이(60)의 위에 나타낸 제2포인터의 위치(화살표)는 상기 제k 스텝에서 단계(S130)이 실행되기 직전의 상태를 나타낸 것이다. And the position of the second pointer (arrow) shown above the output array 60 shown to the right of the k-th step (k=1, ..., 11) is immediately before the step (S130) is executed in the k-th step. It indicates the state of.
그리고 제k 스텝(k=1, ..., 11)의 오른쪽에 나타낸 상기 가변 어레이(70)의 각 요소에 표시된 값은, 상기 제k 스텝이 완료된 상태에서의 값을 나타낸다. 'vp'는 미리 정의된 패딩값이고, 부호 '?'는 해당 요소의 값이 유효한 값이 아님을 나타낸다.And the value displayed for each element of the variable array 70 shown to the right of the k-th step (k=1, ..., 11) represents the value when the k-th step is completed. 'vp' is a predefined padding value, and the symbol '?' indicates that the value of the element is not a valid value.
도 6의 스텝 1에 제시한 상태는, 도 5의 단계(S130), 단계(S210), 단계(S220), 및 단계(S230)이 실행된 결과이다. 그 결과 상기 가변 어레이(70)의 인덱스 0에는 상기 패딩값이 저장된다.The state shown in step 1 of FIG. 6 is the result of executing steps S130, S210, S220, and S230 of FIG. 5. As a result, the padding value is stored at index 0 of the variable array 70.
예컨대 스텝 1에서, 단계(S220)에 의해 엘패드(lpad)가 1만큼 감소하였지만 그 결과는 스텝 2에 제시하였다. 예컨대 스텝 1에서, 단계(S230)에 의해 제1포인터의 값이 1만큼 증가하였지만 그 결과는 스텝 2에 제시하였다.For example, in step 1, lpad was decreased by 1 in step S220, but the result is presented in step 2. For example, in step 1, the value of the first pointer is increased by 1 in step S230, but the result is presented in step 2.
도 6의 스텝 2에 제시한 상태는, 도 5의 단계(S130), 단계(S210), 단계(S220), 및 단계(S230)이 순차적으로 실행된 결과이다. 그 결과 상기 가변 어레이(70)의 인덱스 1에는 상기 패딩값이 저장된다.The state shown in step 2 of FIG. 6 is the result of sequentially executing steps S130, S210, S220, and S230 in FIG. 5. As a result, the padding value is stored at index 1 of the variable array 70.
도 6의 스텝 3에 제시한 상태는, 도 5의 단계(S130), 단계(S210), 단계(S220), 및 단계(S230)이 순차적으로 실행된 결과이다. 그 결과 상기 가변 어레이(70)의 인덱스 2에는 상기 패딩값이 저장된다.The state shown in step 3 of FIG. 6 is the result of sequentially executing steps S130, S210, S220, and S230 in FIG. 5. As a result, the padding value is stored at index 2 of the variable array 70.
도 6의 스텝 4 내지 스텝 8에 각각 제시한 상태는, 도 5의 단계(S130), 단계(S310), 단계(S320), 단계(S330), 단계(S340), 및 단계(S350)이 순차적으로 실행된 결과이다. 상기 가변 어레이(70)에 저장된 값들과 상기 커널(90)에 저장된 값들을 연산한 결과값(co[ ])이 상기 제2포인터가 가리키는 상기 출력 어레이(60)의 위치에 저장된다.In the states shown in steps 4 to 8 of FIG. 6, steps S130, S310, S320, S330, S340, and S350 of FIG. 5 are sequentially performed. This is the result of running . The result value (co[ ]) of calculating the values stored in the variable array 70 and the values stored in the kernel 90 is stored in the location of the output array 60 indicated by the second pointer.
도 6의 스텝 9 내지 스텝 10에 각각 제시한 상태는, 도 5의 단계(S130), 단계(S310), 단계(S410), 단계(S420), 단계(S430), 단계(S440), 및 단계(S450)이 순차적으로 실행된 결과이다. 상기 가변 어레이(70)에 저장된 값들과 상기 커널(90)에 저장된 값들을 연산한 결과값(co[ ])이 상기 제2포인터가 가리키는 상기 출력 어레이(60)의 위치에 저장된다.The states shown in steps 9 to 10 of FIG. 6, respectively, are step (S130), step (S310), step (S410), step (S420), step (S430), step (S440), and step (S440) of FIG. (S450) is the result of sequential execution. The result value (co[ ]) of calculating the values stored in the variable array 70 and the values stored in the kernel 90 is stored in the location of the output array 60 indicated by the second pointer.
도 6의 스텝 11에 제시한 상태는, 도 5의 단계(S130), 단계(S310), 단계(S410), 단계(S500)이 순차적으로 실행된 결과이다. 상기 가변 어레이(70)에 저장된 값들과 상기 커널(90)에 저장된 값들을 연산한 결과값(co[ ])이 상기 제2포인터가 가리키는 상기 출력 어레이(60)의 위치에 저장되고, 상기 콘볼루션 연산 방법이 종료된다.The state shown in step 11 of FIG. 6 is the result of sequentially executing steps S130, S310, S410, and S500 of FIG. 5. A result value (co[ ]) of calculating the values stored in the variable array 70 and the values stored in the kernel 90 is stored in the location of the output array 60 pointed to by the second pointer, and the convolution The calculation method ends.
상기 스텝 4 내지 스텝 11에서, 상기 커널(90)의 마지막 인덱스의 값은 상기 가변 어레이(70) 중 상기 제1포인터가 가리키는 인덱스의 값에 대응된다. 상기 커널(90)의 마지막 인덱스로부터 n만큼 순환 증가된 인덱스의 값은, 상기 제1포인터가 가리키는 인덱스로부터 n만큼 순환 증가된 인덱스의 값에 대응한다. 상기 스텝 4 내지 스텝 11에서, 상기 커널(90)와 상기 가변 어레이(70)이 서로 연산될 때에, 상기 서로 대응하는 값들을 서로 연산할 수 있다. 즉, 도 6에서 상기 커널(90)와 상기 가변 어레이(70)에서, 사각형 아이콘으로 지시된 데이터끼리 연산되고, 원형 아이콘으로 지시된 데이터끼리 연산되고, 삼각형 아이콘으로 지시된 데이터끼리 연산되고, 그리고 검은색 역삼각형 아이콘으로 지시된 데이터끼리 연산될 수 있다.In steps 4 to 11, the last index value of the kernel 90 corresponds to the index value pointed to by the first pointer in the variable array 70. The value of the index cyclically increased by n from the last index of the kernel 90 corresponds to the value of the index cyclically increased by n from the index pointed to by the first pointer. In steps 4 to 11, when the kernel 90 and the variable array 70 are operated with each other, the corresponding values can be operated with each other. That is, in FIG. 6, in the kernel 90 and the variable array 70, data indicated by a square icon is operated, data indicated by a circular icon is calculated, data indicated by a triangle icon are calculated, and Data indicated by the black inverted triangle icon can be operated on.
<실시예 - 풀링 연산><Example - Pooling Operation>
도 7은 본 발명의 일 실시예에 따라 풀링 연산을 실행할 때에 사용되는 대상 어레이, 가변 어레이의 개념을 나타낸 것이다.Figure 7 shows the concepts of a target array and a variable array used when performing a pooling operation according to an embodiment of the present invention.
도 7에 제시된 개념 중 도 3에 제시한 개념과 동일한 개념은 여기서 간단히 설명한다. Among the concepts presented in FIG. 7, the same concepts as those presented in FIG. 3 will be briefly explained here.
참조번호 80은 메모리에 저장된 데이터인 메모리 데이터(80)를 예시한 것이다. Reference number 80 illustrates memory data 80, which is data stored in memory.
참조번호 81은 상기 메모리에서 추출하여 읽은 데이터로서 풀링 연산의 대상이 되는 대상 어레이(81)이다. Reference number 81 is data extracted and read from the memory and is the target array 81 that is the target of the pooling operation.
참조번호 70는 가변 어레이(70)이다. 상기 가변 어레이(70)를 구성하는 값들은 모두 상기 대상 어레이(81)로부터 획득된 것일 수 있다. 또는, 상기 가변 어레이(70)를 구성하는 값들 중 일부는 소정의 패딩값으로 이루어지고 나머지는 상기 대상 어레이(81)로부터 획득된 것일 수 있다. 상기 패딩값은 예컨대 '0'과 같은 미리 결정된 값일 수 있다. Reference number 70 is a variable array 70. All values constituting the variable array 70 may be obtained from the target array 81. Alternatively, some of the values constituting the variable array 70 may be composed of predetermined padding values, and the remainder may be obtained from the target array 81. The padding value may be a predetermined value such as '0'.
참조번호 160은 상기 대상 어레이(81)를 풀링 연산하여 생성하게 되는 데이터인 출력 어레이(160)를 나타낸 것이다. 출력 어레이(160)의 크기는 실행해야 할 풀링 연산 방법의 구체적인 정의에 따라 결정될 수 있다. Reference number 160 indicates the output array 160, which is data generated by performing a pooling operation on the target array 81. The size of the output array 160 may be determined according to the specific definition of the pooling operation method to be executed.
상기 가변 어레이(70)의 크기는 상기 대상 어레이(81)의 크기보다 작을 수 있다. The size of the variable array 70 may be smaller than the size of the target array 81.
상기 가변 어레이(70)의 크기는, 정의된 풀링 연산에서 이용되는 풀링 윈도우의 크기와 동일하다. 도 7에서는 풀링 윈도우의 크기가 4인 예를 제시하였다.The size of the variable array 70 is the same as the size of the pooling window used in the defined pooling operation. In Figure 7, an example where the size of the pooling window is 4 is presented.
도 8은 미리 결정된 대상 어레이를 풀링 윈도우를 이용하여 풀링 연산을 수행하는 방법의 개념을 설명하는 도면이다.Figure 8 is a diagram explaining the concept of a method of performing a pooling operation on a predetermined target array using a pooling window.
도 8에서, 설명의 편의를 위하여, 상기 미리 결정된 대상 어레이로서 도 7에 제시한 대상 어레이(81)를 제시하였다. 이때, 풀링 윈도우의 크기는 4이다. 도 8에서 풀링 윈도우의 위치는 점선으로 표시하였다.In FIG. 8 , for convenience of explanation, the target array 81 shown in FIG. 7 is presented as the predetermined target array. At this time, the size of the pooling window is 4. In Figure 8, the position of the pooling window is indicated by a dotted line.
상기 풀링 연산은 스텝 121 내지 스텝 128의 총 8회의 스텝으로 구성될 수 있다. 각 스텝마다 풀링 윈도우의 대상 어레이(81)에 대한 상대적인 위치는 스트라이드 1만큼 변경될 수 있다. The pooling operation may consist of a total of 8 steps, including steps 121 to 128. For each step, the relative position of the pooling window to the target array 81 may be changed by stride 1.
설명의 편의를 위해, 도 8에 제시한 예에서, v1, v2, v3, v4, 및 v5는 각각 1, 2, 3, 4, 및 5의 값을 갖는 것으로 가정한다. 그리고 도 8에 적용된 풀링 연산은, 풀링 윈도우에 존재하는 값들 중 가장 큰 값을 출력하는 맥스 풀링(MAX pooling)인 것으로 가정한다. For convenience of explanation, in the example shown in FIG. 8, v1, v2, v3, v4, and v5 are assumed to have values of 1, 2, 3, 4, and 5, respectively. It is assumed that the pooling operation applied in FIG. 8 is MAX pooling, which outputs the largest value among the values existing in the pooling window.
상기 조건에 따르면, 스텝 121에 의해 생성되는 풀링 연산 데이터는 po[0]=v1 이다. According to the above conditions, the pooling operation data generated by step 121 is po[0]=v1.
상기 조건에 따르면, 스텝 122에 의해 생성되는 풀링 연산 데이터는 po[1]=v2 이다. According to the above conditions, the pooling operation data generated by step 122 is po[1]=v2.
상기 조건에 따르면, 스텝 123에 의해 생성되는 풀링 연산 데이터는 po[2]=v3 이다. According to the above conditions, the pooling operation data generated by step 123 is po[2]=v3.
상기 조건에 따르면, 스텝 124에 의해 생성되는 풀링 연산 데이터는 po[3]=v4 이다. According to the above conditions, the pooling operation data generated by step 124 is po[3]=v4.
상기 조건에 따르면, 스텝 125에 의해 생성되는 풀링 연산 데이터는 po[4]=v5 이다. According to the above conditions, the pooling operation data generated by step 125 is po[4]=v5.
상기 조건에 따르면, 스텝 126에 의해 생성되는 풀링 연산 데이터는 po[5]=v5 이다. According to the above conditions, the pooling operation data generated by step 126 is po[5]=v5.
상기 조건에 따르면, 스텝 127에 의해 생성되는 풀링 연산 데이터는 po[6]=v5 이다. According to the above conditions, the pooling operation data generated by step 127 is po[6]=v5.
상기 조건에 따르면, 스텝 128에 의해 생성되는 풀링 연산 데이터는 po[7]=v5 이다. According to the above conditions, the pooling operation data generated by step 128 is po[7]=v5.
본 발명의 일 실시예에 따라 제공되는 풀링 연산 방법에서는 '좌측 패딩의 최대 개수'라는 값 및 '우측 패딩의 최대 개수'라는 값이 정의된다. In the pooling operation method provided according to an embodiment of the present invention, the values 'maximum number of left padding' and 'maximum number of right padding' are defined.
상기 풀링 연산 방법의 실행과정 중 첫 번째 스텝(스텝 121)에 있어서, 풀링 윈도우 중 대상 어레이의 값에 대응되지 않는 영역의 개수를 좌측 패딩의 최대 개수라고 정의한다. 도 8에 제시한 풀링 연산 방법의 예에서 상기 좌측 패딩의 최대 개수는 3으로 결정된다.In the first step (step 121) of the execution process of the pooling operation method, the number of areas in the pooling window that do not correspond to the value of the target array is defined as the maximum number of left padding. In the example of the pooling operation method shown in FIG. 8, the maximum number of left paddings is determined to be 3.
상기 풀링 연산 방법의 실행 과정 중 마지막 스텝(스텝 128)에 있어서, 풀링 윈도우 중 대상 어레이의 값에 대응되지 않는 영역의 개수를 우측 패딩의 최대 개수라고 정의할 수 있다. 도 8에 제시한 풀링 연산 방법의 예에서 상기 우측 패딩의 최대 개수는 3으로 결정된다.In the last step (step 128) of the execution process of the pooling operation method, the number of areas in the pooling window that do not correspond to the value of the target array can be defined as the maximum number of right padding. In the example of the pooling operation method shown in FIG. 8, the maximum number of right paddings is determined to be 3.
상술한 바와 같이 상기 좌측 패딩의 최대 개수가 3이고, 상기 우측 패딩의 최대 개수가 3이며, 그리고 스트라이드가 1인 경우, 상기 출력 어레이(160)의 크기는 8로 결정된다. As described above, when the maximum number of left paddings is 3, the maximum number of right paddings is 3, and the stride is 1, the size of the output array 160 is determined to be 8.
도 9a, 도 9b, 도 9c, 및 도 9d는 본 발명의 일 실시예에 따라 제공되는 풀링 연산 방법을 나타낸 순서도이다. 도 9a, 도 9b, 도 9c, 및 도 9d를 통칭하여 도 9라고 지칭할 수 있다.FIGS. 9A, 9B, 9C, and 9D are flowcharts showing a pooling operation method provided according to an embodiment of the present invention. FIGS. 9A, 9B, 9C, and 9D may be collectively referred to as FIG. 9.
이하 도 7, 도 8, 및 도 9를 함께 참조하여 설명한다. Hereinafter, the description will be made with reference to FIGS. 7, 8, and 9.
단계(S1110)에서, 상기 메인 프로세서(160) 또는 제어부(40)는 메모리 중 대상 어레이(81)의 데이터가 저장되어 있는 영역의 시작주소와 종료주소를 획득할 수 있다. In step S1110, the main processor 160 or the control unit 40 may obtain the start address and end address of the area in the memory where data of the target array 81 is stored.
도 7의 대상 어레이(81)을 구성하는 데이터들은 상기 메모리의 주소 1 내지 5에 저장된 것일 수 있다.Data constituting the target array 81 of FIG. 7 may be stored in addresses 1 to 5 of the memory.
한편, 본 발명의 일 실시예에 따른 풀링 연산방법에 있어서, 소스인덱스(s_idx), 엘패드(lpad), 밸리드(valid), 및 알패드(rpad)의 4가지 변수가 정의되어 사용된다. Meanwhile, in the pooling operation method according to an embodiment of the present invention, four variables are defined and used: source index (s_idx), lpad, valid, and rpad.
또한, 본 발명의 일 실시예에 따른 풀링 연산방법에 있어서, 가변 어레이 포인터(제1포인터) 및 출력 어레이 포인터(제2포인터)라는 2개의 포인터가 더 정의될 수 있다. Additionally, in the pooling operation method according to an embodiment of the present invention, two pointers, a variable array pointer (first pointer) and an output array pointer (second pointer), may be further defined.
본 발명의 일 실시예에 따른 풀링 연산방법을 구현하는데 사용되는 컴퓨팅 장치는, 소스인덱스(s_idx), 엘패드(lpad), 밸리드(valid), 및 알패드(rpad)의 값을 각각 저장하는 레지스터인 소스인덱스 레지스터(s_idx_reg), 엘패드 레지스터(lpad_reg), 밸리드 레지스터(valid_reg), 및 알패드 레지스터(rpad_reg)를 메모리 공간에 할당할 수 있다. The computing device used to implement the pooling operation method according to an embodiment of the present invention stores the values of source index (s_idx), lpad, valid, and rpad, respectively. The registers source index register (s_idx_reg), Lpad register (lpad_reg), valid register (valid_reg), and Rpad register (rpad_reg) can be allocated to the memory space.
단계(S1120)에서 컴퓨팅 장치는 초기화 작업을 수행할 수 있다. 상기 초기화 작업은 아래에 나열한 작업들을 포함한다.In step S1120, the computing device may perform an initialization operation. The initialization task includes the tasks listed below.
첫째, 상기 소스인덱스(s_idx)에 상기 대상 어레이(81)의 첫 번째 인덱스를 할당할 수 있다. 상기 대상 어레이(81)의 첫 번째 인덱스는 상기 대상 어레이(81)의 첫 번째 데이터가 저장되어 있는 상기 메모리의 주소일 수 있다. 도 7 및 도 8의 예에서 상기 대상 어레이(81)의 첫 번째 인덱스는 '1'이다(s_idx=1).First, the first index of the target array 81 can be assigned to the source index (s_idx). The first index of the target array 81 may be the address of the memory where the first data of the target array 81 is stored. In the examples of FIGS. 7 and 8, the first index of the target array 81 is '1' (s_idx=1).
둘째, 상기 엘패드(lpad)에 미리 계획된 풀링 연산에서 이용되는 상기 좌측 패딩의 최대 개수를 할당할 수 있다. 도 7 및 도 8의 예에서 상기 좌측 패딩의 최대 개수는 3이다(lpad=3). Second, the maximum number of left paddings used in a pre-planned pooling operation can be assigned to lpad. In the examples of Figures 7 and 8, the maximum number of left paddings is 3 (lpad=3).
셋째, 상기 밸리드(valid)에 상기 대상 어레이(81)의 크기를 할당할 수 있다. 도 7 및 도 8의 예에서 상기 대상 어레이의 크기는 5이다(valid=5). Third, the size of the target array 81 can be assigned to the valid. In the examples of FIGS. 7 and 8, the size of the target array is 5 (valid=5).
넷째, 상기 알패드(rpad)에 상기 계획된 풀링 연산에서 이용되는 우측 패딩의 최대 개수를 할당할 수 있다. 도 7 및 도 8의 예에서 상기 우측 패딩의 최대 개수는 3이다(rpad=3). Fourth, the maximum number of right paddings used in the planned pooling operation can be assigned to the rpad. In the examples of Figures 7 and 8, the maximum number of right paddings is 3 (rpad=3).
다섯째, 상기 풀링 연산에 이용되는 풀링 윈도우의 크기와 동일한 크기를 갖는 가변 어레이(제2어레이)(70)를 준비할 수 있다. Fifth, a variable array (second array) 70 having the same size as the size of the pooling window used in the pooling operation can be prepared.
여섯째, 상기 가변 어레이 포인터(제1포인터)가 상기 가변 어레이(70)의 첫 번째 인덱스를 가리키도록 상기 가변 어레이 포인터(제1포인터)의 값을 초기화 할 수 있다. 도 7의 예에서 상기 가변 어레이 포인터(제1포인터)는 상기 가변 어레이(70)의 첫 번째 인덱스인 인덱스 1을 가리키도록 초기화될 수 있다. Sixth, the value of the variable array pointer (first pointer) can be initialized so that the variable array pointer (first pointer) points to the first index of the variable array 70. In the example of FIG. 7, the variable array pointer (first pointer) may be initialized to point to index 1, which is the first index of the variable array 70.
일곱째, 상기 출력 어레이 포인터(제2포인터)가 미리 준비된 출력 어레이(160)의 첫 번째 인덱스를 가리키도록 상기 제2포인터의 값을 초기화할 수 있다. 도 7의 예에서 상기 제2포인터는 상기 출력 어레이(160)의 첫 번째 인덱스인 인덱스 0을 가리키도록 초기화될 수 있다. Seventh, the value of the output array pointer (second pointer) can be initialized so that it points to the first index of the output array 160 prepared in advance. In the example of FIG. 7, the second pointer may be initialized to point to index 0, which is the first index of the output array 160.
단계(S1130)에서, 상기 엘패드(lpad)가 0보다 큰지 여부를 판단한다. 상기 엘패드(lpad)가 0보다 크면 단계(S1210)으로 진행하고, 그렇지 않으면 단계(S1310)로 진행한다. In step S1130, it is determined whether lpad is greater than 0. If lpad is greater than 0, the process proceeds to step S1210. Otherwise, the process proceeds to step S1310.
단계(S1310)에서, 상기 밸리드(valid)가 0보다 큰지 여부를 판단한다. 상기 밸리드(valid)가 0보다 크면 단계(S1320)로 진행하고, 그렇지 않으면 단계(S1410)로 진행한다.In step S1310, it is determined whether the valid is greater than 0. If the valid is greater than 0, the process proceeds to step S1320. Otherwise, the process proceeds to step S1410.
도 9b를 살펴보면, 단계(S1210)에서, 상기 가변 어레이(70) 중 상기 가변 어레이 포인터가 가리키는 자리에 미리 결정된 패딩값(vp)을 저장할 수 있다.Referring to FIG. 9B, in step S1210, a predetermined padding value (vp) may be stored in the position indicated by the variable array pointer in the variable array 70.
도 8에 제시한 것과 같이, 만일 상기 풀링 연산이 MAX 풀링인 경우, 상기 패딩값(vp)은 표현할 수 있는 가장 작은 값일 수 있다.As shown in FIG. 8, if the pooling operation is MAX pooling, the padding value (vp) may be the smallest value that can be expressed.
다른 실시예에서는 상기 패딩값(vp)은 다른 값으로 정의될 수 있다. 예컨대 만일 상기 풀링 연산이, 풀링 윈도우 내의 데이터들의 평균값을 출력하는 평균 풀링(average pooling)인 경우, 상기 패딩값(vp)은 0(0)일 수 있다.In another embodiment, the padding value (vp) may be defined as a different value. For example, if the pooling operation is average pooling, which outputs the average value of data within the pooling window, the padding value (vp) may be 0 (0).
단계(S1220)에서, 상기 엘패드(lpad)를 상기 제1값만큼 감소시킬 수 있다.In step S1220, lpad may be reduced by the first value.
단계(S1230)에서, 상기 가변 어레이 포인터(제1포인터)의 값을 워드 사이즈만큼 증가시킬 수 있다. 그리고 이때 상기 증가는 순환 증가일 수 있다. 그리고 다시 도 9a의 단계(S1130)로 되돌아 갈 수 있다. In step S1230, the value of the variable array pointer (first pointer) may be increased by the word size. And at this time, the increase may be a circulation increase. Then, the process may return to step S1130 of FIG. 9A.
도 9c를 살펴보면, 단계(S1320)에서 상기 가변 어레이(70) 중 상기 가변 어레이 포인터(제1포인터)가 가리키는 자리에, 상기 소스인덱스(s_idx)가 가리키는 대상 어레이(81)의 값, 즉 상기 소스인덱스(s_idx)가 가리키는 대상 어레이(81)의 요소의 값을 저장할 수 있다. Referring to FIG. 9C, in step S1320, the value of the target array 81 indicated by the source index (s_idx), that is, the source, is placed at the position pointed to by the variable array pointer (first pointer) of the variable array 70. The value of the element of the target array 81 pointed to by the index (s_idx) can be stored.
단계(S1330)에서, 상기 밸리드(valid)를 상기 제2값만큼 감소시키고 상기 소스인덱스(s_idx)를 상기 제3값만큼 증가시킬 수 있다.In step S1330, the valid may be decreased by the second value and the source index (s_idx) may be increased by the third value.
단계(S1340)에서, 상기 가변 어레이(70)의 데이터들을 대상으로 풀링 연산한 결과값을, 상기 출력 어레이(160) 중 상기 출력 어레이 포인터(제2포인터)가 가리키는 자리에 저장할 수 있다.In step S1340, the result of the pooling operation on the data of the variable array 70 may be stored in the position pointed to by the output array pointer (second pointer) of the output array 160.
단계(S1350)에서, 상기 가변 어레이 포인터(제1포인터)의 값을 워드 사이즈만큼 순환 증가시키고, 상기 출력 어레이 포인터(제2포인터)를 워드 사이즈만큼 증가시킬 수 있다. 그리고 다시 도 9a의 단계(S1130)로 되돌아 갈 수 있다. In step S1350, the value of the variable array pointer (first pointer) may be cyclically increased by the word size, and the output array pointer (second pointer) may be increased by the word size. Then, the process may return to step S1130 of FIG. 9A.
도 9d를 살펴보면, 단계(S1410)에서 상기 알패드(rpad)가 1보다 큰지 여부를 결정할 수 있다. 상기 알패드(rpad)가 1보다 크면 단계(S1420)로 진행하고, 그렇지 않으면 단계(S1500)로 이동하여 상기 풀링 연산 방법을 종료한다.Referring to FIG. 9D, it can be determined whether rpad is greater than 1 in step S1410. If rpad is greater than 1, the process proceeds to step S1420. Otherwise, the process proceeds to step S1500 and the pooling operation method is terminated.
단계(S1420)에서, 상기 가변 어레이(70) 중 상기 가변 어레이 포인터가 가리키는 자리에 상기 미리 결정된 패딩값(vp)을 저장할 수 있다.In step S1420, the predetermined padding value (vp) may be stored in the position indicated by the variable array pointer in the variable array 70.
단계(S1430)에서, 상기 알패드(rpad)를 상기 제4값만큼 감소시킬 수 있다.In step S1430, the rpad may be decreased by the fourth value.
단계(S1440)에서, 상기 가변 어레이(70)의 데이터들을 대상으로 풀링 연산한 결과값을, 상기 출력 어레이(160) 중 상기 출력 어레이 포인터(제2포인터)가 가리키는 자리에 저장할 수 있다. In step S1440, the result of the pooling operation on the data of the variable array 70 may be stored in the position pointed to by the output array pointer (second pointer) of the output array 160.
단계(S1450)에서, 상기 가변 어레이 포인터의 값을 워드 사이즈만큼 순환 증가시키고, 상기 출력 어레이 포인터(제2포인터)를 워드 사이즈만큼 증가시킬 수 있다. 그리고 다시 도 9a의 단계(S1130)로 되돌아 갈 수 있다. In step S1450, the value of the variable array pointer may be cyclically increased by the word size, and the output array pointer (second pointer) may be increased by the word size. Then, the process may return to step S1130 of FIG. 9A.
도 10은 도 9에 제시한 본 발명의 일 실시예에 따라 제공되는 풀링 연산 방법의 실제 사례를 나타낸 것이다. Figure 10 shows an actual example of the pooling operation method provided according to an embodiment of the present invention shown in Figure 9.
도 10은 도 9에 제시한 풀링 연산 방법을 도 7에 예시한 대상 어레이(81)에 적용한 사례이다. FIG. 10 is an example of applying the pooling operation method shown in FIG. 9 to the target array 81 illustrated in FIG. 7.
도 10에는 소스인덱스(s_idx), 엘패드(lpad), 밸리드(valid), 및 알패드(rpad)의 값을 나타낸 레지스터 테이블(50), 가변 어레이(70), 및 출력 어레이(160)를 제시하였다. 출력 어레이(160)는, 출력 어레이 포인터(제2포인터)가 위치한 일부 요소들만을 제시하였고, 나머지 요소들은 제시하지 않았다.Figure 10 shows the register table 50, variable array 70, and output array 160 showing the values of source index (s_idx), lpad, valid, and rpad. presented. The output array 160 presented only some elements where the output array pointer (second pointer) was located, and did not present the remaining elements.
도 10에 제시한 스텝 100 내지 스텝 103에서 가변 어레이(70)의 값들은 확정되지 않은 상태이다.In steps 100 to 103 shown in FIG. 10, the values of the variable array 70 are not confirmed.
도 7에 예시한 출력 어레이(160)의 각 값은, 가변 어레이(70)를 대상으로 하는 풀링 연산을 수행하여 결정될 수 있다. 스텝 100 내지 스텝 103에서는 가변 어레이(70)이 요소값들 중 적어도 일부가 결정되어 있지 않기 때문에, 스텝 100 내지 스텝 103에서는 출력 어레이(160)의 어떤 요소를 결정하는 연산이 수행될 수 없다. Each value of the output array 160 illustrated in FIG. 7 may be determined by performing a pooling operation targeting the variable array 70. Since at least some of the element values of the variable array 70 are not determined in steps 100 to 103, an operation for determining an element of the output array 160 cannot be performed in steps 100 to 103.
도 10에 제시한 스텝 104 내지 스텝 111의 총 8개 스텝에서는 각각 출력 어레이(160)의 각 요소를 결정한다.In a total of eight steps, steps 104 to 111 shown in FIG. 10, each element of the output array 160 is determined.
도 10의 스텝 100에서는 도 9a의 단계(S1120)에 의해 소스인덱스(s_idx), 엘패드(lpad), 밸리드(valid), 및, 알패드(rpad)의 값이 각각 1, 3, 5, 3 으로 결정되고, 상기 제1포인터의 값이 가변 어레이(70)의 첫 번째 인덱스(0)를 가리키도록 초기화 된다. 도 10에서 상기 제1포인터의 위치는 검은색 역삼각형으로 표시하였다.In step 100 of FIG. 10, the values of source index (s_idx), lpad, valid, and rpad are 1, 3, 5, respectively, by step S1120 of FIG. 9a. It is determined to be 3, and the value of the first pointer is initialized to point to the first index (0) of the variable array 70. In Figure 10, the location of the first pointer is indicated by a black inverted triangle.
각각의 제k 스텝(step k)(k=101, ..., 111)은 도 9의 단계(S1130)으로부터 시작될 수 있다. Each k-th step (step k) (k=101, ..., 111) may start from step S1130 of FIG. 9.
이하, 제k 스텝(k=101, ..., 111)의 오른쪽에 나타낸 상기 레지스터 테이블(50)의 각 요소의 값, 그리고 상기 가변 어레이(70)의 각 요소의 값은 상기 제k 스텝에서 단계(S1130)이 실행되기 직전의 상태를 나타낸 것이다. Hereinafter, the value of each element of the register table 50 shown on the right side of the k-th step (k=101, ..., 111) and the value of each element of the variable array 70 are expressed in the k-th step. This shows the state just before step (S1130) is executed.
그리고 제k 스텝(k=101, ..., 111)의 오른쪽에 나타낸 상기 가변 어레이(70)의 위에 나타낸 제1포인터의 위치(검은색 역삼각형)는 상기 제k 스텝에서 단계(S1130)이 실행되기 직전의 상태를 나타낸 것이다. And the position of the first pointer (black inverted triangle) shown on the variable array 70 shown to the right of the k-th step (k=101, ..., 111) is the step (S1130) in the k-th step. It shows the state just before execution.
그리고 제k 스텝(k=101, ..., 111)의 오른쪽에 나타낸 상기 출력 어레이(160)의 위에 나타낸 제2포인터의 위치(화살표)는 상기 제k 스텝에서 단계(S1130)이 실행되기 직전의 상태를 나타낸 것이다. And the position of the second pointer (arrow) shown above the output array 160 shown to the right of the k-th step (k=101, ..., 111) is immediately before the step (S1130) is executed in the k-th step. It indicates the state of.
그리고 제k 스텝(k=101, ..., 111)의 오른쪽에 나타낸 상기 가변 어레이(70)의 각 요소에 표시된 값은, 상기 제k 스텝이 완료된 상태에서의 값을 나타낸다. 'vp'는 미리 정의된 패딩값이고, 부호 '?'는 해당 요소의 값이 유효한 값이 아님을 나타낸다.And the value displayed for each element of the variable array 70 shown to the right of the k-th step (k=101, ..., 111) represents the value when the k-th step is completed. 'vp' is a predefined padding value, and the symbol '?' indicates that the value of the element is not a valid value.
도 10의 스텝 101에 제시한 상태는, 도 9의 단계(S1130), 단계(S1210), 단계(S1220), 및 단계(S1230)이 실행된 결과이다. 그 결과 상기 가변 어레이(70)의 인덱스 0에는 상기 패딩값이 저장된다.The state shown in step 101 of FIG. 10 is the result of executing steps S1130, S1210, S1220, and S1230 of FIG. 9. As a result, the padding value is stored at index 0 of the variable array 70.
도 10의 스텝 102에 제시한 상태는, 도 9의 단계(S1130), 단계(S1210), 단계(S1220), 및 단계(S1230)이 순차적으로 실행된 결과이다. 그 결과 상기 가변 어레이(70)의 인덱스 1에는 상기 패딩값이 저장된다.The state shown in step 102 of FIG. 10 is the result of sequentially executing steps S1130, S1210, S1220, and S1230 in FIG. 9. As a result, the padding value is stored at index 1 of the variable array 70.
도 10의 스텝 103에 제시한 상태는, 도 9의 단계(S1130), 단계(S1210), 단계(S1220), 및 단계(S1230)이 순차적으로 실행된 결과이다. 그 결과 상기 가변 어레이(70)의 인덱스 2에는 상기 패딩값이 저장된다.The state shown in step 103 of FIG. 10 is the result of sequentially executing steps S1130, S1210, S1220, and S1230 in FIG. 9. As a result, the padding value is stored at index 2 of the variable array 70.
도 10의 스텝 104 내지 스텝 108에 각각 제시한 상태는, 도 9의 단계(S1130), 단계(S1310), 단계(S1320), 단계(S1330), 단계(S1340), 및 단계(S1350)이 순차적으로 실행된 결과이다. 상기 가변 어레이(70)에 저장된 값들을 대상으로 풀링 연산한 결과값(po[ ])이 상기 제2포인터가 가리키는 상기 출력 어레이(160)의 위치에 저장된다.In the states shown in steps 104 to 108 of FIG. 10, steps S1130, S1310, S1320, S1330, S1340, and S1350 of FIG. 9 are sequentially performed. This is the result of running . The result value (po[ ]) of the pooling operation on the values stored in the variable array 70 is stored in the location of the output array 160 pointed to by the second pointer.
도 10의 스텝 109 내지 스텝 110에 각각 제시한 상태는, 도 9의 단계(S1130), 단계(S1310), 단계(S1410), 단계(S1420), 단계(S1430), 단계(S1440), 및 단계(S1450)이 순차적으로 실행된 결과이다. 상기 가변 어레이(70)에 저장된 값들을 대상으로 풀링 연산한 결과값(po[ ])이 상기 제2포인터가 가리키는 상기 출력 어레이(160)의 위치에 저장된다.The states shown in steps 109 to 110 of FIG. 10 are step (S1130), step (S1310), step (S1410), step (S1420), step (S1430), step (S1440), and step (S1440) of FIG. 9. This is the result of (S1450) being executed sequentially. The result value (po[ ]) of the pooling operation on the values stored in the variable array 70 is stored in the location of the output array 160 pointed to by the second pointer.
도 10의 스텝 111에 제시한 상태는, 도 9의 단계(S1130), 단계(S1310), 단계(S1410), 단계(S1500)이 순차적으로 실행된 결과이다. 상기 가변 어레이(70)에 저장된 값들을 대상으로 풀링 연산한 결과값(po[ ])이 상기 제2포인터가 가리키는 상기 출력 어레이(160)의 위치에 저장되고, 상기 풀링 연산 방법이 종료된다.The state shown in step 111 of FIG. 10 is the result of sequentially executing steps S1130, S1310, S1410, and S1500 in FIG. 9. The result value (po[ ]) of the pooling operation on the values stored in the variable array 70 is stored in the location of the output array 160 pointed to by the second pointer, and the pooling operation method is terminated.
<본 발명에 따른 제1인스트럭션의 실행방법><Method of executing the first instruction according to the present invention>
상술한 콘볼루션 연산의 실시예와 풀링 연산의 실시예에는 가변 어레이(70)에 저장될 값을 결정하는 프로세스가 포함되어 있다. 이 프로세스를 도 11a 및 도 11b를 참조하여 설명한다.The above-described embodiment of the convolution operation and the embodiment of the pooling operation include a process for determining the value to be stored in the variable array 70. This process is explained with reference to Figures 11A and 11B.
도 11a는 본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 실행을 위해 필요한 3개의 변수를 초기화하는 과정을 나타낸다.Figure 11a shows the process of initializing three variables required for execution of the first instruction provided according to an embodiment of the present invention.
도 11b는 본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 1회 실행 과정을 나타낸 순서도이다. Figure 11b is a flowchart showing a one-time execution process of the first instruction provided according to an embodiment of the present invention.
컴퓨팅 장치가 상기 제1인스트럭션을 실행한다는 것은, 상기 제1인스트럭션에 의해 실행되는 단계들을 실행한다는 것을 의미할 수 있다.Executing the first instruction by a computing device may mean executing steps executed by the first instruction.
컴퓨팅 장치가 상기 제1인스트럭션을 실행하기 위해서는, 상기 제1인스트럭션을 실행을 위해 필요한 3개의 변수의 값을 초기화하고, 상기 제1인스트럭션이 상기 3개의 변수의 값을 제어할 수 있도록 상기 제1인스트럭션을 상기 3개의 변수에 연관시켜야 할 수 있다. 상기 3개의 변수가 초기화된 이후, 상기 제1인스트럭션이 1회 실행될 때마다, 미리 계획된 연산을 위해 필요한 값들이 결정되어 제1레지스터에 로딩될 수 있다. In order for the computing device to execute the first instruction, the values of the three variables necessary for executing the first instruction are initialized, and the first instruction is initialized so that the first instruction can control the values of the three variables. may need to be associated with the above three variables. After the three variables are initialized, each time the first instruction is executed, values required for a pre-planned operation may be determined and loaded into the first register.
상기 제1인스트럭션이 1회 실행될 때에, 상기 제1레지스터에는 메모리에 저장되어 있는 값이 로딩될 수도 있지만, 특정 조건에서는 상기 제1레지스터에는 미리 결정된 특정 상수값이 로딩될 수도 있다. 본 명세서에서 상기 미리 결정된 특정 상수값은 패딩값이라고 지칭할 수 있다. 본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 이름은 예컨대 LwP1 또는 LoadWithPad1 라고 지칭될 수도 있는데, 이에 한정되는 것은 아니다. When the first instruction is executed once, a value stored in memory may be loaded into the first register, but under certain conditions, a specific predetermined constant value may be loaded into the first register. In this specification, the specific predetermined constant value may be referred to as a padding value. The name of the first instruction provided according to an embodiment of the present invention may be, for example, LwP1 or LoadWithPad1, but is not limited thereto.
이제 도 11a를 참조하여, 본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 실행을 위한 변수 초기화 방법을 설명한다.Now, with reference to FIG. 11A, a method of initializing variables for executing the first instruction provided according to an embodiment of the present invention will be described.
본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 실행을 위한 변수 초기화 방법은 아래 단계들을 포함한다.The variable initialization method for executing the first instruction provided according to an embodiment of the present invention includes the following steps.
단계(S2110)에서, 컴퓨팅 장치는, 미리 계획된 연산의 대상인 대상 어레이에 대응하는 메모리의 영역의 첫 번째 주소를 획득할 수 있다. In step S2110, the computing device may obtain the first address of the area of the memory corresponding to the target array that is the target of the pre-planned operation.
일 실시예에서, 상기 메모리는 DRAM이거나 또는 SRAM일 수 있다.In one embodiment, the memory may be DRAM or SRAM.
본 명세서에서, 상기 메모리의 주소는 인덱스라고 지칭될 수도 있다.In this specification, the address of the memory may be referred to as an index.
단계(S2120)에서, 컴퓨팅 장치는, s_idx에 상기 획득한 첫 번째 주소를 부여하고, lpad에 상기 미리 계획된 연산에서 이용되는 좌측 패딩의 최대 개수를 부여하며, 그리고 valid에 상기 대상 어레이의 크기를 부여할 수 있다. In step S2120, the computing device assigns the obtained first address to s_idx, assigns the maximum number of left paddings used in the preplanned operation to lpad, and assigns the size of the target array to valid. can do.
상기 단계(S2110) 및 단계(S2120)는 lpad, s_idx, 및 valid를 포함하는 한 세트의 변수를 초기화하는 단계인 것으로 이해될 수 있다. The steps S2110 and S2120 may be understood as initializing a set of variables including lpad, s_idx, and valid.
상기 단계(S2110) 및 단계(S2120)을 단계(S2100)로 통합하여 설명할 수 있다. 이때 단계(S2100)는 lpad, s_idx, 및 valid를 포함하는 한 세트의 변수를 초기화하는 단계인 것으로 이해할 수 있다. The steps S2110 and S2120 can be explained by integrating them into step S2100. At this time, step S2100 can be understood as a step of initializing a set of variables including lpad, s_idx, and valid.
상기 대상 어레이의 크기는 상기 대상 어레이에 포함된 데이터 요소의 개수일 수 있다. The size of the target array may be the number of data elements included in the target array.
이제 도 11b를 참조하여, 본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 실행 방법을 설명한다.Now, with reference to FIG. 11B, a method of executing the first instruction provided according to an embodiment of the present invention will be described.
컴퓨팅 장치가 상기 제1인스트럭션을 호출하면 제1인스트럭션 실행 방법이 시작된다.When the computing device calls the first instruction, the method for executing the first instruction begins.
상기 제1인스트럭션 실행 방법은, pad, s_idx, 및 valid를 포함하는 한 세트의 변수에 대한 제어 권한, 소정의 제1레지스터의 기록 권한, 및 메모리에 대한 읽기 권한을 필요로 한다. The method of executing the first instruction requires control rights to a set of variables including pad, s_idx, and valid, write rights to a predetermined first register, and read rights to memory.
본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 실행 방법은 아래 단계들을 포함한다.A method of executing the first instruction provided according to an embodiment of the present invention includes the following steps.
단계(S2130)에서, lpad가 0(영)보다 큰지 확인한다. 0보다 크면 단계(S2210)로 진행하고 크지 않으면 단계(S2310)로 진행한다. In step S2130, it is checked whether lpad is greater than 0 (zero). If it is greater than 0, proceed to step (S2210), and if not greater than 0, proceed to step (S2310).
단계(S2310)에서, valid가 0(영)보다 큰지 확인한다. 0보다 크면 단계(S2320)로 진행하고 크지 않으면 단계(S2420)로 진행한다. In step S2310, it is checked whether valid is greater than 0 (zero). If it is greater than 0, proceed to step (S2320), and if not greater than 0, proceed to step (S2420).
단계(S2210)에서, 미리 결정된 패딩값을 제1레지스터에 저장한다. 그 다음, 단계(S2220)에서 lpad를 상기 제1값만큼 감소시킨 후 상기 제1인스트럭션의 실행을 종료한다.In step S2210, a predetermined padding value is stored in the first register. Next, in step S2220, lpad is decreased by the first value and then execution of the first instruction is terminated.
단계(S2320)에서, s_idx가 가리키는 메모리 주소에 저장된 값을 상기 제1레지스터에 저장한다. 그 다음, 단계(S2330)에서 valid를 상기 제2값만큼 감소시키고 s_idx를 상기 제3값만큼 증가시킨 후 상기 제1인스트럭션의 실행을 종료한다.In step S2320, the value stored at the memory address indicated by s_idx is stored in the first register. Next, in step S2330, valid is decreased by the second value, s_idx is increased by the third value, and execution of the first instruction is terminated.
여기서 상기 메모리의 서로 인접한 두 개의 주소값들의 차이는 1이라고 가정하였다. 만일 상기 메모리의 서로 인접한 두 개의 주소값들의 차이의 노미널 값이 ndv라고 한다면, 단계(S2330)에서 s_idx를 1만큼 증가시키는 것이 아니라 ndv만큼 증가시킬 수도 있다.Here, it is assumed that the difference between two adjacent address values of the memory is 1. If the nominal value of the difference between two adjacent address values of the memory is ndv, s_idx may be increased by ndv instead of 1 in step S2330.
단계(S2420)에서, 상기 미리 결정된 패딩값을 상기 제1레지스터에 저장한 후 상기 제1인스트럭션의 실행을 종료한다.In step S2420, the predetermined padding value is stored in the first register and then execution of the first instruction is terminated.
도 11b에 제시한 본 발명의 일 실시예에 따라 제공되는 제1인스트럭션의 실행 방법을 1회 실행하면, 상기 제1레지스터에 저장된 값이 1회 갱신된다.When the method of executing the first instruction provided according to an embodiment of the present invention shown in FIG. 11B is executed once, the value stored in the first register is updated once.
상기 제1인스트럭션이 1회 실행되면, 상기 lpad, 상기 valid, 및 상기 s_idx 중 적어도 하나가 변경된다. 이와 같이 상기 lpad, 상기 valid, 및 상기 s_idx 중 적어도 하나가 변경된 상태에서 상기 제1인스트럭션이 다시 실행될 수도 있다. When the first instruction is executed once, at least one of the lpad, the valid, and the s_idx is changed. In this way, the first instruction may be executed again with at least one of the lpad, valid, and s_idx changed.
일 실시예에서, 상기 제1인스트럭션을 이용하는 상위 어플리케이션은, 상기 제1인스트럭션의 실행을 위한 변수 초기화 방법을 1회 실행한 이후, 상기 제1인스트럭션을 N회 호출할 수 있다. 그 결과 상기 제1레지스터에 저장된 값은 N회에 걸쳐 갱신될 수 있다. 상기 상위 어플리케이션은 상기 N회에 걸쳐 갱신된 상기 제1레지스터의 값을 실시간으로 이용하거나 또는 별도의 어레이(예컨대 상기 가변 어레이)에 저장하였다가 미리 계획된 연산에 이용할 수 있다. In one embodiment, a higher-level application using the first instruction may call the first instruction N times after executing the variable initialization method for executing the first instruction once. As a result, the value stored in the first register can be updated N times. The higher-level application can use the value of the first register updated N times in real time or store it in a separate array (eg, the variable array) and use it for a pre-planned operation.
예컨대 상기 미리 계획된 연산은 콘볼루션 연산이고 상기 상위 어플리케이션은 콘볼루션 연산을 실행하는 연산일 수 있다. 다른 예에서, 상기 미리 계획된 연산은 풀링 연산이고 상기 상위 어플리케이션은 풀링 연산을 실행하는 프로그램일 수 있다. 또 다른 예에서, 상기 미리 계획된 연산은 임의의 연산이고 상기 상위 어플리케이션은 상기 임의의 연산을 실행하는 프로그램일 수 있다.For example, the pre-planned operation may be a convolution operation, and the higher-level application may be an operation that executes the convolution operation. In another example, the pre-planned operation may be a pooling operation and the higher level application may be a program that executes the pooling operation. In another example, the pre-planned operation may be an arbitrary operation and the higher level application may be a program that executes the arbitrary operation.
<본 발명에 따른 제2인스트럭션의 실행방법><Method of executing the second instruction according to the present invention>
도 12a는 본 발명의 다른 실시예에 따라 제공되는 제2인스트럭션의 실행을 위해 필요한 4개의 변수를 초기화하는 과정을 나타낸다.Figure 12a shows the process of initializing four variables required for execution of the second instruction provided according to another embodiment of the present invention.
도 12b는 본 발명의 상기 다른 실시예에 따라 제공되는 제2인스트럭션의 1회 실행 과정을 나타낸 순서도이다. Figure 12b is a flowchart showing a one-time execution process of the second instruction provided according to another embodiment of the present invention.
컴퓨팅 장치가 상기 제2인스트럭션을 실행하기 위해서는, 상기 제2인스트럭션을 실행을 위해 필요한 4개의 변수의 값을 초기화하고, 상기 제2인스트럭션이 상기 4개의 변수의 값을 제어할 수 있도록 상기 제2인스트럭션을 상기 4개의 변수에 연관시켜야 할 수 있다. 상기 4개의 변수가 초기화된 이후, 상기 제2인스트럭션이 1회 실행될 때마다, 미리 계획된 연산을 위해 필요한 값들이 결정되어 제1레지스터에 로딩될 수 있다. In order for the computing device to execute the second instruction, the values of four variables required for executing the second instruction are initialized, and the second instruction is initialized so that the second instruction can control the values of the four variables. may need to be associated with the above four variables. After the four variables are initialized, each time the second instruction is executed, values required for a pre-planned operation may be determined and loaded into the first register.
상기 본 발명의 다른 실시예에 따라 제공되는 제2인스트럭션의 이름은 예컨대 LwP2 또는 LoadWithPad2 라고 지칭될 수도 있는데, 이에 한정되는 것은 아니다. The name of the second instruction provided according to another embodiment of the present invention may be, for example, LwP2 or LoadWithPad2, but is not limited thereto.
이제 도 12a를 참조하여, 본 발명의 다른 실시예에 따라 제공되는 제2인스트럭션의 실행을 위한 변수 초기화 방법을 설명한다.Now, with reference to FIG. 12A, a method of initializing variables for executing a second instruction provided according to another embodiment of the present invention will be described.
본 발명의 다른 실시예에 따라 제공되는 제2인스트럭션의 실행을 위한 변수 초기화 방법은 아래 단계들을 포함한다.A variable initialization method for executing a second instruction provided according to another embodiment of the present invention includes the following steps.
단계(S2110)에서, 컴퓨팅 장치는, 미리 계획된 연산의 대상인 대상 어레이에 대응하는 메모리의 영역의 첫 번째 주소를 획득할 수 있다. In step S2110, the computing device may obtain the first address of the area of the memory corresponding to the target array that is the target of the pre-planned operation.
단계(S2120)에서, 컴퓨팅 장치는, s_idx에 상기 획득한 첫 번째 주소를 부여하고, lpad에 상기 미리 계획된 연산에서 이용되는 좌측 패딩의 최대 개수를 부여하며, valid에 상기 대상 어레이의 크기를 부여하고, 그리고 rpad에 상기 미리 계획된 연산에서 이용되는 우측 패딩의 최대 개수를 부여할 수 있다. In step S2120, the computing device assigns the obtained first address to s_idx, assigns the maximum number of left paddings used in the preplanned operation to lpad, and assigns the size of the target array to valid. , and the maximum number of right paddings used in the preplanned operation can be given to rpad.
상기 단계(S2110) 및 단계(S2120)는 lpad, s_idx, valid, 및 rpad를 포함하는 한 세트의 변수를 초기화하는 단계인 것으로 이해될 수 있다. The steps S2110 and S2120 may be understood as initializing a set of variables including lpad, s_idx, valid, and rpad.
상기 단계(S2110) 및 단계(S2120)을 단계(S2100)로 통합하여 설명할 수 있다. 이때 단계(S2100)는 lpad, s_idx, valid, 및 rpad를 포함하는 한 세트의 변수를 초기화하는 단계인 것으로 이해할 수 있다. The steps S2110 and S2120 can be explained by integrating them into step S2100. At this time, step S2100 can be understood as a step of initializing a set of variables including lpad, s_idx, valid, and rpad.
상기 대상 어레이의 크기는 상기 대상 어레이에 포함된 데이터 요소의 개수일 수 있다. The size of the target array may be the number of data elements included in the target array.
이제 도 12b를 참조하여, 본 발명의 다른 실시예에 따라 제공되는 제2인스트럭션의 실행 방법을 설명한다.Now, with reference to FIG. 12B, a method of executing the second instruction provided according to another embodiment of the present invention will be described.
컴퓨팅 장치가 상기 제2인스트럭션을 호출하면 제2인스트럭션 실행 방법이 시작된다.When the computing device calls the second instruction, the second instruction execution method begins.
상기 제2인스트럭션 실행 방법은, pad, s_idx, valid, 및 rpad를 포함하는 한 세트의 변수에 대한 제어 권한, 소정의 제1레지스터의 기록 권한, 및 메모리에 대한 읽기 권한을 필요로 한다. The second instruction execution method requires control rights to a set of variables including pad, s_idx, valid, and rpad, write rights to a predetermined first register, and read rights to memory.
본 발명의 다른 실시예에 따라 제공되는 제2인스트럭션의 실행 방법은 아래 단계들을 포함한다.A method of executing the second instruction provided according to another embodiment of the present invention includes the following steps.
단계(S2130)에서, lpad가 0(영)보다 큰지 확인한다. 0보다 크면 단계(S2210)로 진행하고, 크지 않으면 단계(S2310)로 진행한다. In step S2130, it is checked whether lpad is greater than 0 (zero). If it is greater than 0, proceed to step (S2210), and if it is not greater than 0, proceed to step (S2310).
단계(S2310)에서, valid가 0(영)보다 큰지 확인한다. 0보다 크면 단계(S2320)로 진행하고, 크지 않으면 단계(S2410)로 진행한다. In step S2310, it is checked whether valid is greater than 0 (zero). If it is greater than 0, proceed to step (S2320), and if not greater than 0, proceed to step (S2410).
단계(S2410)에서, rpad가 1보다 큰지 확인한다. 1보다 크면 단계(S2420)로 진행하고, 크지 않으면 종료한다.In step S2410, it is checked whether rpad is greater than 1. If it is greater than 1, it proceeds to step (S2420), and if it is not greater than 1, it ends.
단계(S2210)에서, 미리 결정된 패딩값을 제1레지스터에 저장한다. 그 다음, 단계(S2220)에서 lpad를 상기 제1값만큼 감소시킨 후 상기 제2인스트럭션의 실행을 종료한다.In step S2210, a predetermined padding value is stored in the first register. Next, in step S2220, lpad is decreased by the first value and then execution of the second instruction is terminated.
단계(S2320)에서, s_idx가 가리키는 메모리 주소에 저장된 값을 상기 제1레지스터에 저장한다. 그 다음, 단계(S2330)에서 valid를 상기 제2값만큼 감소시키고 s_idx를 상기 제3값만큼 증가시킨 후 상기 제2인스트럭션의 실행을 종료한다.In step S2320, the value stored at the memory address indicated by s_idx is stored in the first register. Next, in step S2330, valid is decreased by the second value, s_idx is increased by the third value, and execution of the second instruction is terminated.
만일 상기 메모리의 서로 인접한 두 개의 주소값들의 차이의 노미널 값이 ndv라고 한다면, 단계(S2330)에서 s_idx를 ndv만큼 증가시킬 수 있다.If the nominal value of the difference between two adjacent address values of the memory is ndv, s_idx can be increased by ndv in step S2330.
단계(S2420)에서, 상기 미리 결정된 패딩값을 상기 제1레지스터에 저장한다. 그 다름, 단계(S2430)에서 rpad를 상기 제4값만큼 감소시킨 후 상기 제2인스트럭션의 실행을 종료한다.In step S2420, the predetermined padding value is stored in the first register. Otherwise, in step S2430, rpad is decreased by the fourth value and then execution of the second instruction is terminated.
상술한 본 발명의 실시예들을 이용하여, 본 발명의 기술분야에 속하는 자들은 본 발명의 본질적인 특성에서 벗어나지 않는 범위 내에 다양한 변경 및 수정을 용이하게 실시할 수 있을 것이다. 특허청구범위의 각 청구항의 내용은 본 명세서를 통해 이해할 수 있는 범위 내에서 인용관계가 없는 다른 청구항에 결합될 수 있다.By using the above-described embodiments of the present invention, those in the technical field of the present invention will be able to easily make various changes and modifications without departing from the essential characteristics of the present invention. The contents of each claim in the patent claims can be combined with other claims without reference within the scope that can be understood through this specification.

Claims (14)

  1. 컴퓨팅 장치가 인스트럭션을 실행하는 인스트럭션 실행방법으로서,As an instruction execution method in which a computing device executes an instruction,
    상기 인스트럭션의 호출이 발생하면, 제1변수(lpad)를 미리 결정된 제1상수와 비교하는 제1단계; 및When the instruction is called, a first step of comparing a first variable (lpad) with a predetermined first constant; and
    제1레지스터에 미리 결정된 패딩값 또는 메모리에 저장된 값을 저장한 후 상기 인스트럭션의 실행을 종료하는 제2단계;A second step of terminating execution of the instruction after storing a predetermined padding value in a first register or a value stored in a memory;
    를 포함하며,Includes,
    상기 제2단계에서, In the second step,
    만일 상기 제1변수가 상기 제1상수보다 크다면, 상기 미리 결정된 패딩값을 상기 제1레지스터에 저장하고, 그리고 상기 제1변수를 제1값만큼 감소시킨 후 상기 제1인스트럭션의 실행을 종료하도록 되어 있고, If the first variable is greater than the first constant, store the predetermined padding value in the first register, decrease the first variable by the first value, and then terminate execution of the first instruction. It is done,
    만일 상기 제1변수가 상기 제1상수보다 크지 않다면, 제2변수(valid)를 미리 결정된 제2상수와 비교하도록 되어 있고, If the first variable is not greater than the first constant, the second variable (valid) is compared with a predetermined second constant,
    만일 상기 제2변수가 상기 제2상수보다 크다면, 제3변수(s_idx)가 가리키는 메모리 주소에 저장되어 있는 값을 상기 제1레지스터에 저장하고, 상기 제2변수를 제2값만큼 감소시키고, 그리고 상기 제3변수를 소정의 제3값만큼 증가시킨 후 상기 제1인스트럭션의 실행을 종료하도록 되어 있고, 그리고 If the second variable is greater than the second constant, the value stored at the memory address indicated by the third variable (s_idx) is stored in the first register, and the second variable is decreased by the second value, And the execution of the first instruction is terminated after increasing the third variable by a predetermined third value, and
    만일 상기 제2변수가 상기 제2상수보다 크지 않다면, 미리 결정된 상기 패딩값을 상기 제1레지스터에 저장한 후에 상기 제1인스트럭션의 실행을 종료하도록 되어 있는, If the second variable is not greater than the second constant, execution of the first instruction is terminated after storing the predetermined padding value in the first register.
    인스트럭션 실행방법.Instruction execution method.
  2. 제1항에 있어서,According to paragraph 1,
    상기 인스트럭션의 호출이 발생하기 이전에, 제1변수(lpad), 제2변수(valid), 및 제3변수(s_idx)를 초기화하는 단계를 더 포함하며,Before calling the instruction, it further includes initializing a first variable (lpad), a second variable (valid), and a third variable (s_idx),
    상기 제1변수(lpad)는 미리 계획된 소정의 연산에서 이용되는 패딩의 최대 개수를 갖도록 초기화되며,The first variable (lpad) is initialized to have the maximum number of padding used in a predetermined operation,
    상기 제2변수(valid)는 상기 미리 계획된 소정의 연산의 대상인 대상 어레이의 크기를 갖도록 초기화되고, 그리고 The second variable (valid) is initialized to have the size of the target array that is the target of the predetermined operation, and
    상기 제3변수(s_idx)는 상기 대상 어레이에 대응하는 정보를 포함하는 메모리의 일 영역을 나타내는 주소 중 첫 번째 주소를 갖도록 초기화되는,The third variable (s_idx) is initialized to have the first address among addresses representing an area of memory containing information corresponding to the target array,
    인스트럭션 실행방법.Instruction execution method.
  3. 제1항에 있어서, 상기 소정의 제3값은, 상기 메모리의 일 영역 중 서로 인접한 두 개의 데이터를 나타내는 주소들 간의 차이값인, 인스트럭션 실행방법.The method of claim 1, wherein the predetermined third value is a difference value between addresses representing two adjacent pieces of data in an area of the memory.
  4. 제1항에 있어서, 상기 제1상수는 0(영)이고, 상기 제2상수는 0(영)인, 인스트럭션 실행방법.The method of claim 1, wherein the first constant is 0 (zero) and the second constant is 0 (zero).
  5. 컴퓨팅 장치가 미리 계획된 소정의 연산을 실행하는 연산방법으로서,As a calculation method in which a computing device executes a predetermined calculation,
    제1변수(lpad), 제2변수(valid), 및 제3변수(s_idx)를 초기화하는 단계;Initializing a first variable (lpad), a second variable (valid), and a third variable (s_idx);
    소정의 인스트럭션 실행방법을 1회 실행하거나 또는 복수 회 반복하여 실행함으로써, 소정의 가변 어레이의 모든 요소들의 값을 결정하는 단계; 및determining the values of all elements of a predetermined variable array by executing a predetermined instruction execution method once or repeatedly; and
    상기 모든 요소들의 값이 결정된 상기 가변 어레이에 대하여 상기 미리 계획된 소정의 연산을 실행하여, 미리 계획된 출력 어레이 중 적어도 일부의 데이터를 생성하는 단계;executing the pre-planned operation on the variable array for which values of all the elements have been determined, thereby generating data for at least some of the pre-planned output array;
    를 포함하며,Includes,
    상기 소정의 인스트럭션 실행방법은, The method of executing the given instruction is,
    소정의 인스트럭션에 대한 호출이 발생하면, 상기 제1변수(lpad)를 미리 결정된 제1상수와 비교하는 제1단계, 및 미리 결정된 패딩값 또는 메모리에 저장된 값을 제1레지스터에 저장한 후 상기 인스트럭션의 실행을 종료하는 제2단계를 포함하는 인스트럭션 실행단계, 및 When a call to a predetermined instruction occurs, the first step is to compare the first variable (lpad) with a predetermined first constant, and the predetermined padding value or the value stored in the memory is stored in the first register and then the instruction an instruction execution step including a second step of terminating execution of
    상기 제1레지스터에 저장된 값을 상기 가변 어레이에 기록하는 단계 Writing the value stored in the first register to the variable array
    를 포함하는,Including,
    연산방법.Calculation method.
  6. 제5항에 있어서, According to clause 5,
    상기 제1변수(lpad)는 상기 미리 계획된 소정의 연산에서 이용되는 패딩의 최대 개수를 갖도록 초기화되며,The first variable (lpad) is initialized to have the maximum number of padding used in the predetermined operation,
    상기 제2변수(valid)는 상기 미리 계획된 소정의 연산의 대상인 대상 어레이의 크기를 갖도록 초기화되고, 그리고 The second variable (valid) is initialized to have the size of the target array that is the target of the predetermined operation, and
    상기 제3변수(s_idx)는 상기 대상 어레이에 대응하는 정보를 포함하는 메모리의 일 영역을 나타내는 주소 중 첫 번째 주소를 갖도록 초기화되는,The third variable (s_idx) is initialized to have the first address among addresses representing an area of memory containing information corresponding to the target array,
    연산방법.Calculation method.
  7. 제5항에 있어서, According to clause 5,
    상기 제2단계에서, In the second step,
    만일 상기 제1변수가 상기 제1상수보다 크다면, 상기 미리 결정된 패딩값을 상기 제1레지스터에 저장하고, 그리고 상기 제1변수를 제1값만큼 감소시킨 후 상기 제1인스트럭션의 실행을 종료하도록 되어 있고, If the first variable is greater than the first constant, store the predetermined padding value in the first register, decrease the first variable by the first value, and then terminate execution of the first instruction. It is done,
    만일 상기 제1변수가 상기 제1상수보다 크지 않다면, 제2변수(valid)를 미리 결정된 제2상수와 비교하도록 되어 있고, If the first variable is not greater than the first constant, the second variable (valid) is compared with a predetermined second constant,
    만일 상기 제2변수가 상기 제2상수보다 크다면, 제3변수(s_idx)가 가리키는 메모리 주소에 저장되어 있는 값을 상기 제1레지스터에 저장하고, 상기 제2변수를 제2값만큼 감소시키고, 그리고 상기 제3변수를 소정의 제3값만큼 증가시킨 후 상기 제1인스트럭션의 실행을 종료하도록 되어 있고, 그리고 If the second variable is greater than the second constant, the value stored at the memory address indicated by the third variable (s_idx) is stored in the first register, and the second variable is decreased by the second value, And the execution of the first instruction is terminated after increasing the third variable by a predetermined third value, and
    만일 상기 제2변수가 상기 제2상수보다 크지 않다면, 미리 결정된 상기 패딩값을 상기 제1레지스터에 저장한 후에 상기 제1인스트럭션의 실행을 종료하도록 되어 있는, If the second variable is not greater than the second constant, execution of the first instruction is terminated after storing the predetermined padding value in the first register.
    연산방법.Calculation method.
  8. 제7항에 있어서, In clause 7,
    상기 제1상수는 0(영)이고, The first constant is 0 (zero),
    상기 제2상수는 0(영)이며,The second constant is 0 (zero),
    상기 제1값은 1이고,The first value is 1,
    상기 제2값은 1이며,The second value is 1,
    상기 소정의 제3값은, 상기 메모리의 일 영역 중 서로 인접한 두 개의 데이터를 나타내는 주소들 간의 차이값인, The predetermined third value is a difference value between addresses representing two adjacent data in an area of the memory,
    연산방법.Calculation method.
  9. 제5항에 있어서, 상기 미리 계획된 소정의 연산은 풀링 연산인, 연산방법.The method according to claim 5, wherein the predetermined operation is a pooling operation.
  10. 제9항에 있어서, 상기 가변 어레이의 크기는 상기 풀링 연산을 위한 풀링 윈도우의 크기와 동일한, 연산방법.The method of claim 9, wherein the size of the variable array is equal to the size of a pooling window for the pooling operation.
  11. 제5항에 있어서, 상기 미리 계획된 소정의 연산은 콘볼루션 연산인, 연산방법.The method according to claim 5, wherein the predetermined operation is a convolution operation.
  12. 제11항에 있어서, 상기 가변 어레이의 크기는 상기 콘볼루션 연산을 위해 사용되는 커널의 크기와 동일한, 연산방법.The method of claim 11, wherein the size of the variable array is the same as the size of the kernel used for the convolution operation.
  13. 제5항에 있어서, According to clause 5,
    상기 인스트럭션 실행방법이 실행될 때마다, 상기 제1레지스터에 저장된 값은, 상기 가변 어레이 중 소정의 제1포인터가 가리키는 요소에 기록되도록 되어 있고, Whenever the instruction execution method is executed, the value stored in the first register is written to an element pointed to by a predetermined first pointer in the variable array,
    상기 인스트럭션 실행방법이 실행될 때마다, 상기 제1포인터가 가리키는 상기 가변 어레이의 요소는 변경되도록 되어 있는,Each time the instruction execution method is executed, the element of the variable array pointed to by the first pointer is changed.
    연산방법. Calculation method.
  14. 하드웨어 가속기(110)를 포함하는 컴퓨팅 장치로서,A computing device comprising a hardware accelerator (110),
    상기 하드웨어 가속기는, 제1항 내지 제4항 중 어느 한 항의 인스트럭션 실행방법 또는 제5항 내지 제13항 중 어느 한 항의 연산방법을 실행하도록 되어 있는, The hardware accelerator is configured to execute the instruction execution method of any one of claims 1 to 4 or the calculation method of any one of claims 5 to 13,
    컴퓨팅 장치.Computing device.
PCT/KR2022/021128 2022-08-30 2022-12-22 Computation method in neural network and device therefor WO2024048868A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020220109294A KR20240030359A (en) 2022-08-30 2022-08-30 Operation method at neural network and device for the same
KR10-2022-0109294 2022-08-30

Publications (1)

Publication Number Publication Date
WO2024048868A1 true WO2024048868A1 (en) 2024-03-07

Family

ID=90098108

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2022/021128 WO2024048868A1 (en) 2022-08-30 2022-12-22 Computation method in neural network and device therefor

Country Status (2)

Country Link
KR (1) KR20240030359A (en)
WO (1) WO2024048868A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101013275B1 (en) * 2007-02-01 2011-02-09 인터내셔널 비지네스 머신즈 코포레이션 Controlling instruction execution in a processing environment
JP6536266B2 (en) * 2015-08-03 2019-07-03 富士通株式会社 Compilation device, compilation method and compilation program
KR102358149B1 (en) * 2021-06-18 2022-02-08 주식회사 위스타 Padding method for convolutional neural network
KR102418794B1 (en) * 2020-06-02 2022-07-08 오픈엣지테크놀로지 주식회사 Method of accessing parameters for a hardware accelerator from a memory and a device for the same
KR102432254B1 (en) * 2019-05-16 2022-08-12 삼성전자주식회사 Method for performing convolution operation at predetermined layer within the neural network by electronic device, and electronic device thereof

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101013275B1 (en) * 2007-02-01 2011-02-09 인터내셔널 비지네스 머신즈 코포레이션 Controlling instruction execution in a processing environment
JP6536266B2 (en) * 2015-08-03 2019-07-03 富士通株式会社 Compilation device, compilation method and compilation program
KR102432254B1 (en) * 2019-05-16 2022-08-12 삼성전자주식회사 Method for performing convolution operation at predetermined layer within the neural network by electronic device, and electronic device thereof
KR102418794B1 (en) * 2020-06-02 2022-07-08 오픈엣지테크놀로지 주식회사 Method of accessing parameters for a hardware accelerator from a memory and a device for the same
KR102358149B1 (en) * 2021-06-18 2022-02-08 주식회사 위스타 Padding method for convolutional neural network

Also Published As

Publication number Publication date
KR20240030359A (en) 2024-03-07

Similar Documents

Publication Publication Date Title
WO2014171705A1 (en) Method for adjusting display area and electronic device thereof
WO2016064131A1 (en) Data processing method and device
WO2019168315A1 (en) Trustzone graphic rendering method and display device using the same
WO2019172685A1 (en) Electronic apparatus and control method thereof
WO2018056642A2 (en) Electronic device and method thereof for managing applications
WO2018076453A1 (en) Associated application display method, device and mobile terminal
WO2017159931A1 (en) Electronic device including touch panel and method of controlling the electronic device
WO2024048868A1 (en) Computation method in neural network and device therefor
WO2021125496A1 (en) Electronic device and control method therefor
WO2023042989A1 (en) Add operation method considering data scale, hardware accelerator therefor, and computing device using same
WO2019074185A1 (en) Electronic apparatus and control method thereof
EP3659073A1 (en) Electronic apparatus and control method thereof
WO2023229094A1 (en) Method and apparatus for predicting actions
WO2022045448A1 (en) Method for compressing output data of hardware accelerator, method for decoding data inputted into hardware accelerator, and hardware accelerator therefor
WO2021172708A1 (en) Method for processing cache barrier command for disk array, and device therefor
WO2012169675A1 (en) Method and apparatus for dividing node of multiway search tree based on integrated moving average
WO2017206882A1 (en) Sensor control method and apparatus, storage medium, and electronic device
WO2024076165A1 (en) Method for generating command set for neural network operation, and computing device for same
WO2021010558A1 (en) Terminal, control method therefor, and recording medium in which program for implementing method is recorded
WO2022154326A1 (en) Method, device, and computer program for managing virtualized resource
WO2024014631A1 (en) Quantization method for convolutional data considering data scale, hardware accelerator therefor, and computing apparatus using same
WO2022154329A1 (en) Method and apparatus for recommending size of resource, and computer program
WO2023219275A1 (en) Image processing device and method for operating same
WO2023113089A1 (en) Method for assetizing training data for training artificial neural network
WO2024096381A1 (en) Method for partitioning and simulating neural network and activation, and computing device for same

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22957544

Country of ref document: EP

Kind code of ref document: A1