Memory mapping method and apparatus
A memory mapping method includes storing a feature map including a plurality of sets of data used for a neural network operation in a memory, shifting a position of a portion of the data included in the feature map that is stored in the memory based on a parameter of the neural network operation, and outputting data requested by the neural network operation from the feature map in which the position of the portion is shifted based on a memory bandwidth.
1 . A memory mapping method, comprising:
storing, in a memory, a feature map comprising a plurality of sets of data used for a neural network operation;
shifting a position of a portion of the data comprised in the feature map that is stored in the memory based on a parameter of the neural network operation; and
outputting data requested by the neural network operation from the feature map in which the position of the portion of the data is shifted based on a memory bandwidth.
2 . The memory mapping method of claim 1 , wherein the shifting comprises:
shifting the position of the portion of the data by a different interval based on a position of a row of the feature map or a position of a column of the feature map.
3 . The memory mapping method of claim 1 , wherein the shifting comprises:
shifting the position of the portion of the data by performing padding on a row or a column of the feature map.
4 . The memory mapping method of claim 3 , wherein the shifting of the position of the portion of the data by performing padding on the row or the column of the feature map comprises:
performing padding based on the memory bandwidth and a kernel size of the neural network operation.
5 . The memory mapping method of claim 1 , wherein the shifting comprises:
shifting data in a row or a column of the feature map by a predetermined interval.
6 . The memory mapping method of claim 5 , wherein the shifting of the data in the row or the column of the feature map by the predetermined interval comprises:
determining the interval based on the memory bandwidth, a kernel size of the neural network operation, and a size of the feature map.
7 . The memory mapping method of claim 1 , wherein the shifting comprises:
shifting the position of the portion of the data based on a lookup table that stores a degree of shifting in a row or a column of the feature map.
8 . The memory mapping method of claim 7 , wherein the shifting of the position of the portion of the data based on the lookup table that stores a degree of shifting in the row or the column of the feature map comprises:
shifting the position of the portion of the data based on coordinates of the sets of the data and a special purpose register.
9 . The memory mapping method of claim 1 , wherein the shifting comprises:
shifting the position of the portion of the data based on a stride corresponding to a width direction of the feature map, a height direction of the feature map, or a channel direction of the feature map.
10 . A non-transitory computer-readable storage medium storing instructions that, when executed by a processor, cause the processor to perform the image-memory mapping method of claim 1 .
11 . A memory mapping apparatus, comprising:
a memory configured to store therein a feature map comprising a plurality of sets of data used for a neural network operation; and
a processor configured to shift a position of a portion of the data comprised in the feature map that is stored in the memory based on a parameter of the neural network operation, and to output data requested by the neural network operation from the feature map in which the position of the portion of the data is shifted based on a memory bandwidth.
12 . The memory mapping apparatus of claim 11 , wherein the processor is configured to:
shift the position of the portion of the data by a different interval based on a position of a row of the feature map or a position of a column of the feature map.
13 . The memory mapping apparatus of claim 11 , wherein the processor is configured to:
shift the position of the portion of the data by performing padding on a row or a column of the feature map.
14 . The memory mapping apparatus of claim 13 , wherein the processor is configured to:
perform padding based on the memory bandwidth and a kernel size of the neural network operation.
15 . The memory mapping apparatus of claim 11 , wherein the processor is configured to:
shift data in a row or a column of the feature map by a predetermined interval.
16 . The memory mapping apparatus of claim 15 , wherein the processor is configured to:
determine the interval based on the memory bandwidth, a kernel size of the neural network operation, and a size of the feature map.
17 . The memory mapping apparatus of claim 11 , wherein the processor is configured to:
shift the position of the portion of the data based on a lookup table that stores a degree of shifting in a row or a column of the feature map.
18 . The memory mapping apparatus of claim 17 , wherein the processor is configured to:
shift the position of the portion of the data based on coordinates of the sets of the data and a special purpose register.
19 . The memory mapping apparatus of claim 11 , wherein the processor is configured to:
shift the position of the portion of the data based on a stride corresponding to a width direction of the feature map, a height direction of the feature map, and a channel direction of the feature map.