The following description relates to a method and apparatus with a dynamic convolution operation.
Diverse operations related to artificial intelligence (AI) may be performed in a user terminal to enhance user convenience. In general, since an AI algorithm requires a large quantity of memory and computing, the AI algorithm may be performed via a standalone server or cloud service, and it may be difficult to perform the AI algorithm in a user terminal such as a smartphone.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
In one general aspect, a method with dynamic convolution includes: determining kernel adaptation weights corresponding to weight matrices in a category set represented by a plurality of predetermined discrete values; determining a unified kernel based on the weight matrices and the kernel adaptation weights corresponding to the weight matrices; and performing a convolution operation based on the unified kernel.
The determining of the kernel adaptation weights may include: generating a plurality of kernel relevance scores corresponding to input data; and determining the kernel adaptation weights based on the kernel relevance scores.
The determining of the kernel adaptation weights based on the kernel relevance scores may include determining the kernel adaptation weights by performing Gumbel softmax sampling on the kernel relevance scores.
The determining of the kernel adaptation weights may include determining the kernel adaptation weights corresponding to the weight matrices in a category set represented by “0” and “1”.
The determining of the unified kernel may include determining the unified kernel by summing weight matrices of which the kernel adaptation weights are determined to be “1”.
The determining of the kernel adaptation weights may include, in a category set represented by “0” and “1”, determining kernel adaptation weights that correspond to one of a plurality of weight matrices to be “1”.
The determining of the unified kernel may include determining the one weight matrix as the unified kernel.
The method may include: determining a unified bias based on biases and the kernel adaptation weights, wherein the performing of the convolution operation may include performing the convolution operation based on input data, the unified kernel, and the unified bias.
In another general aspect, one or more embodiments include a non-transitory computer-readable storage medium storing instructions that, when executed by one or more processors, configure the one or more processors to perform any one, any combination, or all operations and methods described herein.
In another general aspect, an apparatus with dynamic convolution includes: one or more processors configured to: determine kernel adaptation weights corresponding to weight matrices in a category set represented by a plurality of predetermined discrete values; determine a unified kernel based on the weight matrices and the kernel adaptation weights corresponding to the weight matrices; and perform a convolution operation based on the unified kernel.
For the determining of the kernel adaptation weights, the one or more processors may be configured to: generate a plurality of kernel relevance scores corresponding to input data; and determine the kernel adaptation weights based on the kernel relevance scores.
For the determining of the kernel adaptation weights based on the kernel relevance scores, the one or more processors may be configured to determine the kernel adaptation weights based on the kernel relevance scores and determine the kernel adaptation weights by performing Gumbel softmax sampling on the kernel relevance scores.
For the determining of the kernel adaptation weights, the one or more processors may be configured to determine the kernel adaptation weights corresponding to the weight matrices in a category set represented by “0” and “1”.
For the determining of the unified kernel, the one or more processors may be configured to determine the unified kernel by summing weight matrices of which the kernel adaptation weights are determined to be “1”.
For the determining of the kernel adaptation weights, the one or more processors may be configured to, in a category set represented by “0” and “1”, determine kernel adaptation weights that correspond to one of a plurality of weight matrices to be “1”.
For the determining of the unified kernel, the one or more processors may be configured to determine the one weight matrix as the unified kernel.
The one or more processors may be configured to: determine a unified bias based on biases and the kernel adaptation weights; and perform the convolution operation based on input data, the unified kernel, and the unified bias.
In another general aspect, a method with dynamic convolution includes: determining discrete valued kernel adaptation weights for weight matrices based on input data; determining a unified kernel based on the weight matrices and the kernel adaptation weights corresponding to the weight matrices; and generating an output by performing convolution between the input data and the unified kernel.
The determining of the unified kernel may include selecting one of the weight matrices as the unified kernel.
The selecting of the one of the weight matrices may include selecting one of the weight matrices corresponding to a predetermined weight among the kernel adaptation weights.
Other features and aspects will be apparent from the following detailed description, the drawings, and the claims.
Throughout the drawings and the detailed description, unless otherwise described or provided, the same drawing reference numerals will be understood to refer to the same elements, features, and structures. The drawings may not be to scale, and the relative size, proportions, and depiction of elements in the drawings may be exaggerated for clarity, illustration, and convenience.
The following detailed description is provided to assist the reader in gaining a comprehensive understanding of the methods, apparatuses, and/or systems described herein. However, various changes, modifications, and equivalents of the methods, apparatuses, and/or systems described herein will be apparent after an understanding of the disclosure of this application. For example, the sequences of operations described herein are merely examples, and are not limited to those set forth herein, but may be changed as will be apparent after an understanding of the disclosure of this application, with the exception of operations necessarily occurring in a certain order. Also, descriptions of features that are known in the art, after an understanding of the disclosure of this application, may be omitted for increased clarity and conciseness.
Although terms of “first” or “second” are used to explain various members, components, regions, layers, or sections, these members, components, regions, layers, or sections are not limited to the terms. Rather, these terms should be used only to distinguish one member, component, region, layer, or section from another member, component, region, layer, or section. For example, a “first” member, component, region, layer, or section referred to in examples described herein may also be referred to as a “second” member, component, region, layer, or section without departing from the teachings of the examples.
It should be noted that if it is described that one component is “connected”, “coupled”, or “joined” to another component, a third component may be “connected”, “coupled”, and “joined” between the first and second components, although the first component may be directly connected, coupled, or joined to the second component. On the contrary, it should be noted that if it is described that one component is “directly connected”, “directly coupled”, or “directly joined” to another component, a third component may be absent. Expressions describing a relationship between components, for example, “between”, directly between”, or “directly neighboring”, etc., should be interpreted to be alike.
The singular forms “a”, “an”, and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. As used herein, the term “and/or” includes any one and any combination of any two or more of the associated listed items. It should be further understood that the terms “includes,” “comprises,” and/or “comprising,” when used in this specification, specify the presence of stated features, integers, steps, operations, elements, components or a combination thereof, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. The use of the term “may” herein with respect to an example or embodiment (for example, as to what an example or embodiment may include or implement) means that at least one example or embodiment exists where such a feature is included or implemented, while all examples are not limited thereto.
Unless otherwise defined, all terms used herein including technical or scientific terms have the same meaning as commonly understood by one of ordinary skill in the art to which examples belong after and understanding of the present disclosure. It will be further understood that terms, such as those defined in commonly-used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The examples may be implemented as various types of products, such as, for example, a personal computer (PC), a laptop computer, a tablet computer, a smart phone, a television (TV), a smart home appliance, an intelligent vehicle, a kiosk, and a wearable device. Hereinafter, examples will be described in detail with reference to the accompanying drawings. In the drawings, like reference numerals are used for like elements.
An artificial intelligence (Al) algorithm including deep learning may input data 10 to an artificial neural network (ANN), and may learn output data 30 through an operation, for example, a convolution. In the ANN, nodes may be connected to each other and collectively operate to process input data. Various types of neural networks may include, for example, a convolutional neural network (CNN), a recurrent neural network (RNN), a deep belief network (DBN), or a restricted Boltzmann machine (RBM), but are not limited thereto. In a feed-forward neural network, nodes may have links to other nodes. The links may be expanded in a single direction, for example, a forward direction, through a neural network. While the neural network may be referred to as an “artificial” neural network, such reference is not intended to impart any relatedness with respect to how the neural network computationally maps or thereby intuitively recognizes information and how a biological brain operates. I.e., the term “artificial neural network” is merely a term of art referring to the hardware-implemented neural network.
The CNN 20 may be used to extract “features”, for example, a border, a line, and a color from the input data 10. The CNN 20 may include a plurality of layers. Each of the layers may receive data, process data input to a corresponding layer, and generate data that is to be output from the corresponding layer. Data output from a layer may be a feature map generated by performing a convolution operation of an image or a feature map that is input to the CNN 20 and weight values of at least one filter. Initial layers of the CNN 20 may operate to extract features of a relatively low level, for example, edges or gradients, from an input. Subsequent layers of the CNN 20 may gradually extract more complex features, for example, an eye or a nose in an image.
A low-power and low-computational lightweight network may be used for running an AI algorithm in a mobile device such as a smartphone. For example, an ANN may be executed in an environment such as an application processor (AP) mounted on a smartphone or a microcontroller (MCU) having lower processing power.
For example, implementing dynamic convolution may increase a representation capacity of a network while alleviating a burden of an increase in operation quantity. Unlike typical convolution that has one convolution kernel per one layer, the dynamic convolution may learn a plurality sets of convolution kernels. Then, instead of a convolution operation being performed on each kernel, a final convolution operation may be performed after a plurality of convolution kernels have aggregated into one kernel using input image information.
Thus, using such dynamic convolution, a burden on an increase in operation quantity may not be significant compared to an increase in a number of kernels in use. In addition, a network accuracy may be improved since a kernel weight is dynamically adjusted according to input information.
However, typical dynamic convolution may have a limitation in an environment in which a use of computational resources is highly restricted such as an MCU.
More particularly, a typical convolution operation for an input x may be represented by Equation 1 shown below, for example.
y=Wx+b Equation 1:
In Equation 1, W may denote a weight matrix of a convolution kernel and b may denote a bias. Thereafter, output data of each layer may be obtained by applying an appropriate activation function (for example, Relu and Sigmoid) to y.
On the other hand, a dynamic convolution operation may be represented by Equation 2 shown below, for example.
y={tilde over (W)}x+{tilde over (b)} Equation 2:
In Equation 3, as shown below, a unified kernel {tilde over (W)} and a unified bias {tilde over (b)} may be generated by a linear combination of K weight matrices Wk and K biases bk respectively.
{tilde over (W)}=Σ
k=1
Kπk(x)Wk, {tilde over (b)}=Σk=1Kπk(x)bk. Equation 3:
In Equation 3, a kernel adaptation weight πk corresponding to each weight matrix Wk is required. A real number πk having a continuous value may be determined through a routing function performed on an input x. As shown in the equation, to obtain a final {tilde over (W)}, multiplication operation of multiplying Wk and πk by K number of times and summation operation of summing all multiplication results by K number of times are required, and thus, computational overheads by KCinCoutDk2+KCout may occur in the typical dynamic convolution operation.
Furthermore, for weight lightening of a network, real number weights represented by floating point precision may be converted into integer type through a quantization process such that they use a smaller bit-width and may perform operation. Thus, using πk in a real number form in dynamic convolution may add burden on the quantization process of the typical dynamic convolution operation.
Dynamic convolution is proposed as a way to increase a representation capacity of a network while alleviating the burden of adding operation quantity since a low-power and low-computational lightweight network is used for running an AI algorithm in a mobile device such as a smartphone. However, the typical dynamic convolution operation method as described above may impose a burden of an additional quantization process for a kernel adaptation weight which is a real number. In addition, the typical dynamic convolution operation method may reduce operation efficiency since a full precision multiply and add (MAC) operation is required for performing kernel aggregation.
In contrast, a dynamic convolution operation method of one or more embodiments may reduce operation overhead and quantization error with respect to kernel aggregation in a dynamic operation by sampling a kernel adaptation weight πk in a category set represented by a discrete value. A more detailed description of non-limiting examples is provided below.
Referring to
In operation 210, the apparatus for performing a dynamic convolution operation may determine kernel adaptation weights corresponding to weight matrices respectively in a category set represented by a plurality of predetermined discrete values. A number of elements and values included in the category set may be predetermined.
For example, the apparatus for performing a dynamic convolution operation may perform sampling on kernel adaptation weights corresponding to weight matrices in two categories represented by {0, 1}. Alternatively, the apparatus for performing a dynamic convolution operation may perform sampling on kernel adaptation weights corresponding to weight matrices in six categories represented by {21, 20,, 0, 2−1, 2−2 2−3}.
In operation 220, the apparatus for performing a dynamic convolution operation may determine a unified kernel based on weight matrices and kernel adaptation weights corresponding to the weight matrices. In a typical dynamic convolution operation, a full precision MAC operation between weight matrices and kernel adaptation weights corresponding to the weight matrices is required for calculating a unified kernel.
However, the apparatus for performing a dynamic convolution operation of one or more embodiments may determine a unified kernel without a full precision MAC operation.
In operation 230, the apparatus for performing a dynamic convolution operation may perform a convolution operation based on the unified kernel.
Referring to
To perform sampling based on input data, the kernel adaptation weight sampling module may generate a plurality (for example, K) of kernel relevance scores by compressing the input data by performing global average pooling on the input data, and then, passing the compressed input data through a linear layer. The kernel relevance scores may be represented by logit.
Performing sampling may refer to modeling a discrete random variable. However, it may be difficult to express the discrete random variable using a typical neural network training method because a non-differentiable layer is generated since a slope is 0. Accordingly, the kernel adaptation weight sampling module may use a Gumbel softmax sampling method to learn a sampling module from a neural network.
More specifically, the kernel adaptation weight sampling module may determine kernel adaptation weights by performing Gumbel softmax sampling on a plurality (for example, K) of kernel relevance scores. More specifically, the kernel adaptation weight sampling module may determine one category that has the largest value by adding noise extracted from a Gumbel distribution to a plurality (for example, K) of kernel relevance scores and causing passing through a softmax layer. However, the sampling method is not limited to Gumbel softmax sampling and various types of sampling methods may be applied.
The kernel composition module may determine a unified kernel based on weight matrices and kernel adaptation weights corresponding to the weight matrices. The apparatus for performing a dynamic convolution operation may determine the unified kernel without performing a full precision MAC operation.
Referring to
In operation 420, the apparatus for performing a dynamic convolution operation may determine a unified kernel through selective kernel summation. For example, when a kernel adaptation weight πk corresponding to a weight matrix Wk is sampled to be 0, the corresponding weight matrix Wk may not need to be multiplied by the kernel adaptation weight πk (e.g., it may be determined that such multiplication is unnecessary, as the output may be 0). Accordingly, when a kernel adaptation weight πk corresponding to a weight matrix Wk is sampled to be 0, the apparatus for performing a dynamic convolution operation may omit performing an operation on the corresponding weight matrix Wk in a summation operation for generating a unified kernel W˜.
Conversely, when a kernel adaptation weight πk corresponding to a weight matrix Wk is sampled to be 1, the weight matrix Wk may not need to be multiplied by the kernel adaptation weight πk and may maintain the weight matrix Wk. Accordingly, when a kernel adaptation weight πk corresponding to a weight matrix Wk is sampled to be 1, the apparatus for performing a dynamic convolution operation may generate a unified kernel W˜ by performing a summation operation after selecting weight matrices Wk of which kernel adaptation weights are 1.
In operation 430, the apparatus for performing a dynamic convolution operation that determines the unified kernel may perform a convolution operation based on the unified kernel.
Referring to
In operation 520, the apparatus for performing a dynamic convolution operation may determine a unified kernel through kernel selection.
Since only a kernel adaptation weight that corresponds to one of the weight matrices is sampled to be 1, the apparatus for performing a dynamic convolution operation may select a weight matrix Wk of which a kernel adaptation weight πk is 1 without performing a summation operation for calculating the unified kernel and may determine it to be a final unified kernel.
In operation 530, the apparatus for performing a dynamic convolution operation that determines the unified kernel may perform a convolution operation based on the unified kernel.
Referring to
For example, the apparatus for performing a dynamic convolution operation may perform sampling in two categories represented by 0 and a power of 2. For example, the apparatus for performing a dynamic convolution operation may perform sampling on kernel adaptation weights corresponding to weight matrices in six categories represented by {21, 20,, 0, 2−1,2−2, 2−3}.
In operation 620, the apparatus for performing a dynamic convolution operation may alleviate operation overhead by performing a shift operation that has better operation efficiency instead of performing a multiplication operation of a kernel adaptation weight πk and a weight matrix Wk.
In operation 630, the apparatus for performing a dynamic convolution operation may generate a final unified kernel by summing shifted weight matrices.
In operation 640, the apparatus for performing a dynamic convolution operation that determines the unified kernel may perform a convolution operation based on the unified kernel.
Referring to
The processor 710 may be a hardware-implemented processing device having a physically structured circuit to execute desired operations. For example, the desired operations may include code or instructions included in a program. The hardware-implemented processing device may include, for example, a microprocessor, a central processing unit (CPU), a graphics processing unit (GPU), a processor core, a multi-core processor, a multiprocessor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a neural processing unit (NPU), a microcontroller (MCU) and the like.
The processor 710 may execute a program and control the apparatus for performing the dynamic convolution operation 700. Program codes to be executed by the processor 710 may be stored in the memory 730.
The processor 710 may determine kernel adaptation weights corresponding to weight matrices respectively in a category set represented by a plurality of predetermined discrete values, may determine a unified kernel based on the weight matrices and the kernel adaptation weights corresponding to the weight matrices, and may perform a convolution operation based on the unified kernel. The processor 710 may perform any one or more or all operations described above with reference to
The memory 730 may include a ROM 731 and an SRAM 733. The ROM 731 may store a neural network model and code for a dynamic convolution operation.
The SRAM 733 may be used as a working memory for operations performed by the processor 710 and may store various application programs. The memory 730 may store a variety of information generated in a processing process of the processor 710 described above. In addition, the memory 730 may store a variety of data and programs. The memory 730 may include a large-capacity storage medium such as a hard disk to store the variety of data.
The sensors 770 may include an image sensor. For example, the image sensor may detect a motion in image frames and may perform adjustment on at least a portion of regions in a target frame among the image frames based on whether the motion is detected. The image sensor may generate a trigger signal by detecting whether a target object is present by an adjusted target frame. The processor 710 may be activated by the trigger signal generated by the sensors 770 and may perform various application programs.
The apparatus for performing the dynamic convolution operation 700 may include devices in various fields, such as, for example, an advanced driver-assistance system (ADAS), a heads-up display (HUD), a 3D digital information display (DID), a navigation device, a neuromorphic device, a 3D mobile device, a smart phone, a smart appliance (for example, a smart TV, a smart refrigerator, a smart washing machine), a smart vehicle, an Internet of Things (IoT) device, a medical device, a measurement device, and the like. Here, the term 3D mobile device may be construed as meaning all such display devices, for example, a display device for displaying augmented reality (AR), virtual reality (VR), and/or mixed reality (MR), a head-mounted display (HMD), a face-mounted display (FMD), AR glasses, and the like.
Also, although not shown in the drawings, the apparatus for performing the dynamic convolution operation 700 may further include a display (not shown) and a communication interface (not shown). The display may be, for example, a touch display and/or a flexible display, but is not limited thereto.
The apparatuses, processors, memories, communication interfaces, sensors, communication buses, apparatus for performing a dynamic convolution operation 700, processor 710, memory 730, communication interface 750, sensors 770, communication bus 707, and other apparatuses, devices, units, modules, and components described herein with respect to
The methods illustrated in
Instructions or software to control computing hardware, for example, one or more processors or computers, to implement the hardware components and perform the methods as described above may be written as computer programs, code segments, instructions or any combination thereof, for individually or collectively instructing or configuring the one or more processors or computers to operate as a machine or special-purpose computer to perform the operations that are performed by the hardware components and the methods as described above. In one example, the instructions or software include machine code that is directly executed by the one or more processors or computers, such as machine code produced by a compiler. In another example, the instructions or software includes higher-level code that is executed by the one or more processors or computer using an interpreter. The instructions or software may be written using any programming language based on the block diagrams and the flow charts illustrated in the drawings and the corresponding descriptions in the specification, which disclose algorithms for performing the operations that are performed by the hardware components and the methods as described above.
The instructions or software to control computing hardware, for example, one or more processors or computers, to implement the hardware components and perform the methods as described above, and any associated data, data files, and data structures, may be recorded, stored, or fixed in or on one or more non-transitory computer-readable storage media. Examples of a non-transitory computer-readable storage medium include read-only memory (ROM), random-access programmable read only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random-access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), flash memory, non-volatile memory, CD-ROMs, CD-Rs, CD+Rs, CD-RWs, CD+RWs, DVD-ROMs, DVD-Rs, DVD+Rs, DVD-RWs, DVD+RWs, DVD-RAMs, BD-ROMs, BD-Rs, BD-R LTHs, BD-REs, blue-ray or optical disk storage, hard disk drive (HDD), solid state drive (SSD), flash memory, a card type memory such as multimedia card micro or a card (for example, secure digital (SD) or extreme digital (XD)), magnetic tapes, floppy disks, magneto-optical data storage devices, optical data storage devices, hard disks, solid-state disks, and any other device that is configured to store the instructions or software and any associated data, data files, and data structures in a non-transitory manner and provide the instructions or software and any associated data, data files, and data structures to one or more processors or computers so that the one or more processors or computers can execute the instructions. In one example, the instructions or software and any associated data, data files, and data structures are distributed over network-coupled computer systems so that the instructions and software and any associated data, data files, and data structures are stored, accessed, and executed in a distributed fashion by the one or more processors or computers.
While this disclosure includes specific examples, it will be apparent after an understanding of the disclosure of this application that various changes in form and details may be made in these examples without departing from the spirit and scope of the claims and their equivalents. The examples described herein are to be considered in a descriptive sense only, and not for purposes of limitation. Descriptions of features or aspects in each example are to be considered as being applicable to similar features or aspects in other examples. Suitable results may be achieved if the described techniques are performed in a different order, and/or if components in a described system, architecture, device, or circuit are combined in a different manner, and/or replaced or supplemented by other components or their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
10-2021-0126395 | Sep 2021 | KR | national |
This application claims the benefit under 35 USC § 119(a) of Korean Patent Application No. 10-2021-0126395, filed on Sep. 24, 2021 in the Korean Intellectual Property Office, the entire disclosure of which is incorporated herein by reference for all purposes.