WO2023121263A1 - 전자 장치 및 전자 장치의 제어 방법 - Google Patents

전자 장치 및 전자 장치의 제어 방법 Download PDF

Info

Publication number
WO2023121263A1
WO2023121263A1 PCT/KR2022/020897 KR2022020897W WO2023121263A1 WO 2023121263 A1 WO2023121263 A1 WO 2023121263A1 KR 2022020897 W KR2022020897 W KR 2022020897W WO 2023121263 A1 WO2023121263 A1 WO 2023121263A1
Authority
WO
WIPO (PCT)
Prior art keywords
tensor
tensors
execution order
electronic device
layer
Prior art date
Application number
PCT/KR2022/020897
Other languages
English (en)
French (fr)
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
Priority claimed from KR1020220031573A external-priority patent/KR20230095759A/ko
Application filed by 삼성전자주식회사 filed Critical 삼성전자주식회사
Publication of WO2023121263A1 publication Critical patent/WO2023121263A1/ko

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • the present disclosure relates to an electronic device and a control method of the electronic device, and more specifically, to an electronic device capable of learning a neural network model and a control method thereof.
  • the neural network model can be installed and operated on a user's personal terminal after being learned on a server based on a large amount of data and vast resources.
  • considerable service cost is consumed in order to personalize the neural network according to all users in the server.
  • An object of the present disclosure is to provide an electronic device and a control method of the electronic device capable of significantly reducing memory usage in the process of learning a neural network model.
  • an electronic device includes a memory for storing data related to a neural network model and a learning step performed through a plurality of layers of the neural network model, a forward propagation step, a gradient Dividing into a plurality of steps including a (gradient) calculation step and a derivative calculation step, determining an execution order of the plurality of steps, and based on the determined execution order, a plurality of tensors used in the plurality of layers Obtains first information on which of a plurality of steps according to the determined execution order is used, and determines whether tensors used in adjacent layers among the first information and the plurality of layers can be shared.
  • the first information may be determined based on information about a type of a step in which the plurality of tensors are used among the plurality of steps.
  • the types of steps in which the plurality of tensors are used include the forward propagation step, the gradient calculation step, the derivative calculation step, the back propagation step including the gradient calculation step and the derivative calculation step, the forward propagation step and the It may include a step including a back propagation step and a type representing each of the entire training steps of the neural network model.
  • the second information includes first mode information indicating that a tensor is in a pre-allocated state, second mode information indicating that a tensor should be newly created, and tensor data may be changed, but the tensor may be shared with other tensors of an adjacent layer.
  • the execution order of the step in which the first tensor is used last among the plurality of tensors is the same as the execution order of the step in which the second tensor of the layer adjacent to the layer of the first tensor is used first. If early, at least part of the determined execution order may be merged such that the first tensor and the second tensor are shared.
  • the execution order of the step in which the first tensor is used last among the plurality of tensors is slower than the execution order in the step in which the second tensor of the layer adjacent to the layer of the first tensor is used first .
  • the second information corresponding to the second tensor is the fourth mode information, at least a part of the determined execution order may be integrated so that the first tensor and the second tensor are shared.
  • the processor determines whether to additionally create a memory area for allocating data corresponding to the plurality of tensors or overwrite a previously created memory area based on the integrated execution order By doing so, the area of the memory can be minimized.
  • a method for controlling an electronic device includes a learning step performed through a plurality of layers of a neural network model, a forward propagation step, a gradient calculation step, and a derivative calculation step. determining an execution order of the plurality of steps by dividing them into a plurality of steps including steps, and determining an execution order of the plurality of steps, based on the determined execution order, a plurality of tensors used in the plurality of layers according to the determined execution order Obtaining first information about which step is used among a plurality of steps, based on the first information and second information about whether tensors used in adjacent layers among the plurality of layers can be shared integrating the determined execution order; allocating the data to the plurality of tensors by minimizing an area of the memory for allocating data corresponding to the plurality of tensors based on the integrated execution order; and and learning the neural network model according to the integrated execution order using tensors of and the data
  • the first information may be determined based on information about a type of a step in which the plurality of tensors are used among the plurality of steps.
  • the types of steps in which the plurality of tensors are used include the forward propagation step, the gradient calculation step, the derivative calculation step, the back propagation step including the gradient calculation step and the derivative calculation step, the forward propagation step and the It may include a step including a back propagation step and a type representing each of the entire training steps of the neural network model.
  • the second information includes first mode information indicating that a tensor is in a pre-allocated state, second mode information indicating that a tensor should be newly created, and tensor data may be changed, but the tensor may be shared with other tensors of an adjacent layer.
  • the execution order of the step in which the first tensor is used last among the plurality of tensors is the step in which the second tensor of the layer adjacent to the layer of the first tensor is used first. If it is equal to or earlier than the execution order of , at least a part of the determined execution order may be integrated so that the first tensor and the second tensor are shared.
  • the execution order of the step in which the first tensor is used last among the plurality of tensors is the step in which the second tensor of the layer adjacent to the layer of the first tensor is used first. If the second information corresponding to the second tensor is the fourth mode information, at least a part of the determined execution order may be integrated so that the first tensor and the second tensor are shared.
  • the step of allocating the data to the plurality of tensors based on the integrated execution order, whether to additionally create a memory area for allocating data corresponding to the plurality of tensors or previously created memory and minimizing the area of the memory by determining whether to overwrite the area of .
  • the control method of the electronic device includes a neural network model. Determining the execution order of the plurality of steps by dividing the learning step performed through the plurality of layers into a plurality of steps including a forward propagation step, a gradient calculation step, and a derivative calculation step; Based on this, obtaining first information about which step among a plurality of steps according to the determined execution order a plurality of tensors used in the plurality of layers are used, the first information and the plurality of Integrating the determined execution order based on second information about whether tensors used in adjacent layers among the layers can be shared, allocating data corresponding to the plurality of tensors based on the integrated execution order Allocating the data to the plurality of tensors by minimizing the area of the memory for performing the neural network model according to the integrated execution order using the plurality of ten
  • FIG. 1 is a flowchart illustrating a control method of an electronic device according to an embodiment of the present disclosure
  • FIG. 2 is a diagram showing an execution sequence of a plurality of steps according to an embodiment of the present disclosure
  • FIG. 3 is a diagram showing types of steps in which a plurality of tensors are used according to an embodiment of the present disclosure
  • FIG. 4 is a diagram for explaining in detail a process of obtaining first information according to the present disclosure
  • FIG. 5 is a diagram showing mode information for a plurality of tensors according to an embodiment of the present disclosure
  • FIG. 6 is a diagram for explaining a process of integrating an execution order determined based on first information and second information
  • FIG. 7 is a diagram illustrating a method of allocating data to tensors by minimizing a memory area according to an embodiment of the present disclosure
  • FIG. 8 is a diagram showing a method of allocating data to tensors by minimizing a memory area according to another embodiment of the present disclosure
  • FIGS. 9 and 10 are views for explaining a method of reducing data loading time according to an embodiment of the present disclosure.
  • FIG. 11 is a diagram for explaining a method of adjusting the number of layers used in a calculation step of a neural network model according to an embodiment of the present disclosure
  • FIG. 12 is a block diagram briefly illustrating the configuration of an electronic device according to an embodiment of the present disclosure.
  • FIG. 13 is a block diagram showing the configuration of an electronic device according to an embodiment of the present disclosure in detail.
  • expressions such as “has,” “can have,” “includes,” or “can include” indicate the presence of a corresponding feature (eg, numerical value, function, operation, or component such as a part). , which does not preclude the existence of additional features.
  • expressions such as “A or B,” “at least one of A and/and B,” or “one or more of A or/and B” may include all possible combinations of the items listed together.
  • a component e.g., a first component
  • another component e.g., a second component
  • connection to it should be understood that the certain component may be directly connected to the other component or connected through another component (eg, a third component).
  • the phrase “device configured to” may mean that the device is “capable of” in conjunction with other devices or components.
  • a processor configured (or configured) to perform A, B, and C may include a dedicated processor (eg, embedded processor) to perform the operation, or by executing one or more software programs stored in a memory device.
  • a general-purpose processor eg, CPU or application processor
  • a 'module' or 'unit' performs at least one function or operation, and may be implemented with hardware or software, or a combination of hardware and software.
  • a plurality of 'modules' or a plurality of 'units' may be integrated into at least one module and implemented by at least one processor, except for 'modules' or 'units' that need to be implemented with specific hardware.
  • FIG. 1 is a flowchart illustrating a control method of an electronic device 100 according to an embodiment of the present disclosure.
  • the electronic device 100 refers to a device capable of learning a neural network model.
  • the electronic device 100 may be a user terminal or server such as a smart phone, tablet PC, or smart watch.
  • the type of electronic device 100 according to the present disclosure is not particularly limited. Learning of the neural network model according to the present disclosure may be performed in the form of an on-device within the electronic device 100, but is not limited thereto.
  • a neural network model according to the present disclosure refers to an artificial intelligence model including an artificial neural network, and may be learned by deep learning.
  • the neural network model is at least one of a deep neural network (DNN), a convolution neural network (CNN), a recurrent neural network (RNN), and a generative adversarial network (GAN). It may include one artificial neural network.
  • DNN deep neural network
  • CNN convolution neural network
  • RNN recurrent neural network
  • GAN generative adversarial network
  • the neural network model according to the present disclosure is not limited to the above example.
  • the electronic device 100 divides a learning step performed through a plurality of layers of a neural network model into a plurality of steps including a forward propagation step, a gradient calculation step, and a derivative calculation step, so that a plurality of The execution order of steps may be determined (S110).
  • the learning step of the neural network model may be largely divided into a feedforward (forward propagation) step and a backpropagation step.
  • the forward propagation step refers to a step of obtaining an output value while transferring input values from the input layer to the output layer
  • the back propagation step refers to a step of updating the weights of each layer while transferring a gradient from the output layer to the input layer.
  • the backpropagation process may include a gradient calculation step and a derivative calculation step.
  • the gradient calculation step refers to a step of calculating a gradient for using weights of each layer included in the neural network model for updating
  • the derivative calculation step refers to a step of calculating a derivative of an activation function of each layer.
  • learning of the neural network model includes a model interpretation step (S210) of analyzing a plurality of layers included in the neural network model, a realization step (S220) of materializing the plurality of layers, and determining an execution order between the plurality of layers. It may include determining an execution order (S230), initializing a model for allocating tensors to a plurality of layers (S240), and performing learning based on the initialized model (S250).
  • each of the learning steps for each of a plurality of layers performed in the learning performance step is shown in order.
  • FC is fully connected
  • FW forward
  • BN batch normalization
  • AC activation
  • CG compute gradient
  • CD is an abbreviation for compute derivative.
  • numbers such as 1, 2, 3, 11, 12, 13, 24, 25, 26, etc. represent execution sequences, and only the execution sequences of some steps are shown for convenience of illustration.
  • the back propagation step corresponding to one of the forward propagation steps is divided into a gradient calculation step and a derivative calculation step.
  • steps corresponding to execution sequences 11 and 12 represent a gradient calculation step and a derivative calculation step corresponding to one activation.
  • the learning step performed through the plurality of layers of the neural network model is not simply divided into a forward propagation step and a back propagation step, but a back propagation step in more detail. Accordingly, it can be divided into a gradient calculation step and a derivative calculation step.
  • an execution order may be determined for each detailed step.
  • 'a plurality of steps' means the steps included in the entire learning step of the neural network model as shown in the lower part of FIG. 2, and 'execution order' refers to the execution order assigned to each of the plurality of steps it means.
  • the types and execution order of the layers shown in FIG. 2 are exemplary, and layers other than the layers shown in FIG. 2 may be included in the neural network model, and the backpropagation step may be performed in more detail than shown in FIG. , and assigning an execution order.
  • the electronic device 100 determines which step among the plurality of steps according to the execution order the plurality of tensors used in the plurality of layers are used based on the determined execution order. It is possible to obtain first information about (S120).
  • a tensor is used as a general term for input/output data, weights, gradients, derivatives, etc. used in a neural network model.
  • a tensor includes a specification part including information about dimensions, information about an execution order according to the present disclosure, information about types of steps in which a plurality of tensors are used, and information about modes and specifications of tensors It can be distinguished by a data part meaning data allocated to .
  • An embodiment described below includes a process of defining tensor specifications and a process of allocating data to tensor specifications.
  • the first information may be determined based on information about types of steps in which a plurality of tensors are used among a plurality of steps.
  • the types of steps in which a plurality of tensors are used include, as shown in FIG. 3, a forward propagation step (F), a compute gradient (CG) step, and a compute derivative (CD) step, Representing the back propagation step including the gradient calculation step and the derivative calculation step (backward, B), the step including the forward propagation step and the back propagation step (iteration, I), and the entire learning step of the neural network model (Max, M), respectively. type can be included.
  • FIG. 4 is a diagram for explaining in detail a process of obtaining first information about which step among a plurality of steps according to a determined execution order a plurality of tensors are used.
  • FIG. 4 for convenience of description, a case in which a neural network model includes only three layers is assumed.
  • L n is a layer
  • X n is an input/output tensor
  • D n is a derivative
  • ⁇ W n is a gradient
  • W n is a weight
  • layer L 0 It shows input/output tensors, derivatives, gradients, and weights corresponding to L 1 and L 2 , respectively.
  • the lower right figure 420 of FIG. 4 shows the steps performed through each layer and their execution order.
  • the training steps of the neural network model include a forward propagation step through layer L 0 (execution order 0), a forward propagation step through layer L 1 (execution order 1), and an order through layer L 2 .
  • Propagation step (running order 2), gradient calculation step through layer L 2 (running order 3), derivative calculation step through layer L 2 (running order 4), gradient calculation step through layer L 1 (running order 5),
  • the derivative calculation step through layer L 1 (execution order 6) and the gradient calculation step through layer L 0 (execution order 7) may be performed in this order.
  • a dotted line circle is indicated in execution sequence 8, indicating that the derivative calculation step through the layer L 0 is not required.
  • the left picture 430 of FIG. 4 is a case where the execution order of a plurality of steps is determined as shown in the lower rear figure 420 of FIG. It shows how to obtain the first information.
  • the numbers written in the rows corresponding to each tensor indicate the execution order
  • the information in parentheses is information on the type of step in which a plurality of tensors are used (slash front end in parentheses) and tensors Indicates the mode information corresponding to (the end of the slash in parentheses).
  • mode information corresponding to the tensor will be described later with reference to FIGS. 5 and 6 .
  • the tensor X 0 is executed in an execution order 0 and an execution order 0.
  • First information indicating that it is used in steps corresponding to each of step 7 may be obtained. That is, in the drawing 430 of FIG. 4, 0 and 7 are written in the row corresponding to tensor X 0 to indicate that tensor X 0 is used in steps corresponding to execution order 0 and execution order 7, respectively.
  • a step in which tensor X 1 , a tensor X 2 , and a tensor X 3 are used may be determined similarly to a method for determining a step in which tensor X 0 is used.
  • the electronic device 100 determines that tensor D 3 is used in steps corresponding to execution order 2 and execution order 3, respectively, based on the fact that tensor D 3 is used in the backpropagation step performed in layer L 2 . It is possible to obtain the first information indicating.
  • the step in which tensor D2 and tensor D1 are used may be determined similarly to the method for determining the step in which tensor D 3 is used.
  • the electronic device 100 determines that the tensor ⁇ W 2 is used in steps corresponding to execution order 3 and execution order 4, respectively. It is possible to obtain the first information indicating.
  • the step at which the tensor ⁇ W 1 and the tensor ⁇ W 0 are used can be determined similarly to the method for determining the step at which the tensor ⁇ W 2 is used.
  • the electronic device 100 is based on the fact that the tensor W 0 must be maintained during the entire training phase of the neural network model performed in the layer L 0 , in the step corresponding to the execution order 0 and the execution order 7, respectively, the tensor W 0 First information indicating that it is used may be obtained.
  • the step in which the tensor W 1 and the tensor W 2 are used may be determined similarly to the method for determining the step in which the tensor W 0 is used.
  • the electronic device 100 may integrate an execution order determined based on the first information and second information regarding whether tensors used in adjacent layers among a plurality of layers can be shared ( S130).
  • the second information includes first mode information (place-holder, P) indicating that a tensor has already been created, and second mode information (create, C) indicating that a tensor should be newly created. ), the third mode information (modify view, MV) indicating that the tensor data is changed but the tensor can be shared with other tensors in the adjacent layer, and the tensor data is not changed, so the tensor can be shared with other tensors It may include a plurality of mode information such as fourth mode information (read-only view, RV) indicating that the tensor can be shared with all tensors, and fifth mode information (extend, E) indicating that the tensor can be shared with all tensors.
  • fourth mode information read-only view, RV
  • E extentend, E
  • the first mode information and the second mode information indicate that the tensor cannot be shared with other tensors
  • the third mode information, the fourth mode information, and the fifth mode information indicate that the tensor can be shared with other tensors. indicates that it can Which of the first mode information to the fifth mode information corresponds to the mode information corresponding to the specific tensor may be determined by the electronic device 100 or set by a developer or a user.
  • FIG. 6 is a diagram for explaining a process of integrating the execution order determined based on the first information and the second information.
  • FIG. 6 is a diagram for explaining a process of integrating the execution order determined based on the first information and the second information.
  • L n denotes a layer
  • X n denotes an input/output tensor
  • D n denotes a derivative
  • ⁇ W n denotes a gradient
  • W n denotes a weight. That is, the upper right figure 610 of FIG. 6 includes three layers L 0 included in the neural network model, Input/output tensors, derivatives, gradients, and weights corresponding to L 1 and L 2 , respectively (MV and RV will be described later).
  • the lower right figure 620 of FIG. 6 shows the steps performed through each layer and their execution order.
  • the training steps of the neural network model include a forward propagation step through layer L 0 (execution order 0), a forward propagation step through layer L 1 (execution order 1), and an order through layer L 2 .
  • propagation step (running order 2), derivative calculation step through layer L 2 (running order 4), derivative calculation step through layer L 1 (running order 6), and gradient calculation step through layer L 0 (running order 7).
  • dotted circles are shown in execution order 3, execution order 5, and execution order 8, which are the gradient calculation step through layer L 2 , the gradient calculation step through layer L 1 , and the derivative calculation step through layer L 0 . Indicates that this is not required.
  • the left picture 630 of FIG. 6 shows in which of the plurality of steps according to the determined execution order a plurality of tensors are used when the execution order of a plurality of steps is determined as shown in the lower rear figure 620 of FIG.
  • a method for acquiring the first information and integrating the determined execution order is shown.
  • the numbers written in the rows corresponding to each tensor indicate the execution order
  • the information in parentheses is information on the type of step in which a plurality of tensors are used (parentheses). slash front end in parentheses) and mode information corresponding to the tensor (slash rear end in parentheses).
  • tensor X 0 is used in steps corresponding to execution order 0 and execution order 7, respectively, and tensor X 1 is used in execution order 0 and execution order 1. It is possible to obtain first information indicating that the tensor X 2 is used in a step corresponding to each, that tensor X 2 is used in a step corresponding to each of execution order 1, execution order 2, and execution order 6. Descriptions of D 3 , D 2 , D 1 , ⁇ W 0 and W 0 are omitted.
  • the electronic device 100 may set an execution sequence of a step in which a first tensor is used last among a plurality of tensors in a step in which a layer of the first tensor and a second tensor of a layer adjacent to a layer are used first. If the execution order is equal to or earlier than the execution order, at least a part of the determined execution order may be integrated so that the first tensor and the second tensor are shared.
  • the electronic device 100 if the execution order of the step in which tensor X 1 is used last is not later than the execution order of the step in which tensor X 2 is used first, tensor X 1 and tensor The order of execution can be unified so that X 2 is shared. Specifically, since the step in which tensor X 1 is used last is the step corresponding to execution order 1, and the step in which tensor X 2 is used first is the step corresponding to execution order 1, tensor X 2 is additionally defined. It can be said that there is no need to do this and X 1 can be used as it is.
  • mode information corresponding to tensor X 2 is described as third mode information (modify view, MV), which means that the data of tensor X 1 is changed, but tensor X 2 is changed to another tensor of an adjacent layer in light of the execution order. Indicates that it can be shared with X 1 .
  • the electronic device 100 may set an execution sequence of a step in which a first tensor is used last among a plurality of tensors in a step in which a layer of the first tensor and a second tensor of a layer adjacent to a layer are used first. Even when the execution order is slower than the execution order, if the second information corresponding to the second tensor is the fourth mode information, at least a part of the determined execution order may be integrated so that the first tensor and the second tensor are shared.
  • the electronic device 100 executes tensor X 2 and tensor X 2 even when the execution order of the step in which tensor X 2 is used last is slower than the execution order of the step in which tensor X 3 is used first.
  • the step in which tensor X 2 is used last is a step corresponding to execution order 6, and the step in which tensor X 3 is used first is a step corresponding to execution order 2, but the electronic device 100 Mode information corresponding to X 3 is fourth mode information (read-only view, RV), that is, a mode indicating that tensor X 3 can be integrated with another tensor X 2 of an adjacent layer because the data of tensor X 2 is not changed. Since it is information, we can unify the execution order so that tensor X 2 and tensor X 3 are shared.
  • RV read-only view
  • step S130 according to the present disclosure may not be performed depending on the embodiment.
  • the meaning that the execution order of a plurality of steps is integrated below means not only the case where the sharing of tensors and the integration of the execution order according to step S130 are performed, but also the sharing of tensors and the integration of the execution order are considered, but not performed. Including cases where
  • the electronic device 100 may allocate data to the plurality of tensors by minimizing the memory area for allocating data to the plurality of tensors based on the integrated execution order ( S140).
  • the electronic device 100 determines whether to additionally create a memory area for allocating data corresponding to a plurality of tensors or overwrite a previously created memory area based on the integrated execution sequence.
  • the area of the memory can be minimized by determining
  • FIG. 7 shows a method of allocating data to tensors by minimizing a memory area when tensors used in a plurality of layers and an execution order of a plurality of steps are finally determined according to the embodiment of FIG. 4 .
  • FIG. 6 shows a method of allocating data to tensors by minimizing a memory area when tensors used in a plurality of layers and an execution order of a plurality of steps are finally determined.
  • FIG. 7 sequentially shows tensors used in a plurality of layers in the case of the embodiment of FIG. 4 .
  • Figures 720, 730, and 740 show methods of minimizing a memory area in a process of allocating data to tensors used in a plurality of layers.
  • the electronic device 100 may additionally allocate a memory area corresponding to tensor W 1 . That is, since the validity of tensor W 0 must be guaranteed not only at the step corresponding to execution order 0 but also at the step corresponding to execution order 7, the data corresponding to tensor W 1 is overwritten in the memory area corresponding to tensor W 0.
  • a memory area corresponding to tensor W 1 must be additionally allocated.
  • memory areas corresponding to tensor W 2 , tensor X 0 , tensor X 1 , tensor X 2 and tensor X 3 are additionally allocated.
  • tensor X 3 is used in a step corresponding to execution order 2 and tensor D 3 is used in a step corresponding to execution order 3 and execution order 4, respectively, data corresponding to tensor D 3 You can overwrite the area of memory corresponding to tensor X 3 . Accordingly, the electronic device 100 may use a memory area corresponding to tensor X 3 without additionally allocating a memory area corresponding to tensor D 3 .
  • the fact that tensor X 3 is reused means that a memory area corresponding to tensor X 3 can be used to allocate data to tensor D 3 .
  • the validity of tensor X 2 only needs to be guaranteed until the steps corresponding to execution order 1 and execution order 3, respectively, and tensor D 2 is used in steps corresponding to execution order 4 and execution order 6, respectively. , data corresponding to tensor D 2 can be overwritten in the memory area corresponding to tensor X 2 . Accordingly, the electronic device 100 may use a memory area corresponding to tensor X 2 without additionally allocating a memory area corresponding to tensor D 3 .
  • the fact that tensor X 2 is reused means that a memory area corresponding to tensor X 2 can be used to allocate data to tensor D 2 .
  • the peak memory consumption of FIG. 7 represents the limit of memory capacity allowed to allocate data to tensors, which may vary depending on memory specifications and user/developer settings.
  • the maximum memory consumption according to the example of FIG. 7 is reached. Therefore, the electronic device 100 overwrites data corresponding to tensor D 3 and data corresponding to tensor D 2 in the memory area corresponding to the previously allocated tensor X 3 and the memory area corresponding to the previously allocated tensor X 2 Data can be allocated based on whether it is writable.
  • the maximum memory consumption is not reached in the process of allocating data to the tensor, it is of course possible to use the memory area corresponding to the previously allocated tensor.
  • FIG. 8 sequentially shows tensors used in a plurality of layers in the case of the embodiment of FIG. 6 .
  • Figures 820, 830, and 840 show methods of minimizing a memory area in a process of allocating data to tensors used in a plurality of layers.
  • the electronic device 100 may additionally allocate a memory area corresponding to tensor W 1 .
  • memory areas corresponding to tensor W 2 , tensor X 0 , tensor X 1 , and tensor X 3 are additionally allocated.
  • the omission of tensor X 2 is due to the process of tensor sharing and integration of execution order as described above with reference to FIG. 6 .
  • tensor X 3 is used in a step corresponding to execution order 2 and tensor D 3 is used in a step corresponding to execution order 3 and execution order 4, respectively, data corresponding to tensor D 3 You can overwrite the area of memory corresponding to tensor X 3 . Accordingly, the electronic device 100 may use a memory area corresponding to tensor X 3 without additionally allocating a memory area corresponding to tensor D 3 .
  • tensor ⁇ W 2 is used in steps corresponding to execution order 3 and execution order 4, respectively. Since there is no region in the previously allocated memory that can overwrite tensor ⁇ W 2 , the memory corresponding to tensor ⁇ W 2 Areas are additionally allocated.
  • tensor D 2 is used in steps corresponding to execution order 4 and execution order 7, respectively. Since there is no area in the previously allocated memory that can overwrite tensor D 2 , tensor D The area of memory corresponding to 2 is additionally allocated.
  • tensor ⁇ W 0 is used in the step corresponding to execution order 7, and tensor T 1 , tensor T 2 , tensor D 3 and tensor ⁇ W 2 are all valid until the step corresponding to execution order 7. As long as this is guaranteed, tensor ⁇ W 0 can overwrite the memory area corresponding to tensor T 1 , tensor T 2 , tensor D 3 , or tensor ⁇ W 2 .
  • the electronic device 100 does not additionally allocate a memory area corresponding to tensor ⁇ W 2 and the tensor ⁇ W 0 uses a memory area corresponding to tensor T 1 , tensor T 2 , tensor D 3 or tensor ⁇ W 2 .
  • a fragment exists between the memory area corresponding to the tensor ⁇ W 2 and the memory area corresponding to the tensor D 2 .
  • the electronic device 100 may learn a neural network model according to an integrated execution sequence using a plurality of tensors and data allocated to the plurality of tensors (S150). .
  • the electronic device 100 uses the plurality of tensors and the data allocated to the plurality of tensors.
  • the weight of each of the plurality of layers of the neural network model may be updated by learning the neural network model according to the integrated execution sequence.
  • the neural network model according to the present disclosure is pre-learned by the server and then re-learned by the electronic device 100 according to the present disclosure, the neural network model is converted to the user of the electronic device 100 according to the learning result as described above. It can be personalized to suit you.
  • the electronic device 100 efficiently defines a plurality of tensors and data allocated to the plurality of tensors according to an execution order of a plurality of steps, thereby reducing the amount of memory used. can be minimized. And, accordingly, it is possible to efficiently perform learning of a neural network model for personalization without overhead, especially on-device.
  • 9 and 10 are views for explaining a method of reducing data loading time according to an embodiment of the present disclosure.
  • the loading time refers to data stored in a non-volatile memory such as a flash memory, an embedded multimedia card (eMMC), or the like, in a random access memory (RAM) for data necessary for learning a neural network model. It means the time required in the process of loading into volatile memory such as the global buffer included in the processor. However, there is no particular limitation on which type of storage space to load data into.
  • FIG. 9 shows information obtained when n-th iteration is performed in learning the neural network model
  • FIG. 10 shows information obtained when n+1-th iteration is performed in learning the neural network model.
  • the nth iteration of FIG. 9 is the first iteration
  • the n+1th iteration is the second iteration.
  • L 1 to L 9 denote nine layers included in the neural network model, respectively.
  • the term look a head refers to index information indicating how many steps to consider in advance in each layer. For example, if the look a head of the first layer is 1, only the calculation time required in the first layer and the maximum loading time of data are considered when calculating the first layer, and if the look a head of the second layer is 2, the second layer When calculating a layer, not only the calculation time required for the second layer and the maximum data loading time, but also the calculation time and maximum data loading time required for the third layer, which is the next layer, are considered.
  • computation (T C ) represents a computation time for each layer
  • max load (T L ) represents a maximum loading time of data for each layer
  • diff (T C -T L ) represents a value obtained by subtracting the maximum loading time of data for each layer from the calculation time for each layer.
  • diff represents a value obtained by subtracting the maximum loading time of data for each layer from the calculation time for each layer.
  • diff is a negative number
  • the maximum loading time of the data is longer than the computation time of the corresponding layer, so it can be said that loading must wait.
  • diff is a positive number
  • the maximum data loading time is shorter than the computation time of the corresponding layer, so there is no need to wait for loading, and rather, there is time available for additional data loading.
  • the electronic device 100 first sets look a head to 1 while performing the first iteration, and then calculates the operation time for each layer (T C ) and the maximum loading time of data for each layer ( T L ), and a value (diff) obtained by subtracting the maximum loading time of data for each layer from the calculation time for each layer can be calculated.
  • the calculation time of the layer L 1 is 1 and the maximum loading time is 3, based only on the calculation time required for the layer L 1 and the maximum loading time of data, and thus the calculation time and Information that the difference in maximum loading time is -2 may be obtained.
  • This can be referred to as a case in which data loading has to wait for a time of 2 when performing an operation of layer L 1 .
  • the electronic device 100 calculates that the layer L2 has a calculation time of 5 and a maximum loading time of 0 based on only the calculation time required for the layer L2 and the maximum loading time of the data (that is, data that has already been loaded). ), and thus information that the difference between the calculation time and the maximum loading time is 5 can be obtained. This can be said to be a case where as much as 5 hours can be devoted to data loading when performing the operation of layer L 2 .
  • the electronic device 100 performs calculations on the layers L 3 to L 9 in the same way as the layer L 1 and the layer L 2 , and calculates the calculation time for each layer, the maximum loading time, the calculation time and the maximum The difference between loading times can be calculated.
  • the electronic device 100 may set the difference between the calculation time and the maximum loading time to be 0 or a positive number while updating the look a head while performing the second iteration. Specifically, when a layer having a negative diff value according to the result of performing the first iteration exists, the overall loading delay time can be reduced by performing loading in advance in a layer having a positive diff value among layers preceding the layer.
  • the layer L 1 will be described later and described first from the layer L 2 .
  • the diff value is a positive number, so that the loading delay time of the layer L 2 to layer L 4 is reduced. There is no need to perform pre-loading in layers. This is also the case of the layer L 6 , the layer L 7 , and the layer L 9 .
  • the electronic device 100 may adjust the look a head of the layer L 4 to 2 and increase the maximum loading time by 1 to 3.
  • the diff value of the layer L 4 is still greater than or equal to 0, the loading time delay in the layer L 4 still does not occur, and since the diff value of the L 5 is adjusted to 0, the loading time delay in the L 5 does not occur either.
  • the electronic device 100 may adjust the look a head of the layer L 7 to 1 and increase the maximum loading time by 1 to adjust the look a head to 1.
  • the diff value of layer L 7 is still greater than 0, the loading time delay does not still occur in layer L 7 , but the diff value of L 5 decreases from -2 to -1, but the loading time delay still occurs. can do.
  • the electronic device 100 may adjust the look a head of the layer L 6 to 2 and increase the maximum loading time by 1 to adjust the look a head to 1.
  • the diff value of the layer L 6 is still greater than or equal to 0, the loading time delay does not still occur in the layer L 6 , and since the diff value of the L 8 is adjusted to 0, the loading time delay of the L 8 does not occur either.
  • the description of the layer L 1 has been omitted and the layer L 2 has been described, but learning of the neural network model is repeatedly performed.
  • loading required for the layer L 1 may be performed in advance.
  • the look a head value converges to a value optimized for each layer, and the diff value for each layer may be adjusted to 0 or a positive number.
  • the electronic device 100 can significantly reduce the data loading time required for all layers by balancing the calculation time and data loading time for each of a plurality of layers. As a result, memory usage can be minimized.
  • FIG. 11 is a diagram for explaining a method of adjusting the number of layers used in a calculation step of a neural network model according to an embodiment of the present disclosure.
  • N, N+1, and N+2 in FIG. 11 indicate the number of iterations of the learning process by distinguishing them.
  • Layers indicated by solid lines indicate layers used in the calculation step, and layers indicated by dotted lines indicate layers not used in the calculation step. indicates
  • the calculation step means a forward propagation step.
  • the layer used in the calculation step is a layer that calculates the gradient and updates the weight.
  • the result value calculated in the forward propagation step is used, so it must be loaded into memory until the back propagation step is performed. should be left
  • the layers not used in the calculation step do not update the weights and are used only in the step of calculating the derivative in the back propagation step, there is no need to load the result values calculated in the forward propagation step.
  • the electronic device 100 may use only odd-numbered layers (layer 0 , layer 2 , layer 4 , layer 7 , layer 10 of FIG. 11 ) among all layers in the calculation step in the N-th iteration.
  • odd-numbered layers layer 1 , layer 3 , layer 5 , and layer 9 in FIG. 11
  • the electronic device 100 since the weights of all layers must be updated in learning the neural network model, the electronic device 100, in the N+1 th iteration, selects even-numbered layers (layer 1 , layer 3 , and layer 5 of FIG. 11) among all layers. , layer 9 ) can be used in the calculation step, and odd-numbered layers (layer 0 , layer 2 , layer 4 , layer 7 , layer 10 in FIG. 11) among all layers can be used in the step of calculating the derivative in the back-propagation step. there is.
  • the electronic device 100 uses only odd-numbered layers (layer 0 , layer 2 , layer 4 , layer 7 , and layer 10 in FIG. 11) among all layers in the calculation step, and all layers Even-numbered layers (layer 1 , layer 3 , layer 5 , and layer 9 in FIG. 11) can be used in the step of calculating the derivative in the backpropagation step.
  • the electronic device 100 can effectively train a neural network model while using memory.
  • accuracy of the neural network model may decrease.
  • layers not used in the previous iteration may be involved in the calculation step.
  • the present disclosure may be applied to a case where the electronic device 100 is re-learned for personalization after pre-learning by the server. After all, according to the above-described embodiment, memory usage can be minimized within a range that does not greatly reduce the accuracy of the neural network model.
  • FIG. 12 is a block diagram briefly illustrating a configuration of an electronic device 100 according to an embodiment of the present disclosure
  • FIG. 13 is a block diagram illustrating a detailed configuration of the electronic device 100 according to an embodiment of the present disclosure. am.
  • the electronic device 100 includes a memory 110 and a processor 120.
  • At least one instruction related to the electronic device 100 may be stored in the memory 110 .
  • an operating system (O/S) for driving the electronic device 100 may be stored in the memory 110 .
  • various software programs or applications for operating the electronic device 100 may be stored in the memory 110 according to various embodiments of the present disclosure.
  • the memory 110 may include a semiconductor memory 110 such as a flash memory 110 or a magnetic storage medium such as a hard disk.
  • various software modules for operating the electronic device 100 may be stored in the memory 110 according to various embodiments of the present disclosure, and the processor 120 executes various software modules stored in the memory 110.
  • the operation of the electronic device 100 may be controlled. That is, the memory 110 is accessed by the processor 120, and data can be read/written/modified/deleted/updated by the processor 120.
  • the term memory 110 refers to the memory 110, a ROM (not shown) in the processor 120, a RAM (not shown), or a memory 110 card (not shown) mounted in the electronic device 100. ) (eg, micro SD card, memory 110 stick).
  • the memory 110 may store data related to the neural network model, specifically, information on various parameters including layers and weights of the neural network model.
  • the memory 110 may store a plurality of tensors according to the present disclosure, data allocated to the plurality of tensors, and the like.
  • the memory 110 stores information about execution sequences of a plurality of steps determined according to the present disclosure, first information and second information according to the present disclosure, information about types of steps in which a plurality of tensors are used, and the like. can
  • various information required within the scope of achieving the object of the present disclosure may be stored in the memory 110, and the information stored in the memory 110 may be updated as received from a server or an external device or input by a user. may be
  • the processor 120 controls overall operations of the electronic device 100 . Specifically, the processor 120 is connected to the configuration of the electronic device 100 including the memory 110, and by executing at least one instruction stored in the memory 110 as described above, the electronic device 100 You have full control over the action.
  • Processor 120 may be implemented in a variety of ways.
  • the processor 120 may include an application specific integrated circuit (ASIC), an embedded processor 120, a microprocessor 120, hardware control logic, a hardware finite state machine (FSM), It may be implemented with at least one of the digital signal processor 120 (Digital Signal Processor, DSP).
  • ASIC application specific integrated circuit
  • FSM hardware finite state machine
  • DSP Digital Signal Processor
  • processor 120 may be used to include a Central Processing Unit (CPU), a Graphic Processing Unit (GPU), and a Main Processing Unit (MPU).
  • CPU Central Processing Unit
  • GPU Graphic Processing Unit
  • MPU Main Processing Unit
  • the processor 120 performs a learning step performed through a plurality of layers of a neural network model in a plurality of steps including a forward propagation step, a gradient calculation step, and a derivative calculation step.
  • the processor 120 may perform an execution sequence of a step in which a first tensor is used last among a plurality of tensors, in which a second tensor of a layer adjacent to a layer of the first tensor is used first If it is equal to or earlier than the order, the first tensor and the second tensor may integrate at least part of the determined execution order to be shared.
  • the processor 120 may perform an execution sequence of a step in which a first tensor is used last among a plurality of tensors, in which a second tensor of a layer adjacent to a layer of the first tensor is used first If the second information corresponding to the second tensor is the fourth mode information, at least a part of an execution order determined to be shared between the first tensor and the second tensor may be integrated.
  • the processor 120 determines whether to additionally create a region of the memory 110 for allocating data corresponding to a plurality of tensors or to determine whether to allocate data corresponding to a plurality of tensors based on the integrated execution order or to determine whether the previously created memory 110 ), it is possible to minimize the area of the memory 110 by determining whether to overwrite the area.
  • the processor 120 may further include a tensor management module 121 and a data allocation module 122.
  • a tensor according to the present disclosure is a specification including information on dimensions, information on an execution order according to the present disclosure, information on types of steps in which a plurality of tensors are used, and mode information, etc.
  • the embodiment described with reference to FIGS. 1 to 8 includes a process of defining tensor specifications and a process of allocating data to tensor specifications.
  • the tensor management module 121 refers to a module that controls the process of defining tensor specifications, and may be named as a tensor pool. Specifically, the tensor management module 121 may perform operations according to steps S110, S120, and S130 of FIG. 1 .
  • the data allocation module 122 refers to a module that controls a process of allocating data to tensor specifications, and may be named as a memory planner of the memory 110 . Specifically, the data allocation module 122 may perform an operation according to step S140 of FIG. 1 .
  • the tensor management module 121 and the data allocation module 122 have been described as examples of modules included in the processor 120, but other modules corresponding to various operations according to the present disclosure are hardware modules or software modules. Of course, it can be implemented in a form.
  • functions related to the neural network model as described above may be performed through the memory 110 and the processor 120.
  • the processor 120 may include one or a plurality of processors 120 .
  • one or a plurality of processors 120 is a general-purpose processor 120, such as a CPU, AP, GPU. It may be a graphics-only processor 120 such as a VPU or an artificial intelligence-only processor 120 such as an NPU.
  • One or more processors 120 control the input data to be processed according to the non-volatile memory 110 and predefined operating rules or artificial intelligence models stored in the volatile memory 110 .
  • a predefined action rule or artificial intelligence model is characterized in that it is created through learning.
  • being created through learning means that a predefined operation rule or an artificial intelligence model having desired characteristics is created by applying a learning algorithm to a plurality of learning data.
  • Such learning may be performed in the device itself in which artificial intelligence according to the present disclosure is performed, or may be performed through a separate server/system.
  • An artificial intelligence model may be composed of a plurality of neural network layers. Each layer has a plurality of weight values, and the layer operation is performed through the operation result of the previous layer and the plurality of weight values.
  • Examples of neural networks include Convolutional Neural Network (CNN), Deep Neural Network (DNN), Recurrent Neural Network (RNN), Restricted Boltzmann Machine (RBM), Deep Belief Network (DBN), Bidirectional Recurrent Deep Neural Network (BRDNN), and GAN. (Generative Adversarial Networks) and deep Q-networks (Deep Q-Networks), and the neural network in the present disclosure is not limited to the above-described examples except for the cases specified.
  • a learning algorithm is a method of training a predetermined target device (eg, a robot) using a plurality of learning data so that the predetermined target device can make a decision or make a prediction by itself.
  • Examples of learning algorithms include supervised learning, unsupervised learning, semi-supervised learning, or reinforcement learning, and the learning algorithm in the present disclosure is specified Except for, it is not limited to the above example.
  • the device-readable storage medium may be provided in the form of a non-transitory storage medium.
  • 'non-temporary storage medium' only means that it is a tangible device and does not contain signals (e.g., electromagnetic waves), and this term refers to the case where data is stored semi-permanently in the storage medium and temporary It does not discriminate if it is saved as .
  • a 'non-temporary storage medium' may include a buffer in which data is temporarily stored.
  • the method according to various embodiments disclosed in this document may be included and provided in a computer program product.
  • Computer program products may be traded between sellers and buyers as commodities.
  • a computer program product is distributed in the form of a device-readable storage medium (eg compact disc read only memory (CD-ROM)), or through an application store (eg Play Store TM ) or between two user devices ( It can be distributed (eg downloaded or uploaded) online, directly between smartphones.
  • a computer program product eg, a downloadable app
  • a device-readable storage such as a manufacturer's server, an application store's server, or a relay server's memory 110. It can be at least temporarily stored in a medium or temporarily created.
  • Each of the components may be composed of a single object or a plurality of entities, and some of the sub-components described above are omitted. or other sub-elements may be further included in various embodiments. Alternatively or additionally, some components (eg, modules or programs) may be integrated into one entity and perform the same or similar functions performed by each corresponding component prior to integration.
  • operations performed by modules, programs, or other components may be executed sequentially, in parallel, repetitively, or heuristically, or at least some operations may be executed in a different order, may be omitted, or other operations may be added.
  • unit or “module” used in the present disclosure includes units composed of hardware, software, or firmware, and may be used interchangeably with terms such as logic, logic blocks, parts, or circuits, for example.
  • a “unit” or “module” may be an integrated component or a minimum unit or part thereof that performs one or more functions.
  • the module may be composed of an application-specific integrated circuit (ASIC).
  • ASIC application-specific integrated circuit
  • Various embodiments of the present disclosure may be implemented as software including commands stored in a storage medium readable by a machine (eg, a computer).
  • the device calls the stored commands from the storage medium.
  • a device capable of operating according to the called command it may include an electronic device (eg, the electronic device 100) according to the disclosed embodiments.
  • the processor may directly or use other elements under the control of the processor to perform a function corresponding to the command.
  • An instruction may include code generated or executed by a compiler or interpreter.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Biophysics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Neurology (AREA)
  • Image Analysis (AREA)

Abstract

전자 장치 및 전자 장치의 제어 방법이 개시된다. 구체적으로, 본 개시에 따른 전자 장치는 신경망 모델에 관련된 데이터를 저장하는 메모리 및 신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 복수의 단계의 실행 순서를 결정하고, 결정된 실행 순서에 기초하여, 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하며, 제1 정보 및 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 결정된 실행 순서를 통합하고, 통합된 실행 순서에 기초하여, 복수의 텐서에 대응되는 데이터를 할당하기 위한 메모리의 영역을 최소화하여 복수의 텐서에 데이터를 할당하며, 복수의 텐서 및 복수의 텐서들에 할당된 데이터를 이용하여 통합된 실행 순서에 따라 신경망 모델을 학습시키는 프로세서를 포함한다. 그 밖에도 다양한 실시 예가 가능하다.

Description

전자 장치 및 전자 장치의 제어 방법
본 개시는 전자 장치 및 전자 장치의 제어 방법에 관한 것으로서, 구체적으로는 신경망 모델을 학습시킬 수 있는 전자 장치 및 이의 제어 방법에 관한 것이다.
근래에는 인공지능 모델, 머신 러닝(machine learning), 딥 러닝(deep learning)에 관련된 기술이 발전함에 따라, 사용자 개인의 단말 내에서도 다양한 유형의 신경망 모델이 구현되어 사용자에게 다양한 서비스를 제공하고 있다.
신경망 모델은 다량의 데이터와 방대한 리소스를 기반으로 서버에서 학습된 후 사용자 개인의 단말에 설치되어 동작할 수 있다. 그런데, 서버에서의 학습만으로는 사용자 개인의 특성에 맞게 개인화(personalization) 되기 어렵다는 문제가 있다. 이러한 문제를 해결하기 위해 사용자의 개인 데이터를 서버로 전송하고 신경망 모델을 다시 학습시키는 방법도 있으나, 사용자의 개인 데이터를 서버로 전송하는 경우에는 보안에 취약할 수 있으며 사용자 개인의 프라이버시(privacy) 침해의 문제가 발생할 수 있다. 뿐만 아니라, 서버에서 모든 사용자에 맞추어 신경망을 개인화하기 위해서는 상당한 서비스 비용이 소모된다는 문제도 있다.
따라서 최근에는 사용자 개인의 단말 내에서 온 디바이스(on-device)로 신경망 모델을 효율적으로 학습시키는 것에 관련된 기술이 주목받고 있다. 그런데, 온 디바이스로 신경망 모델을 학습시키는 것에 있어서는, 사용자 개인의 단말이 가지고 있는 자원의 한계(limitation of computing resources)와 사용자 데이터가 한정적이라는 한계가 있으며, 따라서 이러한 한계를 극복할 수 있는 기술이 필요한 실정이다.
본 개시는 상술한 바와 같은 필요성에 따른 것으로서, 본 개시의 목적은 신경망 모델의 학습 과정에서 메모리 사용량을 현저하게 감소시킬 수 있는 전자 장치 및 전자 장치의 제어 방법을 제공함에 있다.
상술한 바와 같은 목적을 달성하기 위한 본 개시의 일 실시 예에 따르면, 전자 장치는 신경망 모델에 관련된 데이터를 저장하는 메모리 및 상기 신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 상기 복수의 단계의 실행 순서를 결정하고, 상기 결정된 실행 순서에 기초하여, 상기 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 상기 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하며, 상기 제1 정보 및 상기 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 상기 결정된 실행 순서를 통합하고, 상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 상기 메모리의 영역을 최소화하여 상기 복수의 텐서에 상기 데이터를 할당하며, 상기 복수의 텐서 및 상기 복수의 텐서들에 할당된 상기 데이터를 이용하여 상기 통합된 실행 순서에 따라 상기 신경망 모델을 학습시키는 프로세서를 포함한다.
여기서, 상기 제1 정보는 상기 복수의 단계 중 상기 복수의 텐서가 이용되는 단계의 유형에 대한 정보에 기초하여 결정될 수 있다.
한편, 상기 복수의 텐서가 이용되는 단계의 유형은 상기 순전파 단계, 상기 그래디언트 계산 단계, 상기 도함수 계산 단계, 상기 그래디언트 계산 단계와 상기 도함수 계산 단계를 포함하는 역전파 단계, 상기 순전파 단계와 상기 역전파 단계를 포함하는 단계 및 상기 신경망 모델의 전체 학습 단계 각각을 나타내는 유형을 포함할 수 있다.
한편, 상기 제2 정보는 텐서가 기 할당된 상태임을 나타내는 제1 모드 정보, 텐서를 새로 생성해야 한다는 것을 나타내는 제2 모드 정보, 텐서의 데이터가 변경되지만 텐서를 인접한 레이어의 다른 텐서와 공유할 수 있다는 것을 나타내는 제3 모드 정보, 텐서의 데이터가 변경되지 않으므로 텐서를 상기 다른 텐서와 공유할 수 있다는 것을 나타내는 제4 모드 정보 및 텐서를 모든 텐서와 공유할 수 있다는 것을 나타내는 제5 모드 정보를 포함할 수 있다.
여기서, 상기 프로세서는 상기 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 상기 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 같거나 빠르면, 상기 제1 텐서와 상기 제2 텐서가 공유되도록 상기 결정된 실행 순서의 적어도 일부를 통합할 수 있다.
여기서, 상기 프로세서는 상기 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 상기 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 느린 경우, 상기 제2 텐서에 대응되는 제2 정보가 상기 제4 모드 정보이면, 상기 제1 텐서와 상기 제2 텐서가 공유되도록 상기 결정된 실행 순서의 적어도 일부를 통합할 수 있다.
한편, 상기 프로세서는 상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 메모리의 영역을 추가로 생성할 것인지 또는 이전에 생성된 메모리의 영역에 덮어쓸 것인지 여부를 결정함으로써 상기 메모리의 영역을 최소화할 수 있다.
상술한 바와 같은 목적을 달성하기 위한 본 개시의 일 실시 예에 따르면, 전자 장치의 제어 방법은 신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 상기 복수의 단계의 실행 순서를 결정하는 단계, 상기 결정된 실행 순서에 기초하여, 상기 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 상기 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하는 단계, 상기 제1 정보 및 상기 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 상기 결정된 실행 순서를 통합하는 단계, 상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 상기 메모리의 영역을 최소화하여 상기 복수의 텐서에 상기 데이터를 할당하는 단계 및 상기 복수의 텐서 및 상기 복수의 텐서들에 할당된 상기 데이터를 이용하여 상기 통합된 실행 순서에 따라 상기 신경망 모델을 학습시키는 단계를 포함할 수 있다.
여기서, 상기 제1 정보는 상기 복수의 단계 중 상기 복수의 텐서가 이용되는 단계의 유형에 대한 정보에 기초하여 결정될 수 있다.
한편, 상기 복수의 텐서가 이용되는 단계의 유형은 상기 순전파 단계, 상기 그래디언트 계산 단계, 상기 도함수 계산 단계, 상기 그래디언트 계산 단계와 상기 도함수 계산 단계를 포함하는 역전파 단계, 상기 순전파 단계와 상기 역전파 단계를 포함하는 단계 및 상기 신경망 모델의 전체 학습 단계 각각을 나타내는 유형을 포함할 수 있다.
한편, 상기 제2 정보는 텐서가 기 할당된 상태임을 나타내는 제1 모드 정보, 텐서를 새로 생성해야 한다는 것을 나타내는 제2 모드 정보, 텐서의 데이터가 변경되지만 텐서를 인접한 레이어의 다른 텐서와 공유할 수 있다는 것을 나타내는 제3 모드 정보, 텐서의 데이터가 변경되지 않으므로 텐서를 상기 다른 텐서와 공유할 수 있다는 것을 나타내는 제4 모드 정보 및 텐서를 모든 텐서와 공유할 수 있다는 것을 나타내는 제5 모드 정보를 포함할 수 있다.
여기서, 상기 결정된 실행 순서를 통합하는 단계는 상기 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 상기 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 같거나 빠르면, 상기 제1 텐서와 상기 제2 텐서가 공유되도록 상기 결정된 실행 순서의 적어도 일부를 통합할 수 있다.
여기서, 상기 결정된 실행 순서를 통합하는 단계는 상기 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 상기 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 느린 경우, 상기 제2 텐서에 대응되는 제2 정보가 상기 제4 모드 정보이면, 상기 제1 텐서와 상기 제2 텐서가 공유되도록 상기 결정된 실행 순서의 적어도 일부를 통합할 수 있다.
한편, 상기 복수의 텐서에 상기 데이터를 할당하는 단계는 상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 메모리의 영역을 추가로 생성할 것인지 또는 이전에 생성된 메모리의 영역에 덮어쓸 것인지 여부를 결정함으로써 상기 메모리의 영역을 최소화하는 단계를 포함할 수 있다.
상술한 바와 같은 목적을 달성하기 위한 본 개시의 일 실시 예에 따르면, 전자 장치의 제어 방법을 실행하는 프로그램을 포함하는 비일시적 컴퓨터 판독 가능 기록매체에 있어서, 상기 전자 장치의 제어 방법은 신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 상기 복수의 단계의 실행 순서를 결정하는 단계, 상기 결정된 실행 순서에 기초하여, 상기 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 상기 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하는 단계, 상기 제1 정보 및 상기 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 상기 결정된 실행 순서를 통합하는 단계, 상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 상기 메모리의 영역을 최소화하여 상기 복수의 텐서에 상기 데이터를 할당하는 단계 및 상기 복수의 텐서 및 상기 복수의 텐서들에 할당된 상기 데이터를 이용하여 상기 통합된 실행 순서에 따라 상기 신경망 모델을 학습시키는 단계를 포함할 수 있다.
도 1은 본 개시의 일 실시 예에 따른 전자 장치의 제어 방법을 나타내는 흐름도,
도 2는 본 개시의 일 실시 예에 따른 복수의 단계의 실행 순서를 나타내는 도면,
도 3은 본 개시의 일 실시 예에 따른 복수의 텐서가 이용되는 단계의 유형을 나타내는 도면,
도 4는 본 개시에 따른 제1 정보의 획득 과정을 상세하게 설명하기 위한 도면,
도 5는 본 개시의 일 실시 예에 따른 복수의 텐서에 대한 모드 정보들을 나타내는 도면,
도 6은 제1 정보 및 제2 정보에 기초하여 결정된 실행 순서를 통합하는 과정을 설명하기 위한 도면,
도 7은 본 개시의 일 실시 예에 있어서 메모리의 영역을 최소화하여 텐서에 데이터를 할당하는 방법을 나타내는 도면,
도 8은 본 개시의 다른 실시 예에 있어서 메모리의 영역을 최소화하여 텐서에 데이터를 할당하는 방법을 나타내는 도면,
도 9 및 도 10은 본 개시의 일 실시 예에 따라 데이터 로딩 시간을 감소시키는 방법에 대해 설명하기 위한 도면,
도 11은 본 개시의 일 실시 예에 따라 신경망 모델의 연산 단계에 이용되는 레이어의 개수를 조정하는 방법에 대해 설명하기 위한 도면,
도 12는 본 개시의 일 실시 예에 따른 전자 장치의 구성을 간략하게 나타내는 블록도, 그리고,
도 13은 본 개시의 일 실시 예에 따른 전자 장치의 구성을 상세하게 나타내는 블록도이다.
본 실시 예들은 다양한 변환을 가할 수 있고 여러 가지 실시 예를 가질 수 있는바, 특정 실시 예들을 도면에 예시하고 상세한 설명에 상세하게 설명하고자 한다. 그러나 이는 특정한 실시 형태에 대해 범위를 한정하려는 것이 아니며, 본 개시의 실시 예의 다양한 변경(modifications), 균등물(equivalents), 및/또는 대체물(alternatives)을 포함하는 것으로 이해되어야 한다. 도면의 설명과 관련하여, 유사한 구성요소에 대해서는 유사한 참조 부호가 사용될 수 있다.
본 개시를 설명함에 있어서, 관련된 공지 기능 혹은 구성에 대한 구체적인 설명이 본 개시의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우 그에 대한 상세한 설명은 생략한다.
덧붙여, 하기 실시 예는 여러 가지 다른 형태로 변형될 수 있으며, 본 개시의 기술적 사상의 범위가 하기 실시 예에 한정되는 것은 아니다. 오히려, 이들 실시 예는 본 개시를 더욱 충실하고 완전하게 하고, 당업자에게 본 개시의 기술적 사상을 완전하게 전달하기 위하여 제공되는 것이다.
본 개시에서 사용한 용어는 단지 특정한 실시 예를 설명하기 위해 사용된 것으로, 권리범위를 한정하려는 의도가 아니다. 단수의 표현은 문맥상 명백하게 다르게 뜻하지 않는 한, 복수의 표현을 포함한다.
본 개시에서, "가진다," "가질 수 있다," "포함한다," 또는 "포함할 수 있다" 등의 표현은 해당 특징(예: 수치, 기능, 동작, 또는 부품 등의 구성요소)의 존재를 가리키며, 추가적인 특징의 존재를 배제하지 않는다.
본 개시에서, "A 또는 B," "A 또는/및 B 중 적어도 하나," 또는 "A 또는/및 B 중 하나 또는 그 이상"등의 표현은 함께 나열된 항목들의 모든 가능한 조합을 포함할 수 있다. 예를 들면, "A 또는 B," "A 및 B 중 적어도 하나," 또는 "A 또는 B 중 적어도 하나"는, (1) 적어도 하나의 A를 포함, (2) 적어도 하나의 B를 포함, 또는 (3) 적어도 하나의 A 및 적어도 하나의 B 모두를 포함하는 경우를 모두 지칭할 수 있다.
본 개시에서 사용된 "제1," "제2," "첫째," 또는 "둘째,"등의 표현들은 다양한 구성요소들을, 순서 및/또는 중요도에 상관없이 수식할 수 있고, 한 구성요소를 다른 구성요소와 구분하기 위해 사용될 뿐 해당 구성요소들을 한정하지 않는다.
어떤 구성요소(예: 제1 구성요소)가 다른 구성요소(예: 제2 구성요소)에 "(기능적으로 또는 통신적으로) 연결되어((operatively or communicatively) coupled with/to)" 있다거나 "접속되어(connected to)" 있다고 언급된 때에는, 상기 어떤 구성요소가 상기 다른 구성요소에 직접적으로 연결되거나, 다른 구성요소(예: 제3 구성요소)를 통하여 연결될 수 있다고 이해되어야 할 것이다.
반면에, 어떤 구성요소(예: 제1 구성요소)가 다른 구성요소(예: 제2 구성요소)에 "직접 연결되어" 있다거나 "직접 접속되어" 있다고 언급된 때에는, 상기 어떤 구성요소와 상기 다른 구성요소 사이에 다른 구성요소(예: 제3 구성요소)가 존재하지 않는 것으로 이해될 수 있다.
본 개시에서 사용된 표현 "~하도록 구성된(또는 설정된)(configured to)"은 상황에 따라, 예를 들면, "~에 적합한(suitable for)," "~하는 능력을 가지는(having the capacity to)," "~하도록 설계된(designed to)," "~하도록 변경된(adapted to)," "~하도록 만들어진(made to)," 또는 "~를 할 수 있는(capable of)"과 바꾸어 사용될 수 있다. 용어 "~하도록 구성된(또는 설정된)"은 하드웨어적으로 "특별히 설계된(specifically designed to)" 것만을 반드시 의미하지 않을 수 있다.
대신, 어떤 상황에서는, "~하도록 구성된 장치"라는 표현은, 그 장치가 다른 장치 또는 부품들과 함께 "~할 수 있는" 것을 의미할 수 있다. 예를 들면, 문구 "A, B, 및 C를 수행하도록 구성된(또는 설정된) 프로세서"는 해당 동작을 수행하기 위한 전용 프로세서(예: 임베디드 프로세서), 또는 메모리 장치에 저장된 하나 이상의 소프트웨어 프로그램들을 실행함으로써, 해당 동작들을 수행할 수 있는 범용 프로세서(generic-purpose processor)(예: CPU 또는 application processor)를 의미할 수 있다.
실시 예에 있어서 '모듈' 혹은 '부'는 적어도 하나의 기능이나 동작을 수행하며, 하드웨어 또는 소프트웨어로 구현되거나 하드웨어와 소프트웨어의 결합으로 구현될 수 있다. 또한, 복수의 '모듈' 혹은 복수의 '부'는 특정한 하드웨어로 구현될 필요가 있는 '모듈' 혹은 '부'를 제외하고는 적어도 하나의 모듈로 일체화되어 적어도 하나의 프로세서로 구현될 수 있다.
한편, 도면에서의 다양한 요소와 영역은 개략적으로 그려진 것이다. 따라서, 본 발명의 기술적 사상은 첨부한 도면에 그려진 상대적인 크기나 간격에 의해 제한되지 않는다.
이하에서는 첨부한 도면을 참고하여 본 개시에 따른 실시 예에 대하여 본 개시가 속하는 기술 분야에서 통상의 지식을 가진 자가 용이하게 실시할 수 있도록 상세히 설명한다.
도 1은 본 개시의 일 실시 예에 따른 전자 장치(100)의 제어 방법을 나타내는 흐름도이다.
본 개시에 따른 전자 장치(100)는 신경망 모델을 학습시킬 수 있는 장치를 말한다. 예를 들어, 전자 장치(100)는 스마트 폰, 태블릿 PC, 스마트 워치 등과 같은 사용자 단말 또는 서버일 수 있다. 그러나, 본 개시에 따른 전자 장치(100)의 유형에 특별한 제한이 따르는 것은 아니다. 본 개시에 따른 신경망 모델의 학습은 전자 장치(100) 내에서 온 디바이스(on-device)의 형태로 수행될 수 있으며, 다만 이에 국한되는 것은 아니다.
본 개시에 따른 신경망 모델은 인공 신경망(neural network)을 포함하는 인공 지능 모델을 말하며, 딥러닝(deep learning)에 의해 학습될 수 있다. 구체적으로, 신경망 모델은 심층 신경망(deep neural network, DNN), 합성곱 신경망(convolution neural network, CNN), 순환 신경망(recurrent neural network, RNN) 및 생성적 적대 신경망(generative adversarial networks, GAN) 중 적어도 하나의 인공 신경망을 포함할 수 있다. 다만, 본 개시에 따른 신경망 모델이 상술한 예에 국한되는 것은 아니다.
도 1을 참조하면, 전자 장치(100)는 신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 복수의 단계의 실행 순서를 결정할 수 있다(S110).
구체적으로, 신경망 모델의 학습 단계는 크게 순전파(feedforward, forward propagation) 단계 및 역전파(backpropagation) 단계로 구분될 수 있다. 여기서, 순전파 단계란 입력 레이어에서 출력 레이어 방향으로 입력 값을 전달하면서 출력 값을 획득하는 단계를 말하며, 역전파 단계란 출력 레이어에서 입력 레이어 방향으로 그래디언트를 전달하면서 각각의 레이어들의 가중치를 업데이트하는 단계를 말한다.
역전파 과정은 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함할 수 있다. 그래디언트 계산 단계는 신경망 모델에 포함된 각각의 레이어들의 가중치를 업데이트에 이용하기 위한 그래디언트를 계산하는 단계를 말하며, 도함수 계산 단계는 각 레이어의 활성화 함수에 대한 도함수를 계산하는 단계를 말한다.
도 2는 본 개시의 일 실시 예에 따른 복수의 단계의 실행 순서를 나타내는 도면이다. 도 2를 참조하면, 신경망 모델의 학습은 신경망 모델에 포함된 복수의 레이어를 해석하는 모델 해석 단계(S210), 복수의 레이어를 구체화하는 현실화 단계(S220), 복수의 레이어 간 실행 순서를 결정하는 실행 순서 결정 단계(S230), 복수의 레이어에 텐서를 할당하는 모델 초기화 단계(S240) 및 초기화된 모델에 기초하여 학습을 수행하는 학습 수행 단계(S250)를 포함할 수 있다.
도 2 하단에는 학습 수행 단계(S250)에서 수행되는 복수의 레이어 별 학습 단계 각각을 순서에 따라 나타내었다. 여기서, FC는 fully connected, FW는 forward, BN은 batch normalization, AC는 activation, CG는 compute gradient, CD는 compute derivative를 나타내는 약어이다. 그리고, 1, 2, 3, 11, 12, 13, 24, 25, 26 등과 같은 숫자는 실행 순서를 나타내며, 도시의 편의를 위해 일부 단계들의 실행 순서만을 나타낸 것이다. 특히, 도 2의 하단에서는 순전파 단계 중 하나의 단계에 대응되는 역전파 단계를 그래디언트 계산 단계 및 도함수 계산 단계로 구분하여 나타내었다. 예를 들어, 실행 순서 11 및 12에 대응되는 단계들은 하나의 activation에 대응되는 그래디언트 계산 단계 및 도함수 계산 단계를 나타낸다.
도 2를 참조하여 상술한 바와 같이, 본 개시에 있어서는, 신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계가 단순히 순전파 단계와 역전파 단계로 구분되는 것이 아니라, 역전파 단계를 더 세부적으로 구분함에 따라 그래디언트 계산 단계와 도함수 계산 단계로 구분될 수 있다. 그리고 세부적으로 구분된 단계 별로 실행 순서가 결정될 수 있다. 이하에서 '복수의 단계'라고 함은 도 2의 하단에 도시된 바와 같이 신경망 모델의 학습 단계 전체에 포함되는 단계들을 의미하며, '실행 순서'라 함은 복수의 단계 각각에 할당된 실행 순서를 의미한다.
한편, 도 2에 도시된 바와 같은 레이어의 종류와 실행 순서는 예시적인 것으로서, 도 2에 도시된 레이어 이외의 레이어가 신경망 모델에 포함될 수 있으며, 역전파 단계를 도 2에 도시된 것보다 더 세부적으로 구분하고 실행 순서를 할당할 수도 있음은 물론이다.
복수의 단계의 실행 순서가 결정되면, 전자 장치(100)는 결정된 실행 순서에 기초하여, 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득할 수 있다(S120).
본 개시에 있어서 텐서란 신경망 모델에서 이용되는 입출력 데이터, 가중치, 그래디언트, 도함수 등을 총칭하는 의미로 사용된다. 특히, 텐서는 차원(dimension)에 대한 정보, 본 개시에 따른 실행 순서에 대한 정보, 복수의 텐서가 이용되는 단계의 유형에 대한 정보 및 모드 정보 등을 포함하는 스펙(specification) 부분과 텐서의 스펙에 할당되는 데이터를 의미하는 데이터 부분으로 구별될 수 있다. 이하에서 설명하는 실시 예는 텐서의 스펙을 정의하는 과정과 텐서의 스펙에 데이터를 할당하는 과정을 포함한다.
제1 정보는 복수의 단계 중 복수의 텐서가 이용되는 단계의 유형에 대한 정보에 기초하여 결정될 수 있다. 여기서, 복수의 텐서가 이용되는 단계의 유형은, 도 3에 도시된 바와 같이, 순전파 단계(forward, F), 그래디언트 계산 단계(compute gradient, CG) 및 도함수 계산 단계(compute derivative, CD), 그래디언트 계산 단계와 도함수 계산 단계를 포함하는 역전파 단계(backward, B), 순전파 단계와 역전파 단계를 포함하는 단계(iteration, I) 및 신경망 모델의 전체 학습 단계(Max, M) 각각을 나타내는 유형을 포함할 수 있다.
이하에서는 도 4를 참조하여 단계 S120에 대해 구체적으로 설명한다. 즉, 도 4는 복수의 텐서가 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하는 과정을 상세하게 설명하기 위한 도면이다. 도 4에서는 설명의 편의를 위해 신경망 모델이 세 개의 레이어만을 포함하는 경우를 전제로 설명한다.
도 4에서 Ln은 레이어, Xn는 입출력 텐서, Dn는 도함수, ΔWn은 그래디언트, Wn는 가중치를 의미한다 즉, 도 4의 우측 상단 그림(410)은 신경망 모델에 포함된 세 개의 레이어 L0, L1, L2 각각에 대응되는 입출력 텐서, 도함수, 그래디언트 및 가중치를 나타낸 것이다.
한편, 도 4의 우측 하단 그림(420)은 각각의 레이어를 통해 수행되는 단계와 그 실행 순서를 나타낸다. 구체적으로, 도 4의 예시에 따르면, 신경망 모델의 학습 단계는 레이어 L0를 통한 순전파 단계(실행 순서 0), 레이어 L1를 통한 순전파 단계(실행 순서 1), 레이어 L2를 통한 순전파 단계(실행 순서 2), 레이어 L2를 통한 그래디언트 계산 단계(실행 순서 3), 레이어 L2를 통한 도함수 계산 단계(실행 순서 4), 레이어 L1를 통한 그래디언트 계산 단계(실행 순서 5), 레이어 L1를 통한 도함수 계산 단계(실행 순서 6) 및 레이어 L0를 통한 그래디언트 계산 단계(실행 순서 7)의 순서로 수행될 수 있다. 도 4에서는 점선 원을 실행 순서 8에 표시하였는바, 이는 레이어 L0를 통한 도함수 계산 단계는 필요하지 않은 경우임을 나타낸다.
도 4의 좌측 그림(430)은 도 4의 후측 하단 그림(420)과 같이 복수의 단계의 실행 순서가 결정된 경우, 복수의 텐서가 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하는 방법을 나타낸다. 도 4의 좌측 그림(430)에서 각각의 텐서에 대응되는 행에 기재된 숫자는 실행 순서를 나타내며, 괄호 안의 정보는 각각 복수의 텐서가 이용되는 단계의 유형에 대한 정보(괄호 안의 슬러쉬 전단) 및 텐서에 대응되는 모드 정보(괄호 안의 슬러쉬 후단)를 나타낸다. 여기서, 텐서에 대응되는 모드 정보에 대해서는 도 5 및 도 6을 참조하여 후술한다.
예를 들어, 전자 장치(100)는 텐서 X0가 레이어 L0에서 수행되는 순전파 단계 및 레이어 L0에서 수행되는 그래디언트 계산 단계에서 이용된다는 점에 기초하여, 텐서 X0가 실행 순서 0 및 실행 순서 7 각각에 대응되는 단계에서 이용된다는 점을 나타내는 제1 정보를 획득할 수 있다. 즉, 도 4의 그림(430)에서 텐서 X0에 대응되는 행에 0 및 7이 기재된 것은 텐서 X0가 실행 순서 0 및 실행 순서 7 각각에 대응되는 단계에서 이용된다는 점을 나타낸 것이다. 텐서 X1, 텐서 X2 및 텐서 X3가 이용되는 단계도 텐서 X0가 이용되는 단계를 결정하는 방법과 마찬가지로 결정될 수 있다.
또한, 전자 장치(100)는 텐서 D3가 레이어 L2에서 수행되는 역전파 단계에서 이용된다는 점에 기초하여, 텐서 D3가 실행 순서 2 및 실행 순서 3 각각에 대응되는 단계에서 이용된다는 점을 나타내는 제1 정보를 획득할 수 있다. 텐서 D2 및 텐서 D1가 이용되는 단계도 텐서 D3가 이용되는 단계를 결정하는 방법과 마찬가지로 결정될 수 있다.
그리고, 전자 장치(100)는 텐서 ΔW2가 레이어 L2에서 수행되는 역전파 단계에서 이용된다는 점에 기초하여, 텐서 ΔW2가 실행 순서 3 및 실행 순서 4 각각에 대응되는 단계에서 이용된다는 점을 나타내는 제1 정보를 획득할 수 있다. 텐서 ΔW1 및 텐서 ΔW0가 이용되는 단계도 텐서 ΔW2가 이용되는 단계를 결정하는 방법과 마찬가지로 결정될 수 있다.
또한, 전자 장치(100)는 텐서 W0가 레이어 L0에서 수행되는 신경망 모델의 전체 학습 단계 동안 유지되어야 한다는 점에 기초하여, 텐서 W0가 실행 순서 0 및 실행 순서 7 각각에 대응되는 단계에서 이용된다는 점을 나타내는 제1 정보를 획득할 수 있다. 텐서 W1 및 텐서 W2가 이용되는 단계도 텐서 W0가 이용되는 단계를 결정하는 방법과 마찬가지로 결정될 수 있다.
제1 정보가 획득되면, 전자 장치(100)는 제1 정보 및 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 결정된 실행 순서를 통합할 수 있다(S130).
여기서, 제2 정보는 도 5에 도시된 바와 같이, 텐서가 이미 생성된 상태임을 나타내는 제1 모드 정보(place-holder, P), 텐서를 새로 생성해야 한다는 것을 나타내는 제2 모드 정보(create, C), 텐서의 데이터가 변경되지만 그 텐서를 인접한 레이어의 다른 텐서와 공유할 수 있다는 것을 나타내는 제3 모드 정보(modify view, MV), 텐서의 데이터가 변경되지 않으므로 텐서를 다른 텐서와 공유할 수 있다는 것을 나타내는 제4 모드 정보(read-only view, RV) 및 텐서를 모든 텐서와 공유할 수 있다는 것을 나타내는 제5 모드 정보(extend, E)와 같은 복수의 모드 정보를 포함할 수 있다.
구체적으로, 제1 모드 정보 및 제2 모드 정보의 경우에는 텐서를 다른 텐서와 공유할 수 없다는 것을 나타내는 반면, 제3 모드 정보, 제4 모드 정보 및 제5 모드 정보는 텐서를 다른 텐서와 공유할 수 있다는 것을 나타낸다. 특정 텐서에 대응되는 모드 정보가 제1 모드 정보 내지 제5 모드 정보 중 어떠한 것에 해당하는지는 전자 장치(100)에 의해 결정될 수도 있으며, 개발자 또는 사용자에 의해 설정될 수도 있다.
이하에서는 도 6을 참조하여 단계 S130에 대해 구체적으로 설명한다. 즉, 도 6은 제1 정보 및 제2 정보에 기초하여 결정된 실행 순서를 통합하는 과정을 설명하기 위한 도면이다. 도 6에 대한 설명에서도 도 4의 경우와 마찬가지로, 설명의 편의를 위해 신경망 모델이 세 개의 레이어를 포함하는 경우를 전제로 설명한다.
도 4의 경우와 마찬가지로, 도 6에서 Ln은 레이어, Xn는 입출력 텐서, Dn는 도함수, ΔWn은 그래디언트, Wn는 가중치를 의미한다. 즉, 도 6의 우측 상단 그림(610)은 신경망 모델에 포함된 세 개의 레이어 L0, L1, L2 각각에 대응되는 입출력 텐서, 도함수, 그래디언트 및 가중치를 나타낸 것이다(MV, RV에 대한 설명은 후술한다).
한편, 도 6의 우측 하단 그림(620)은 각각의 레이어를 통해 수행되는 단계와 그 실행 순서를 나타낸다. 구체적으로, 도 6의 예시에 따르면, 신경망 모델의 학습 단계는 레이어 L0를 통한 순전파 단계(실행 순서 0), 레이어 L1를 통한 순전파 단계(실행 순서 1), 레이어 L2를 통한 순전파 단계(실행 순서 2), 레이어 L2를 통한 도함수 계산 단계(실행 순서 4), 레이어 L1를 통한 도함수 계산 단계(실행 순서 6) 및 레이어 L0를 통한 그래디언트 계산 단계(실행 순서 7)의 순서로 수행될 수 있다. 도 4에서는 점선 원을 실행 순서 3, 실행 순서 5 및 실행 순서 8에 표시하였는바, 이는 레이어 L2를 통한 그래디언트 계산 단계, 레이어 L1을 통한 그래디언트 계산 단계 및 레이어 L0를 통한 도함수 계산 단계는 필요하지 않은 경우임을 나타낸다.
도 6의 좌측 그림(630)은 도 6의 후측 하단 그림(620)과 같이 복수의 단계의 실행 순서가 결정된 경우, 복수의 텐서가 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하고, 결정된 실행 순서를 통합하는 방법을 나타낸다. 도 4의 경우와 마찬가지로, 도 6 좌측 그림(630)에서 각각의 텐서에 대응되는 행에 기재된 숫자는 실행 순서를 나타내며, 괄호 안의 정보는 각각 복수의 텐서가 이용되는 단계의 유형에 대한 정보(괄호 안의 슬러쉬 전단) 및 텐서에 대응되는 모드 정보(괄호 안의 슬러쉬 후단)를 나타낸다.
예를 들어, 도 6에 도시된 바와 같이, 전자 장치(100)는 텐서 X0가 실행 순서 0 및 실행 순서 7 각각에 대응되는 단계에서 이용된다는 점, 텐서 X1이 실행 순서 0 및 실행 순서 1 각각에 대응되는 단계에서 이용된다는 점, 텐서 X2가 실행 순서 1, 실행 순서 2 및 실행 순서 6 각각에 대응되는 단계에서 이용된다는 점 등을 나타내는 제1 정보를 획득할 수 있다. D3, D2, D1, ΔW0 및 W0에 대한 설명은 생략한다.
일 실시 예에 있어서, 전자 장치(100)는 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 같거나 빠르면, 제1 텐서와 제2 텐서가 공유되도록, 결정된 실행 순서의 적어도 일부를 통합할 수 있다.
도 6의 예를 참조하면, 전자 장치(100)는 텐서 X1이 가장 마지막으로 이용되는 단계의 실행 순서가 텐서 X2가 가장 처음으로 이용되는 단계의 실행 순서보다 늦지 않으면, 텐서 X1과 텐서 X2가 공유되도록 실행 순서를 통합할 수 있다. 구체적으로, 텐서 X1이 가장 마지막으로 이용되는 단계가 실행 순서 1에 대응되는 단계이고, 텐서 X2가 가장 처음으로 이용되는 단계가 실행 순서 1에 대응되는 단계이므로, 텐서 X2을 추가로 정의할 필요가 없고 X1을 그대로 사용할 수 있는 경우라고 할 수 있다. 따라서 텐서 X1과 X2는 공유되고 텐서 X1이 실행 순서 0, 실행 순서 1, 실행 순서 2 및 실행 순서 6 각각에 대응되는 단계에 이용되도록 결정될 수 있다. 도 6에서는 텐서 X2에 대응되는 모드 정보가 제3 모드 정보(modify view, MV)라고 기재되어 있는바, 이는 텐서 X1의 데이터가 변경되지만 실행 순서에 비추어 텐서 X2를 인접한 레이어의 다른 텐서인 X1과 공유할 수 있다는 것을 나타낸다.
일 실시 예에 있어서, 전자 장치(100)는 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 느린 경우에도, 제2 텐서에 대응되는 제2 정보가 제4 모드 정보이면, 제1 텐서와 제2 텐서가 공유되도록, 결정된 실행 순서의 적어도 일부를 통합할 수 있다.
도 6의 예를 참조하면, 전자 장치(100)는 텐서 X2가 가장 마지막으로 이용되는 단계의 실행 순서가 텐서 X3이 가장 처음으로 이용되는 단계의 실행 순서보다 느린 경우에도, 텐서 X2와 텐서 X3이 공유되도록 실행 순서를 통합할 수 있다. 구체적으로, 텐서 X2가 가장 마지막으로 이용되는 단계가 실행 순서 6에 대응되는 단계이고, 텐서 X3이 가장 처음으로 이용되는 단계가 실행 순서 2에 대응되는 단계이지만, 전자 장치(100)는 텐서 X3에 대응되는 모드 정보가 제4 모드 정보(read-only view, RV), 즉 텐서 X2의 데이터가 변경되지 않으므로 텐서 X3를 인접한 레이어의 다른 텐서인 X2와 통합할 수 있다는 나타내는 모드 정보이므로, 텐서 X2와 텐서 X3이 공유되도록 실행 순서를 통합할 수 있다.
이상에서는 텐서 X1, 텐서 X2 및 텐서 X3에 대해서만 설명하였으나, 도 6에 도시된 바와 같이, 텐서 D3, 텐서 D2 및 텐서 D3의 사이에서도 텐서 X1, 텐서 X2 및 텐서 X3에 대한 설명과 마찬가지 방법으로 텐서의 공유 및 실행 순서의 통합이 이루어질 수 있다.
한편, 이상에서는 도 6의 실시 예를 참조하여 텐서의 공유 및 실행 순서의 통합에 대해 설명하였으나, 도 4의 실시 예와 같이 텐서의 공유 및 실행 순서의 통합이 이루어질 수 없는 경우(모든 텐서들에 대응되는 제2 정보가 제1 모드 정보 또는 제2 모드 정보인 경우)에는 텐서의 공유 및 실행 순서의 통합이 이루어지지 않을 수 있다. 즉, 본 개시에 따른 단계 S130은 실시 예에 따라서는 수행되지 않을 수 있다. 이 점을 고려할 때, 이하에서 복수의 단계의 실행 순서가 통합되었다는 것의 의미는 단계 S130에 따른 텐서의 공유 및 실행 순서의 통합이 이루어진 경우뿐만 아니라 텐서의 공유 및 실행 순서의 통합을 고려하였으나 수행되지 않은 경우를 포함한다.
복수의 단계의 실행 순서가 통합되면, 전자 장치(100)는 통합된 실행 순서에 기초하여, 복수의 텐서에 데이터를 할당하기 위한 메모리의 영역을 최소화하여 복수의 텐서에 데이터를 할당할 수 있다(S140).
구체적으로, 전자 장치(100)는 통합된 실행 순서에 기초하여, 복수의 텐서에 대응되는 데이터를 할당하기 위한 메모리의 영역을 추가로 생성할 것인지 또는 이전에 생성된 메모리의 영역에 덮어쓸 것인지 여부를 결정함으로써 메모리의 영역을 최소화할 수 있다.
이하에서는 도 7 및 도 8을 참조하여 메모리의 영역을 최소화하여 텐서에 데이터를 할당하는 방법에 대해 구체적으로 설명한다. 도 7은 도 4의 실시 예에 따라 복수의 레이어에서 이용되는 텐서들과 복수의 단계의 실행 순서가 최종적으로 결정된 경우 메모리의 영역을 최소화하여 텐서에 데이터를 할당하는 방법을 나타내며, 도 8은 도 6의 실시 예에 따라 복수의 레이어에서 이용되는 텐서들과 복수의 단계의 실행 순서가 최종적으로 결정된 경우 메모리의 영역을 최소화하여 텐서에 데이터를 할당하는 방법을 나타낸다.
도 7의 그림(710)은 도 4의 실시 예의 경우 복수의 레이어에서 이용되는 텐서들을 순차적으로 나타낸다. 그리고, 그림(720), 그림(730) 및 그림(740)은 복수의 레이어에서 이용되는 텐서들에 데이터를 할당하는 과정에서 메모리의 영역을 최소화하는 방법을 나타낸다.
그림(720)을 참조하면, 텐서 W0은 실행 순서 0 및 실행 순서 7 각각에 대응되는 단계에 이용되며, 텐서 W1은 실행 순서 0 및 실행 순서 7 각각에 대응되는 단계에 이용되므로, 텐서 W1에 대응되는 데이터를 텐서 W0에 대응되는 메모리의 영역에 덮어쓸 수 없다. 따라서, 전자 장치(100)는 텐서 W1에 대응되는 메모리의 영역을 추가로 할당할 수 있다. 즉, 텐서 W0는 실행 순서 0에 대응되는 단계뿐만 아니라 실행 순서 7에 대응되는 단계에서도 유효성(validity)이 보장되어야 하므로 텐서 W1에 대응되는 데이터를 텐서 W0에 대응되는 메모리의 영역에 덮어쓸 수 없고, 따라서 텐서 W1에 대응되는 메모리의 영역을 추가로 할당하여야 한다. 마찬가지 이유에서, 텐서 W2, 텐서 X0, 텐서 X1, 텐서 X2 및 텐서 X3에 대응되는 메모리의 영역이 추가로 할당된다.
이상에서는 텐서 W1에 대응되는 데이터를 할당하기 위한 메모리의 영역을 고려함에 있어서는 W0에 대응되는 메모리의 영역에 덮어쓸 수 있는지 여부만을 고려하였으나, 텐서 W2에 대응되는 데이터를 할당하기 위한 메모리의 영역을 고려함에 있어서는 텐서 W1뿐만 아니라 텐서 W0에 대응되는 메모리의 영역에 텐서 W2에 대응되는 데이터를 덮어쓸 수 있는지 여부도 고려할 수 있다.
그림(730)을 참조하면, 텐서 X3는 실행 순서 2에 대응되는 단계에 이용되고 텐서 D3는 실행 순서 3 및 실행 순서 4 각각에 대응되는 단계에서 이용되므로, 텐서 D3에 대응되는 데이터를 텐서 X3에 대응되는 메모리의 영역에 덮어쓸 수 있다. 따라서, 전자 장치(100)는 텐서 D3에 대응되는 메모리의 영역을 추가로 할당하지 않고 텐서 X3에 대응되는 메모리의 영역을 이용할 수 있다. 그림(730)에서 텐서 X3가 재사용(reused)된다는 것의 의미는 텐서 D3에 데이터를 할당하기 위해 텐서 X3에 대응되는 메모리의 영역이 이용될 수 있다는 것을 의미한다.
한편, 텐서 D3는 실행 순서 3 및 실행 순서 4 각각에 대응되는 단계에서 이용되고 텐서 ΔW2도 실행 순서 3 및 실행 순서 4 각각에 대응되는 단계에서 이용되므로, 텐서 ΔW2에 대응되는 메모리의 영역은 추가로 할당된다.
그림(740)을 참조하면, 텐서 X2는 실행 순서 1 및 실행 순서 3 각각에 대응되는 단계까지만 유효성이 보장되면 되고, 텐서 D2는 실행 순서 4 및 실행 순서 6 각각에 대응되는 단계에서 이용되므로, 텐서 D2에 대응되는 데이터를 텐서 X2에 대응되는 메모리의 영역에 덮어쓸 수 있다. 따라서, 전자 장치(100)는 텐서 D3에 대응되는 메모리의 영역을 추가로 할당하지 않고 텐서 X2에 대응되는 메모리의 영역을 이용할 수 있다. 그림(740)에서 텐서 X2가 재사용(reused)된다는 것의 의미는 텐서 D2에 데이터를 할당하기 위해 텐서 X2에 대응되는 메모리의 영역이 이용될 수 있다는 것을 의미한다.
한편, 도 7의 최대 메모리 소비(peak memory consumption)는 텐서들에 데이터를 할당하도록 허용된 메모리 용량의 한계치를 나타내며, 이는 메모리의 사양(specification)과 사용자/개발자의 설정에 따라 달라질 수 있다. 그림(730)에서 텐서 D3 및 텐서 ΔW2 각각에 대응되는 메모리의 영역을 추가적으로 할당하는 경우, 도 7의 예시에 따른 최대 메모리 소비에 도달하게 된다. 따라서 전자 장치(100)는 앞서 할당된 텐서 X3에 대응되는 메모리의 영역 및 앞서 할당된 텐서 X2에 대응되는 메모리의 영역에 텐서 D3에 대응되는 데이터 및 텐서 D2에 대응되는 데이터를 덮어쓸 수 있는지 여부에 기초하여 데이터를 할당할 수 있다. 다만, 데이터를 텐서에 할당하는 과정에서 최대 메모리 소비에 도달하지 않는 경우에도 앞서 할당된 텐서에 대응되는 메모리의 영역을 이용할 수도 있음은 물론이다.
도 8의 그림(810)은 도 6의 실시 예의 경우 복수의 레이어에서 이용되는 텐서들을 순차적으로 나타낸다. 그리고, 그림(820), 그림(830) 및 그림(840)은 복수의 레이어에서 이용되는 텐서들에 데이터를 할당하는 과정에서 메모리의 영역을 최소화하는 방법을 나타낸다.
그림(820)을 참조하면, 텐서 W0은 실행 순서 0 및 실행 순서 7 각각에 대응되는 단계에 이용되며, 텐서 W1은 실행 순서 0 및 실행 순서 7 각각에 대응되는 단계에 이용되므로, 텐서 W1에 대응되는 데이터를 텐서 W0에 대응되는 메모리의 영역에 덮어쓸 수 없다. 따라서, 전자 장치(100)는 텐서 W1에 대응되는 메모리의 영역을 추가로 할당할 수 있다. 마찬가지 이유에서, 텐서 W2, 텐서 X0, 텐서 X1 및 텐서 X3에 대응되는 메모리의 영역이 추가로 할당된다. 여기서, 텐서 X2가 생략된 것은 도 6을 참조하여 상술한 바와 같은 텐서의 공유와 실행 순서의 통합 과정에 따른 것이다.
그림(830)을 참조하면, 텐서 X3는 실행 순서 2에 대응되는 단계에 이용되고 텐서 D3는 실행 순서 3 및 실행 순서 4 각각에 대응되는 단계에서 이용되므로, 텐서 D3에 대응되는 데이터를 텐서 X3에 대응되는 메모리의 영역에 덮어쓸 수 있다. 따라서, 전자 장치(100)는 텐서 D3에 대응되는 메모리의 영역을 추가로 할당하지 않고 텐서 X3에 대응되는 메모리의 영역을 이용할 수 있다. 한편, 텐서 ΔW2는 실행 순서 3 및 실행 순서 4 각각에 대응되는 단계에서 이용되는데, 기 할당된 메모리의 영역 중 텐서 ΔW2를 덮어쓸 수 있는 영역은 존재하지 않으므로 텐서 ΔW2에 대응되는 메모리의 영역은 추가로 할당된다.
그림(840)을 참조하면, 텐서 D2는 실행 순서 4 및 실행 순서 7 각각에 대응되는 단계에서 이용되는데, 기 할당된 메모리의 영역 중 텐서 D2를 덮어쓸 수 있는 영역은 존재하지 않으므로 텐서 D2에 대응되는 메모리의 영역은 추가로 할당된다.
그림(850)을 참조하면, 텐서 ΔW0는 실행 순서 7에 대응되는 단계에 이용되는데, 텐서 T1, 텐서 T2, 텐서 D3 및 텐서 ΔW2는 모두 실행 순서 7에 대응되는 단계 이전까지만 유효성이 보장되면 되기 때문에 텐서 ΔW0는 텐서 T1, 텐서 T2, 텐서 D3 또는 텐서 ΔW2에 대응되는 메모리의 영역에 덮어쓸 수 있다. 따라서, 전자 장치(100)는 텐서 ΔW2에 대응되는 메모리의 영역을 추가로 할당하지 않고 텐서 ΔW0는 텐서 T1, 텐서 T2, 텐서 D3 또는 텐서 ΔW2에 대응되는 메모리의 영역을 이용할 수 있다. 이에 따라 텐서 ΔW2에 대응되는 메모리의 영역과 텐서 D2에 대응되는 메모리의 영역 사이에는 절편(fragment)이 존재하게 된다.
상술한 바와 같은 단계 S110 내지 S140이 수행된 후, 전자 장치(100)는 복수의 텐서 및 복수의 텐서들에 할당된 데이터를 이용하여 통합된 실행 순서에 따라 신경망 모델을 학습시킬 수 있다(S150).
구체적으로, 상술한 바와 같이 복수의 단계의 실행 순서에 따라 복수의 텐서 및 복수의 텐서에 할당되는 데이터가 정의되면, 전자 장치(100)는 복수의 텐서 및 복수의 텐서들에 할당된 데이터를 이용하여 통합된 실행 순서에 따라 신경망 모델을 학습시킴으로써 신경망 모델의 복수의 레이어 각각의 가중치를 업데이트할 수 있다.
특히, 본 개시에 따른 신경망 모델이 서버에 의해 기 학습된 후 본 개시에 따른 전자 장치(100)에 의해 다시 학습되는 경우, 상술한 바와 같은 학습 결과에 따라 신경망 모델이 전자 장치(100)의 사용자에 맞도록 개인화될 수 있다.
이상에서 도 1 내지 도 7을 참조하여 상술한 실시 예에 따르면, 전자 장치(100)는 복수의 단계의 실행 순서에 따라 복수의 텐서 및 복수의 텐서에 할당되는 데이터를 효율적으로 정의함으로써 메모리의 사용량을 최소화할 수 있게 된다. 그리고 이에 따라, 특히 온 디바이스(on-device)에서 오버헤드(overhead) 없이 개인화를 위한 신경망 모델의 학습을 효율적으로 수행할 수 있게 된다.
도 9 및 도 10은 본 개시의 일 실시 예에 따라 데이터 로딩 시간을 감소시키는 방법에 대해 설명하기 위한 도면이다.
본 개시에 있어서, 로딩 시간이라 함은 신경망 모델의 학습을 수행하기 위해 필요한 데이터를 플래시 메모리(flash memory), eMMC(embedded multimedia card) 등과 같은 비휘발성 메모리에 저장된 데이터를 RAM(random access memory) 또는 프로세서에 포함된 글로벌 버퍼(global buffer)등과 같은 휘발성 메모리에 불러들이는 과정에서 소요되는 시간을 의미한다. 다만, 어떠한 유형의 저장 공간에서 어떠한 유형의 저장 공간으로 데이터를 로딩할 것인지에 대해 특별한 제한이 있는 것은 아니다.
도 9는 신경망 모델의 학습에 있어서 n번째 반복(iteration)을 수행하는 경우 획득되는 정보를 나타내며, 도 10은 신경망 모델의 학습에 있어서 n+1번째 반복을 수행하는 경우 획득되는 정보를 나타낸다. 이하에서는 도 9의 n번째 반복이 첫번째 반복이고, n+1번째 반복이 두번째 반복임을 전제로 설명한다.
도 9 및 도 10에서 L1 내지 L9는 신경망 모델에 포함된 9개의 레이어들 각각을 나타낸다. 그리고, look a head라는 용어는 각각의 레이어에서 몇 개의 단계를 미리 고려할 지를 나타내는 인덱스 정보를 말한다. 예를 들어, 제1 레이어의 look a head가 1이면 제1 레이어의 연산 시 제1 레이어에서 소요되는 연산 시간과 데이터의 최대 로딩 시간만을 고려하고, 제2 레이어의 look a head가 2이면 제2 레이어의 연산 시 제2 레이어에서 소요되는 연산 시간과 데이터의 최대 로딩 시간뿐만 아니라, 다음 레이어인 제3 레이어에서 소요되는 연산 시간과 데이터의 최대 로딩 시간을 고려한다.
도 9 및 도 10에서 computation (TC)는 각각의 레이어 별 연산 시간을 나타내며, max load (TL)은 각각의 레이어 별 데이터의 최대 로딩 시간을 나타낸다. 그리고, diff (TC-TL)은 각각의 레이어 별 연산 시간에서 각각의 레이어 별 데이터의 최대 로딩 시간을 뺀 값을 나타낸다. 즉, diff가 음수이면 해당 레이어의 연산 시간 보다 데이터의 최대 로딩 시간이 긴 경우이므로 로딩을 기다려야 하는 경우라고 할 수 있다. 반대로, diff가 양수이면 해당 레이어의 연산 시간 보다 데이터의 최대 로딩 시간이 짧은 경우이므로 로딩을 기다릴 필요가 없고 오히려 추가적인 데이터 로딩에 할애될 수 있는 시간이 존재하는 경우라고 할 수 있다.
도 9를 참조하면, 전자 장치(100)는 첫번째 반복을 수행하는 동안 우선 look a head를 1로 설정한 후, 각각의 레이어 별 연산 시간(TC), 각각의 레이어 별 데이터의 최대 로딩 시간(TL), 그리고 각각의 레이어 별 연산 시간에서 각각의 레이어 별 데이터의 최대 로딩 시간을 뺀 값(diff)을 산출할 수 있다.
예를 들어, 전자 장치(100)는 레이어 L1에서 소요되는 연산 시간과 데이터의 최대 로딩 시간만에 기초하여, 레이어 L1의 연산 시간은 1이고, 최대 로딩 시간은 3이며, 따라서 연산 시간과 최대 로딩 시간의 차이가 -2라는 정보를 획득할 수 있다. 이는 레이어 L1의 연산을 수행하는 경우 2라는 시간만큼 데이터 로딩을 기다려야 하는 경우라고 할 수 있다.
또한, 전자 장치(100)는 레이어 L2에서 소요되는 연산 시간과 데이터의 최대 로딩 시간만에 기초하여, 레이어 L2의 연산 시간은 5이고, 최대 로딩 시간은 0이며(즉, 이미 로딩된 데이터를 이용하는 경우임), 따라서 연산 시간과 최대 로딩 시간의 차이가 5라는 정보를 획득할 수 있다. 이는 레이어 L2의 연산을 수행하는 경우 5라는 시간만큼 데이터 로딩에 할애할 수 있는 경우라고 할 수 있다.
나아가, 전자 장치(100)는 레이어 L1 및 레이어 L2에 대한 경우와 마찬가지 방법으로 레이어 L3 내지 레이어 L9에 대한 연산을 수행하면서 각각의 레이어 별 연산 시간, 최대 로딩 시간 및 연산 시간과 최대 로딩 시간 사이의 차이를 산출할 수 있다.
도 10을 참조하면, 전자 장치(100)는 두번째 반복을 수행하는 동안 look a head을 업데이트하면서 연산 시간과 최대 로딩 시간 사이의 차이를 0 또는 양수가 되도록 할 수 있다. 구체적으로, 첫번째 반복을 수행한 결과에 따른 diff 값이 음수인 레이어가 존재하는 경우, 그 레이어에 앞선 레이어들 중 diff 값이 양수인 레이어에서 미리 로딩을 수행함으로써 전체적인 로딩 지연 시간을 감소시킬 수 있다.
예를 들어, 레이어 L1에 대해서는 후술하고 우선 레이어 L2에서부터 설명하면, 레이어 L2 내지 레이어 L4의 경우에는 diff 값이 양수이므로 레이어 L2 내지 레이어 L4의 로딩 지연 시간을 감소시키기 위해 앞선 레이어에서 미리 로딩을 수행할 필요는 없다. 이는 레이어 L6, 레이어 L7 및 레이어 L9의 경우에도 마찬가지이다.
그런데, 레이어 L5의 경우 diff 값이 -1이므로, 1에 해당하는 시간만큼 앞선 레이어에서 미리 로딩을 수행하는 것이 바람직하다고 할 수 있다. 따라서, 전자 장치(100)는 레이어 L4의 look a head를 2로 조정하고, 최대 로딩 시간을 1만큼 증가시켜 3으로 조정할 수 있다. 그 결과, 레이어 L4의 diff 값은 여전히 0 이상이기 때문에 레이어 L4에서 로딩 시간 지연은 여전히 일어나지 않으며, L5의 diff 값이 0으로 조정되기 때문에 L5의 로딩 시간 지연 또한 일어나지 않게 된다.
한편, 레이어 L8의 경우 diff 값이 -2이므로, 2에 해당하는 시간만큼 앞선 레이어에서 미리 로딩을 수행하는 것이 바람직하다고 할 수 있다. 따라서, 전자 장치(100)는 레이어 L7의 look a head를 1로 조정하고, 최대 로딩 시간을 1만큼 증가시켜 1로 조정할 수 있다. 그 결과, 레이어 L7의 diff 값은 여전히 0 이상이기 때문에 레이어 L7에서 로딩 시간 지연은 여전히 일어나지 않으며, 다만 L5의 diff 값은 -2에서 -1로 감소하지만 여전히 로딩 시간 지연이 일어나는 경우라고 할 수 있다. 따라서, 전자 장치(100)는 레이어 L6의 look a head를 2로 조정하고, 최대 로딩 시간을 1만큼 증가시켜 1로 조정할 수 있다. 그 결과, 레이어 L6의 diff 값은 여전히 0 이상이기 때문에 레이어 L6에서 로딩 시간 지연은 여전히 일어나지 않으며, L8의 diff 값이 0으로 조정되기 때문에 L8의 로딩 시간 지연 또한 일어나지 않게 된다.
한편, 이상에서는 레이어 L1에 대한 설명을 생략하고 레이어 L2에 대해서부터 설명하였으나, 신경망 모델의 학습은 반복적으로 수행되는바, 전자 장치(100)는 상술한 방법과 마찬가지 방법으로 레이어 L9의 연산 단계를 수행하는 동안 레이어 L1에 필요한 로딩을 미리 수행할 수 있다.
신경망 모델을 학습시키는 동안 상술한 바와 같은 반복 횟수가 증가되면, look a head 값이 각각의 레이어 별로 최적화된 값으로 수렴하게 되고, 각각의 레이어 별 diff 값이 0 또는 양수로 조정될 수 있다.
도 9 및 도 10을 참조하여 상술한 실시 예에 따르면, 전자 장치(100)는 복수의 레이어 별 연산 시간과 데이터 로딩 시간의 균형을 맞춰, 전체 레이어에서 소요되는 데이터 로딩 시간을 현저하게 감소시킬 수 있게 되며, 그 결과 메모리의 사용량이 최소화될 수 있다.
도 11은 본 개시의 일 실시 예에 따라 신경망 모델의 연산 단계에 이용되는 레이어의 개수를 조정하는 방법에 대해 설명하기 위한 도면이다.
도 11의 N, N+1 및 N+2는 학습 과정의 반복 횟수를 구별하여 나타내는 것이며, 실선으로 표시된 레이어는 연산 단계에 이용되는 레이어를 나타내며, 점선으로 표시된 레이어는 연산 단계에 이용되지 않는 레이어를 나타낸다. 여기서, 연산 단계란 순전파 단계를 의미한다.
구체적으로, 연산 단계에 이용되는 레이어는 그래디언트를 산출하여 가중치를 업데이트하는 레이어로서, 그래디언트를 계산하기 위해서는 순전파 단계에서 산출된 결과 값을 이용하기 때문에 이를 역전파 단계를 수행하기 전까지 메모리에 로딩해 놓고 있어야 한다. 반면, 연산 단계에 이용되지 않는 레이어들은 가중치를 업데이트하지 않고 역전파 단계에서 도함수를 산출하는 단계에서만 이용되기 때문에 순전파 단계에서 산출된 결과 값을 로딩해 놓을 필요가 없다.
구체적으로, 전자 장치(100)는 N번째 반복에서, 전체 레이어 중 홀수번째 레이어들(도 11의 layer0, layer2, layer4, layer7, layer10)만을 연산 단계에서 이용할 수 있다. 이 경우, 전체 레이어 중 짝수번째 레이어들(도 11의 layer1, layer3, layer5, layer9)은 전술한 바와 같이 연산 단계에 이용되지 않고 역전파 단계에서 도함수를 산출하는 단계에서만 이용되기 때문에 메모리 사용량을 줄일 수 있게 된다.
그리고, 신경망 모델의 학습에 있어서 모든 레이어의 가중치를 업데이트해야 하기 때문에, 전자 장치(100)는 N+1번째 반복에서, 전체 레이어 중 짝수번째 레이어들(도 11의 layer1, layer3, layer5, layer9)만을 연산 단계에서 이용하고, 전체 레이어 중 홀수번째 레이어들(도 11의 layer0, layer2, layer4, layer7, layer10)은 역전파 단계에서 도함수를 산출하는 단계에서 이용할 수 있다.
나아가, 전자 장치(100)는 N+2번째 반복에서, 전체 레이어 중 홀수번째 레이어들(도 11의 layer0, layer2, layer4, layer7, layer10)만을 연산 단계에서 이용하고, 전체 레이어 중 짝수번째 레이어들(도 11의 layer1, layer3, layer5, layer9)은 역전파 단계에서 도함수를 산출하는 단계에서 이용할 수 있다.
한편, 이상에서는 전체 레이어 중 홀수번째 레이어들과 짝수번째 레이어들을 구분하여 연산 단계에 이용하는 실시 예에 대해 설명하였으나, 각각의 반복에서 연산 단계에 이용되는 레이어들은 도 11의 예시와 달리 선택될 수도 있음은 물론이다.
도 11을 참조하여 상술한 실시 예에 따르면, 전자 장치(100)는 효과적인 방법으로 메모리를 사용하면서 신경망 모델을 학습시킬 수 있게 된다. 한편, 각각의 반복에서 복수의 레이어 중 일부 레이어만을 이용하는 경우 신경망 모델의 정확도가 감소할 우려가 있을 수 있다. 그러나, 본 개시에 따르면 다음 반복에서는 이전 반복에서 이용되지 않은 레이어들을 연산 단계에 참여시킬 수 있다. 그리고 본 개시는 서버에 의해 기 학습된 후 전자 장치(100)에 의해 개인화를 위해 다시 학습되는 경우에 적용될 수 있다. 결국 상술한 실시 예에 따르면, 신경망 모델의 정확도를 크게 감소시키지 않는 범위 내에서 메모리의 사용량을 최소화할 수 있게 된다.
도 12는 본 개시의 일 실시 예에 따른 전자 장치(100)의 구성을 간략하게 나타내는 블록도이고, 도 13은 본 개시의 일 실시 예에 따른 전자 장치(100)의 구성을 상세하게 나타내는 블록도이다.
도 12에 도시된 바와 같이, 본 개시의 일 실시 예에 따른 전자 장치(100)는 메모리(110) 및 프로세서(120)를 포함한다.
메모리(110)에는 전자 장치(100)에 관한 적어도 하나의 인스트럭션(instruction)이 저장될 수 있다. 그리고, 메모리(110)에는 전자 장치(100)를 구동시키기 위한 O/S(Operating System)가 저장될 수 있다. 또한, 메모리(110)에는 본 개시의 다양한 실시 예들에 따라 전자 장치(100)가 동작하기 위한 각종 소프트웨어 프로그램이나 애플리케이션이 저장될 수도 있다. 그리고, 메모리(110)는 플래시 메모리(110)(Flash Memory) 등과 같은 반도체 메모리(110)나 하드디스크(Hard Disk) 등과 같은 자기 저장 매체 등을 포함할 수 있다.
구체적으로, 메모리(110)에는 본 개시의 다양한 실시 예에 따라 전자 장치(100)가 동작하기 위한 각종 소프트웨어 모듈이 저장될 수 있으며, 프로세서(120)는 메모리(110)에 저장된 각종 소프트웨어 모듈을 실행하여 전자 장치(100)의 동작을 제어할 수 있다. 즉, 메모리(110)는 프로세서(120)에 의해 액세스되며, 프로세서(120)에 의한 데이터의 독취/기록/수정/삭제/갱신 등이 수행될 수 있다.
한편, 본 개시에서 메모리(110)라는 용어는 메모리(110), 프로세서(120) 내 롬(미도시), 램(미도시) 또는 전자 장치(100)에 장착되는 메모리(110) 카드(미도시)(예를 들어, micro SD 카드, 메모리(110) 스틱)를 포함하는 의미로 사용될 수 있다.
특히, 본 개시에 따른 다양한 실시 예에 있어서, 메모리(110)에는 신경망 모델에 관련된 데이터, 구체적으로, 신경망 모델의 레이어들과 가중치를 비롯한 각종 파라미터에 대한 정보가 저장될 수 잇다. 또한, 메모리(110)에는 본 개시에 따른 복수의 텐서, 복수의 텐서에 할당되는 데이터 등이 저장될 수 있다. 그리고, 메모리(110)에는 본 개시에 따라 결정된 복수의 단계의 실행 순서에 대한 정보, 본 개시에 따른 제1 정보, 제2 정보, 복수의 텐서가 이용되는 단계의 유형에 대한 정보 등이 저장될 수 있다.
그 밖에도 본 개시의 목적을 달성하기 위한 범위 내에서 필요한 다양한 정보가 메모리(110)에 저장될 수 있으며, 메모리(110)에 저장된 정보는 서버 또는 외부 장치로부터 수신되거나 사용자에 의해 입력됨에 따라 갱신될 수도 있다.
프로세서(120)는 전자 장치(100)의 전반적인 동작을 제어한다. 구체적으로, 프로세서(120)는 메모리(110)를 포함하는 전자 장치(100)의 구성과 연결되며, 상술한 바와 같은 메모리(110)에 저장된 적어도 하나의 인스트럭션을 실행함으로써, 전자 장치(100)의 동작을 전반적으로 제어할 수 있다.
프로세서(120)는 다양한 방식으로 구현될 수 있다. 예를 들어, 프로세서(120)는 주문형 집적 회로(Application Specific Integrated Circuit, ASIC), 임베디드 프로세서(120), 마이크로 프로세서(120), 하드웨어 컨트롤 로직, 하드웨어 유한 상태 기계(hardware Finite State Machine, FSM), 디지털 신호 프로세서(120)(Digital Signal Processor, DSP) 중 적어도 하나로 구현될 수 있다. 한편, 본 개시에서 프로세서(120)라는 용어는 CPU(Central Processing Unit), GPU(Graphic Processing Unit) 및 MPU(Main Processing Unit)등을 포함하는 의미로 사용될 수 있다.
특히, 본 개시에 따른 다양한 실시 예에 있어서, 프로세서(120)는 신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 복수의 단계의 실행 순서를 결정하고, 결정된 실행 순서에 기초하여, 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하며, 제1 정보 및 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 결정된 실행 순서를 통합하고, 통합된 실행 순서에 기초하여, 복수의 텐서에 대응되는 데이터를 할당하기 위한 메모리(110)의 영역을 최소화하여 복수의 텐서에 데이터를 할당하며, 복수의 텐서 및 복수의 텐서들에 할당된 데이터를 이용하여 통합된 실행 순서에 따라 신경망 모델을 학습시킬 수 있다. 여기서, 제1 정보 및 제2 정보에 대해서는 전술한 바 있으므로 동일한 내용에 대한 중복 설명은 생략한다.
일 실시 예에 있어서, 프로세서(120)는 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 같거나 빠르면, 제1 텐서와 제2 텐서가 공유되도록 결정된 실행 순서의 적어도 일부를 통합할 수 있다.
일 실시 예에 있어서, 프로세서(120)는 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 느린 경우, 제2 텐서에 대응되는 제2 정보가 제4 모드 정보이면, 제1 텐서와 제2 텐서가 공유되도록 결정된 실행 순서의 적어도 일부를 통합할 수 있다.
일 실시 예에 있어서, 프로세서(120)는 통합된 실행 순서에 기초하여, 복수의 텐서에 대응되는 데이터를 할당하기 위한 메모리(110)의 영역을 추가로 생성할 것인지 또는 이전에 생성된 메모리(110)의 영역에 덮어쓸 것인지 여부를 결정함으로써 메모리(110)의 영역을 최소화할 수 있다.
그 밖에도 도 1 내지 도 11을 참조하여 상술한 바와 같은 다양한 실시 예는 프로세서(120)의 제어 과정에 있어서도 마찬가지로 적용될 수 있는바, 동일한 내용에 대한 상세한 중복 설명은 생략한다.
한편, 도 13에 도시된 바와 같이, 프로세서(120)는 텐서 관리 모듈(tensor management module, 121) 및 데이터 할당 모듈(data allocation module, 122)을 더 포함할 수 있다.
전술한 바와 같이, 본 개시에 따른 텐서는 차원에 대한 정보, 그리고 본 개시에 따른 실행 순서에 대한 정보, 복수의 텐서가 이용되는 단계의 유형에 대한 정보 및 모드 정보 등을 포함하는 스펙(specification) 부분과 텐서의 스펙에 할당되는 데이터를 의미하는 데이터 부분으로 구별될 수 있다. 그리고, 도 1 내지 도 8을 참조하여 설명한 실시 예는 텐서의 스펙을 정의하는 과정과 텐서의 스펙에 데이터를 할당하는 과정을 포함한다.
그리고, 텐서 관리 모듈(121)은 텐서의 스펙을 정의하는 과정을 제어하는 모듈을 말하며, 텐서 풀(tensor pool)와 같이 명명될 수도 있다. 구체적으로, 텐서 관리 모듈(121)은 도 1의 단계 S110, S120 및 S130에 따른 동작을 수행할 수 있다.
데이터 할당 모듈(122)은 텐서의 스펙에 데이터를 할당하는 과정을 제어하는 모듈을 말하며, 메모리(110) 풀(memory planner)와 같이 명명될 수도 있다. 구체적으로, 데이터 할당 모듈(122)은 도 1의 단계 S140에 따른 동작을 수행할 수 있다.
이상에서는 프로세서(120)에 포함된 모듈의 예로서 텐서 관리 모듈(121) 및 데이터 할당 모듈(122)에 대해 설명하였으나, 그 밖에도 본 개시에 따른 다양한 동작에 대응되는 모듈들이 하드웨어 모듈 또는 소프트웨어 모듈의 형태로 구현될 수 있음은 물론이다.
한편, 이상에서 상술한 바와 같은 신경망 모델에 관련된 기능은 메모리(110) 및 프로세서(120)를 통해 수행될 수 있다.
프로세서(120)는 하나 또는 복수의 프로세서(120)로 구성될 수 있다. 이때, 하나 또는 복수의 프로세서(120)는 CPU, AP 등과 같은 범용 프로세서(120), GPU. VPU 등과 같은 그래픽 전용 프로세서(120) 또는 NPU와 같은 인공 지능 전용 프로세서(120)일 수 있다.
하나 또는 복수의 프로세서(120)는, 비휘발성 메모리(110) 및 휘발성 메모리(110)에 저장된 기 정의된 동작 규칙 또는 인공 지능 모델에 따라, 입력 데이터를 처리하도록 제어한다. 기 정의된 동작 규칙 또는 인공 지능 모델은 학습을 통해 만들어진 것을 특징으로 한다.
여기서, 학습을 통해 만들어진다는 것은, 다수의 학습 데이터들에 학습 알고리즘을 적용함으로써, 원하는 특성의 기 정의된 동작 규칙 또는 인공 지능 모델이 만들어짐을 의미한다. 이러한 학습은 본 개시에 따른 인공 지능이 수행되는 기기 자체에서 이루어질 수도 있고, 별도의 서버/시스템을 통해 이루어질 수도 있다.
인공 지능 모델은, 복수의 신경망 레이어들로 구성될 수 있다. 각 레이어는 복수의 가중치(weight values)을 갖고 있으며, 이전(previous) 레이어의 연산 결과와 복수의 가중치의 연산을 통해 레이어의 연산을 수행한다. 신경망의 예로는, CNN (Convolutional Neural Network), DNN (Deep Neural Network), RNN (Recurrent Neural Network), RBM (Restricted Boltzmann Machine), DBN (Deep Belief Network), BRDNN(Bidirectional Recurrent Deep Neural Network), GAN(Generative Adversarial Networks) 및 심층 Q-네트워크 (Deep Q-Networks)이 있으며, 본 개시에서의 신경망은 명시한 경우를 제외하고 전술한 예에 한정되지 않는다.
학습 알고리즘은, 다수의 학습 데이터들을 이용하여 소정의 대상 기기(예컨대, 로봇)을 훈련시켜 소정의 대상 기기 스스로 결정을 내리거나 예측을 할 수 있도록 하는 방법이다. 학습 알고리즘의 예로는, 지도형 학습(supervised learning), 비지도형 학습(unsupervised learning), 준지도형 학습(semi-supervised learning) 또는 강화 학습(reinforcement learning)이 있으며, 본 개시에서의 학습 알고리즘은 명시한 경우를 제외하고 전술한 예에 한정되지 않는다.
기기로 읽을 수 있는 저장매체는, 비일시적(non-transitory) 저장매체의 형태로 제공될 수 있다. 여기서, '비일시적 저장매체'는 실재(tangible)하는 장치이고, 신호(signal)(예: 전자기파)를 포함하지 않는다는 것을 의미할 뿐이며, 이 용어는 데이터가 저장매체에 반영구적으로 저장되는 경우와 임시적으로 저장되는 경우를 구분하지 않는다. 예로, '비일시적 저장매체'는 데이터가 임시적으로 저장되는 버퍼를 포함할 수 있다.
일 실시 예에 따르면, 본 문서에 개시된 다양한 실시 예들에 따른 방법은 컴퓨터 프로그램 제품(computer program product)에 포함되어 제공될 수 있다. 컴퓨터 프로그램 제품은 상품으로서 판매자 및 구매자 간에 거래될 수 있다. 컴퓨터 프로그램 제품은 기기로 읽을 수 있는 저장 매체(예: compact disc read only memory (CD-ROM))의 형태로 배포되거나, 또는 어플리케이션 스토어(예: 플레이 스토어TM)를 통해 또는 두개의 사용자 장치들(예: 스마트폰들) 간에 직접, 온라인으로 배포(예: 다운로드 또는 업로드)될 수 있다. 온라인 배포의 경우에, 컴퓨터 프로그램 제품(예: 다운로더블 앱(downloadable app))의 적어도 일부는 제조사의 서버, 어플리케이션 스토어의 서버, 또는 중계 서버의 메모리(110)와 같은 기기로 읽을 수 있는 저장 매체에 적어도 일시 저장되거나, 임시적으로 생성될 수 있다.
이상에서 상술한 바와 같은 본 개시의 다양한 실시 예들에 따른 구성 요소(예: 모듈 또는 프로그램) 각각은 단수 또는 복수의 개체로 구성될 수 있으며, 전술한 해당 서브 구성 요소들 중 일부 서브 구성 요소가 생략되거나, 또는 다른 서브 구성 요소가 다양한 실시 예에 더 포함될 수 있다. 대체적으로 또는 추가적으로, 일부 구성 요소들(예: 모듈 또는 프로그램)은 하나의 개체로 통합되어, 통합되기 이전의 각각의 해당 구성 요소에 의해 수행되는 기능을 동일 또는 유사하게 수행할 수 있다.
다양한 실시 예들에 따른, 모듈, 프로그램 또는 다른 구성 요소에 의해 수행되는 동작들은 순차적, 병렬적, 반복적 또는 휴리스틱하게 실행되거나, 적어도 일부 동작이 다른 순서로 실행되거나, 생략되거나, 또는 다른 동작이 추가될 수 있다.
한편, 본 개시에서 사용된 용어 "부" 또는 "모듈"은 하드웨어, 소프트웨어 또는 펌웨어로 구성된 유닛을 포함하며, 예를 들면, 로직, 논리 블록, 부품, 또는 회로 등의 용어와 상호 호환적으로 사용될 수 있다. "부" 또는 "모듈"은, 일체로 구성된 부품 또는 하나 또는 그 이상의 기능을 수행하는 최소 단위 또는 그 일부가 될 수 있다. 예를 들면, 모듈은 ASIC(application-specific integrated circuit)으로 구성될 수 있다.
본 개시의 다양한 실시 예들은 기기(machine)(예: 컴퓨터)로 읽을 수 있는 저장 매체(machine-readable storage media에 저장된 명령어를 포함하는 소프트웨어로 구현될 수 있다. 기기는 저장 매체로부터 저장된 명령어를 호출하고, 호출된 명령어에 따라 동작이 가능한 장치로서, 개시된 실시 예들에 따른 전자 장치(예: 전자 장치(100))를 포함할 수 있다.
상기 명령이 프로세서에 의해 실행될 경우, 프로세서가 직접 또는 상기 프로세서의 제어 하에 다른 구성요소들을 이용하여 상기 명령에 해당하는 기능을 수행할 수 있다. 명령은 컴파일러 또는 인터프리터에 의해 생성 또는 실행되는 코드를 포함할 수 있다.
이상에서는 본 개시의 바람직한 실시 예에 대하여 도시하고 설명하였지만, 본 개시는 상술한 특정의 실시 예에 한정되지 아니하며, 청구범위에서 청구하는 본 개시의 요지를 벗어남이 없이 당해 개시가 속하는 기술분야에서 통상의 지식을 가진 자에 의해 다양한 변형실시가 가능한 것은 물론이고, 이러한 변형실시들은 본 개시의 기술적 사상이나 전망으로부터 개별적으로 이해되어서는 안 될 것이다.

Claims (15)

  1. 전자 장치에 있어서,
    신경망 모델에 관련된 데이터를 저장하는 메모리; 및
    상기 신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 상기 복수의 단계의 실행 순서를 결정하고,
    상기 결정된 실행 순서에 기초하여, 상기 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 상기 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하며,
    상기 제1 정보 및 상기 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 상기 결정된 실행 순서를 통합하고,
    상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 상기 메모리의 영역을 최소화하여 상기 복수의 텐서에 상기 데이터를 할당하며,
    상기 복수의 텐서 및 상기 복수의 텐서들에 할당된 상기 데이터를 이용하여 상기 통합된 실행 순서에 따라 상기 신경망 모델을 학습시키는 프로세서; 를 포함하는 전자 장치.
  2. 제1 항에 있어서,
    상기 제1 정보는 상기 복수의 단계 중 상기 복수의 텐서가 이용되는 단계의 유형에 대한 정보에 기초하여 결정되는 전자 장치.
  3. 1 항에 있어서,
    상기 복수의 텐서가 이용되는 단계의 유형은 상기 순전파 단계, 상기 그래디언트 계산 단계, 상기 도함수 계산 단계, 상기 그래디언트 계산 단계와 상기 도함수 계산 단계를 포함하는 역전파 단계, 상기 순전파 단계와 상기 역전파 단계를 포함하는 단계 및 상기 신경망 모델의 전체 학습 단계 각각을 나타내는 유형을 포함하는 전자 장치.
  4. 제1 항에 있어서,
    상기 제2 정보는 텐서가 기 할당된 상태임을 나타내는 제1 모드 정보, 텐서를 새로 생성해야 한다는 것을 나타내는 제2 모드 정보, 텐서의 데이터가 변경되지만 텐서를 인접한 레이어의 다른 텐서와 공유할 수 있다는 것을 나타내는 제3 모드 정보, 텐서의 데이터가 변경되지 않으므로 텐서를 상기 다른 텐서와 공유할 수 있다는 것을 나타내는 제4 모드 정보 및 텐서를 모든 텐서와 공유할 수 있다는 것을 나타내는 제5 모드 정보를 포함하는 전자 장치.
  5. 제4 항에 있어서,
    상기 프로세서는,
    상기 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 상기 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 같거나 빠르면, 상기 제1 텐서와 상기 제2 텐서가 공유되도록 상기 결정된 실행 순서의 적어도 일부를 통합하는 전자 장치.
  6. 제5 항에 있어서,
    상기 프로세서는,
    상기 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 상기 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 느린 경우, 상기 제2 텐서에 대응되는 제2 정보가 상기 제4 모드 정보이면, 상기 제1 텐서와 상기 제2 텐서가 공유되도록 상기 결정된 실행 순서의 적어도 일부를 통합하는 전자 장치.
  7. 제1 항에 있어서,
    상기 프로세서는,
    상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 메모리의 영역을 추가로 생성할 것인지 또는 이전에 생성된 메모리의 영역에 덮어쓸 것인지 여부를 결정함으로써 상기 메모리의 영역을 최소화하는 전자 장치.
  8. 전자 장치의 제어 방법에 있어서,
    신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 상기 복수의 단계의 실행 순서를 결정하는 단계;
    상기 결정된 실행 순서에 기초하여, 상기 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 상기 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하는 단계;
    상기 제1 정보 및 상기 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 상기 결정된 실행 순서를 통합하는 단계;
    상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 상기 메모리의 영역을 최소화하여 상기 복수의 텐서에 상기 데이터를 할당하는 단계; 및
    상기 복수의 텐서 및 상기 복수의 텐서들에 할당된 상기 데이터를 이용하여 상기 통합된 실행 순서에 따라 상기 신경망 모델을 학습시키는 단계; 를 포함하는 전자 장치의 제어 방법.
  9. 제8 항에 있어서,
    상기 제1 정보는 상기 복수의 단계 중 상기 복수의 텐서가 이용되는 단계의 유형에 대한 정보에 기초하여 결정되는 전자 장치의 제어 방법.
  10. 제8 항에 있어서,
    상기 복수의 텐서가 이용되는 단계의 유형은 상기 순전아 단계, 상기 그래디언트 계산 단계, 상기 도함수 계산 단계, 상기 그래디언트 계산 단계와 상기 도함수 계산 단계를 포함하는 역전파 단계, 상기 순전파 단계와 상기 역전파 단계를 포함하는 단계 및 상기 신경망 모델의 전체 학습 단계 각각을 나타내는 유형을 포함하는 전자 장치의 제어 방법.
  11. 제8 항에 있어서,
    상기 제2 정보는 텐서가 기 할당된 상태임을 나타내는 제1 모드 정보, 텐서를 새로 생성해야 한다는 것을 나타내는 제2 모드 정보, 텐서의 데이터가 변경되지만 텐서를 인접한 레이어의 다른 텐서와 공유할 수 있다는 것을 나타내는 제3 모드 정보, 텐서의 데이터가 변경되지 않으므로 텐서를 상기 다른 텐서와 공유할 수 있다는 것을 나타내는 제4 모드 정보 및 텐서를 모든 텐서와 공유할 수 있다는 것을 나타내는 제5 모드 정보를 포함하는 전자 장치의 제어 방법.
  12. 제11 항에 있어서,
    상기 결정된 실행 순서를 통합하는 단계는,
    상기 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 상기 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 같거나 빠르면, 상기 제1 텐서와 상기 제2 텐서가 공유되도록 상기 결정된 실행 순서의 적어도 일부를 통합하는 전자 장치의 제어 방법.
  13. 제12 항에 있어서,
    상기 결정된 실행 순서를 통합하는 단계는,
    상기 복수의 텐서 중 제1 텐서가 가장 마지막으로 이용되는 단계의 실행 순서가 상기 제1 텐서의 레이어와 인접한 레이어의 제2 텐서가 가장 처음으로 이용되는 단계의 실행 순서보다 느린 경우, 상기 제2 텐서에 대응되는 제2 정보가 상기 제4 모드 정보이면, 상기 제1 텐서와 상기 제2 텐서가 공유되도록 상기 결정된 실행 순서의 적어도 일부를 통합하는 전자 장치의 제어 방법.
  14. 제8 항에 있어서,
    상기 복수의 텐서에 상기 데이터를 할당하는 단계는,
    상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 메모리의 영역을 추가로 생성할 것인지 또는 이전에 생성된 메모리의 영역에 덮어쓸 것인지 여부를 결정함으로써 상기 메모리의 영역을 최소화하는 단계를 포함하는 전자 장치의 제어 방법.
  15. 전자 장치의 제어 방법을 실행하는 프로그램을 포함하는 비일시적 컴퓨터 판독 가능 기록매체에 있어서,
    상기 전자 장치의 제어 방법은,
    신경망 모델의 복수의 레이어를 통해 수행되는 학습 단계를 순전파 단계, 그래디언트(gradient) 계산 단계 및 도함수 계산 단계를 포함하는 복수의 단계로 구분하여 상기 복수의 단계의 실행 순서를 결정하는 단계;
    상기 결정된 실행 순서에 기초하여, 상기 복수의 레이어에서 이용되는 복수의 텐서(tensor)가 상기 결정된 실행 순서에 따른 복수의 단계 중 어떠한 단계에 이용되는지에 대한 제1 정보를 획득하는 단계;
    상기 제1 정보 및 상기 복수의 레이어 중 인접한 레이어들에서 이용되는 텐서들을 공유할 수 있는지에 대한 제2 정보에 기초하여 상기 결정된 실행 순서를 통합하는 단계;
    상기 통합된 실행 순서에 기초하여, 상기 복수의 텐서에 대응되는 데이터를 할당하기 위한 상기 메모리의 영역을 최소화하여 상기 복수의 텐서에 상기 데이터를 할당하는 단계; 및
    상기 복수의 텐서 및 상기 복수의 텐서들에 할당된 상기 데이터를 이용하여 상기 통합된 실행 순서에 따라 상기 신경망 모델을 학습시키는 단계; 를 포함하는 컴퓨터 판독 가능 기록매체.
PCT/KR2022/020897 2021-12-22 2022-12-20 전자 장치 및 전자 장치의 제어 방법 WO2023121263A1 (ko)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
KR20210185454 2021-12-22
KR10-2021-0185454 2021-12-22
KR1020220031573A KR20230095759A (ko) 2021-12-22 2022-03-14 전자 장치 및 전자 장치의 제어 방법
KR10-2022-0031573 2022-03-14

Publications (1)

Publication Number Publication Date
WO2023121263A1 true WO2023121263A1 (ko) 2023-06-29

Family

ID=86903423

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2022/020897 WO2023121263A1 (ko) 2021-12-22 2022-12-20 전자 장치 및 전자 장치의 제어 방법

Country Status (1)

Country Link
WO (1) WO2023121263A1 (ko)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20190055610A (ko) * 2017-11-15 2019-05-23 삼성전자주식회사 뉴럴 네트워크 모델들의 공용 연산 그룹을 단일 처리하는 뉴럴 네트워크 시스템, 이를 포함하는 애플리케이션 프로세서 및 뉴럴 네트워크 시스템의 동작방법
KR102164427B1 (ko) * 2015-12-02 2020-10-12 구글 엘엘씨 신경망의 실행 순서 결정
KR102219904B1 (ko) * 2018-12-13 2021-02-24 한동대학교 산학협력단 딥러닝 프레임워크를 활용한 뉴럴 네트워크 구조 확장 방법
US11010379B2 (en) * 2017-08-15 2021-05-18 Sap Se Increasing performance of in-memory databases using re-ordered query execution plans
KR20210091880A (ko) * 2020-01-15 2021-07-23 삼성전자주식회사 뉴럴 네트워크 모델 재구성 방법 및 이를 수행하는 데이터 처리 장치

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102164427B1 (ko) * 2015-12-02 2020-10-12 구글 엘엘씨 신경망의 실행 순서 결정
US11010379B2 (en) * 2017-08-15 2021-05-18 Sap Se Increasing performance of in-memory databases using re-ordered query execution plans
KR20190055610A (ko) * 2017-11-15 2019-05-23 삼성전자주식회사 뉴럴 네트워크 모델들의 공용 연산 그룹을 단일 처리하는 뉴럴 네트워크 시스템, 이를 포함하는 애플리케이션 프로세서 및 뉴럴 네트워크 시스템의 동작방법
KR102219904B1 (ko) * 2018-12-13 2021-02-24 한동대학교 산학협력단 딥러닝 프레임워크를 활용한 뉴럴 네트워크 구조 확장 방법
KR20210091880A (ko) * 2020-01-15 2021-07-23 삼성전자주식회사 뉴럴 네트워크 모델 재구성 방법 및 이를 수행하는 데이터 처리 장치

Similar Documents

Publication Publication Date Title
WO2019194465A1 (ko) 뉴럴 네트워크 프로세서
WO2019098538A1 (en) Device and method for processing convolution operation using kernel
WO2018030772A1 (ko) 감응식 교통 신호 제어 방법 및 그 장치
EP3756145A1 (en) Electronic apparatus and control method thereof
WO2020180084A1 (ko) 타겟 이미지의 채색 완성 방법, 장치 및 컴퓨터 프로그램
WO2021118270A1 (en) Method and electronic device for deblurring blurred image
WO2019164251A1 (en) Method of performing learning of deep neural network and apparatus thereof
WO2019050297A1 (ko) 뉴럴 네트워크 학습 방법 및 장치
WO2020141720A1 (en) Apparatus and method for managing application program
WO2023121263A1 (ko) 전자 장치 및 전자 장치의 제어 방법
WO2020045794A1 (ko) 전자 장치 및 그 제어 방법
WO2020246724A1 (en) Electronic apparatus and method of performing operations thereof
WO2020231196A1 (en) Method and system for predicting and optimizing resource utilization of ai applications in an embedded computing system
WO2023022321A1 (ko) 분산 학습용 서버 및 분산 학습 방법
WO2022146031A1 (en) Method and device of computing layout selection for efficient dnn inference
EP3707646A1 (en) Electronic apparatus and control method thereof
WO2022035058A1 (en) Method and system of dnn modularization for optimal loading
WO2022145676A1 (ko) 전자 장치 및 이의 제어 방법
WO2023008797A1 (ko) 전자 장치 및 전자 장치의 제어 방법
WO2022177091A1 (ko) 전자 장치 및 이의 제어 방법
WO2021137420A1 (ko) 분석알고리즘개발장치 및 그 동작 방법
WO2022086045A1 (ko) 전자 장치 및 이의 제어 방법
WO2021246818A1 (ko) 뉴럴 네트워크 프로세싱 방법 및 이를 위한 장치
WO2021230470A1 (ko) 전자 장치 및 그 제어 방법
WO2022080758A1 (ko) 전자 장치 및 전자 장치의 제어 방법

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: 22911896

Country of ref document: EP

Kind code of ref document: A1