Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP7614475B2 - Calculation device and calculation method - Google Patents
[go: Go Back, main page]

JP7614475B2 - Calculation device and calculation method - Google Patents

Calculation device and calculation method Download PDF

Info

Publication number
JP7614475B2
JP7614475B2 JP2020193718A JP2020193718A JP7614475B2 JP 7614475 B2 JP7614475 B2 JP 7614475B2 JP 2020193718 A JP2020193718 A JP 2020193718A JP 2020193718 A JP2020193718 A JP 2020193718A JP 7614475 B2 JP7614475 B2 JP 7614475B2
Authority
JP
Japan
Prior art keywords
decimal point
output
shift
amount
input
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
JP2020193718A
Other languages
Japanese (ja)
Other versions
JP2022082257A (en
Inventor
真人 木山
太樹 尼崎
全広 飯田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kumamoto University NUC
Original Assignee
Kumamoto University NUC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kumamoto University NUC filed Critical Kumamoto University NUC
Priority to JP2020193718A priority Critical patent/JP7614475B2/en
Publication of JP2022082257A publication Critical patent/JP2022082257A/en
Application granted granted Critical
Publication of JP7614475B2 publication Critical patent/JP7614475B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Complex Calculations (AREA)

Description

本発明の実施形態は、演算装置、及び演算方法に関する。 Embodiments of the present invention relate to a computing device and a computing method.

エッジデバイスやAI(artificial intelligence)チップは、GPU(Graphics Processing Unit)を備えたコンピュータと比較すると資源が少ない。そのため、学習済ディープニューラルネットワークモデル(DNN(Deep Neural Network))の実行は、エッジデバイスでは困難となる。そこで、モデルの重みを軽量化するため、量子化が行われる。
通常、DNNの内部では、32ビット演算精度の浮動小数点が演算で使われる。積和演算時の桁あふれ検出やAIチップでの動作検証のため、量子化ではその精度を8ビットなど、より少ないビット幅へ変換し、演算を行うことで重みを軽量化する。
Edge devices and AI (artificial intelligence) chips have fewer resources than computers equipped with GPUs (Graphics Processing Units). Therefore, it is difficult to run a trained deep neural network model (DNN (Deep Neural Network)) on an edge device. Therefore, quantization is performed to reduce the weight of the model.
Normally, floating-point numbers with 32-bit arithmetic precision are used inside DNNs. In order to detect overflow during multiplication and accumulation operations and to verify operation on AI chips, the precision is converted to a smaller bit width, such as 8 bits, during quantization, and the weights are reduced by performing the calculations.

ニューラルネットワークの重みを量子化する技術に関して、パラメータを量子化するとき、前段階、学習中、推論中でパラメータを変更可能にする技術が知られている(例えば、特許文献1参照)。この技術では、桁あふれなどはその都度調べられ、パラメータが更新される。
また、CNN(Convolutional neural network)に対して重みを量子化し、実行する技術が知られている(例えば、特許文献2参照)。
また、浮動小数点で学習されたモデルの重みを固定小数点に変換する技術が知られている(例えば、特許文献3参照)。この技術では、統計に基づいてビット幅、シフト量などのパラメータの決定、CNNのチャンネルごとにパラメータの設定が可能である。
Regarding the technology for quantizing the weights of a neural network, a technology is known that allows parameters to be changed in the pre-stage, during learning, and during inference when quantizing the parameters (see, for example, Patent Document 1). In this technology, overflow and the like are checked each time, and the parameters are updated.
Furthermore, a technique is known in which weights are quantized for a convolutional neural network (CNN) and then executed (see, for example, Patent Document 2).
There is also known a technique for converting the weights of a model trained in floating point to fixed point (see, for example, Patent Document 3). This technique makes it possible to determine parameters such as bit width and shift amount based on statistics, and to set parameters for each CNN channel.

特開2020-64635号公報JP 2020-64635 A 特開2020-060967号公報JP 2020-060967 A 特開2019-032833号公報JP 2019-032833 A

本発明は、前述した問題を解決すべくなされたもので、固定小数点の形式の入力値に対する学習モデルの出力値の精度を向上できる演算装置、及び演算方法を提供することを目的とする。 The present invention has been made to solve the above-mentioned problems, and aims to provide a calculation device and a calculation method that can improve the accuracy of the output value of a learning model for input values in fixed-point format.

本発明の一実施形態は、ニューラルネットワーク形式の学習モデルのパラメータの小数点のシフト量を特定する情報を取得する取得部と、前記取得部が取得したパラメータの小数点のシフト量を特定する情報に基づいて、異なるビット幅で固定小数点の形式へ変換された複数の入力値に対する前記学習モデルの出力値を求め、求めた複数の前記出力値の各々と出力値の小数点のシフト量とに基づいて、求めた複数の前記出力値の各々の小数点をシフトさせる演算部と、複数の前記出力値の各々の小数点をシフトさせた結果の精度を導出する導出部と、を備え、前記入力値は、固定小数点の形式である、演算装置である。
本発明の一実施形態は、前述の演算装置において、前記パラメータには、複数の層の各々のパラメータが含まれる。
本発明の一実施形態は、前述の演算装置において、前記パラメータには、ウエイトおよび出力が含まれる。
本発明の一実施形態は、前述の演算装置において、前記パラメータには、バイアスがさらに含まれる。
本発明の一実施形態は、前述の演算装置において、前記パラメータは、固定小数点の形式である。
本発明の一実施形態は、前述の演算装置において、前記学習モデルは、ディープニューラルネットワーク形式の学習済モデルに基づいて、パラメータを固定小数点の形式に変換することによって作成されたものである。
本発明の一実施形態は、前述の演算装置において、前記演算部は、前記パラメータに基づいて、入力値に対して、MAC(multiply-accumulate)演算を行う
One embodiment of the present invention is a calculation device comprising: an acquisition unit that acquires information specifying the amount of decimal point shift of parameters of a neural network format learning model; a calculation unit that calculates output values of the learning model for multiple input values converted to fixed-point format with different bit widths based on the information specifying the amount of decimal point shift of the parameters acquired by the acquisition unit, and shifts the decimal point of each of the calculated multiple output values based on each of the calculated multiple output values and the amount of decimal point shift of the output value; and a derivation unit that derives the accuracy of the result of shifting the decimal point of each of the calculated multiple output values , wherein the input values are in fixed-point format.
In one embodiment of the present invention, in the aforementioned computing device, the parameters include parameters for each of a plurality of layers.
In one embodiment of the present invention, in the aforementioned computing device, the parameters include weights and outputs.
In one embodiment of the present invention, in the aforementioned computing device, the parameters further include a bias.
In one embodiment of the present invention, in the aforementioned arithmetic device, the parameters are in a fixed-point format.
One embodiment of the present invention is in the aforementioned computing device, wherein the learning model is created by converting parameters into fixed-point format based on a trained model in deep neural network format.
One embodiment of the present invention is the aforementioned arithmetic device, wherein the arithmetic unit performs a MAC (multiply-accumulate) operation on an input value based on the parameter .

本発明の一実施形態は、ニューラルネットワーク形式の学習モデルのパラメータの小数点のシフト量を特定する情報を取得するステップと、取得する前記ステップで取得したパラメータの小数点のシフト量を特定する情報に基づいて、異なるビット幅で固定小数点の形式へ変換された複数の入力値に対する前記学習モデルの出力値を求め、求めた複数の前記出力値の各々と出力値の小数点のシフト量とに基づいて、求めた複数の前記出力値の各々の小数点をシフトさせるステップと、複数の前記出力値の各々の小数点をシフトさせた結果の精度を導出するステップと、を有し、前記入力値は、固定小数点の形式である、コンピュータが実行する演算方法である。 One embodiment of the present invention is a computer-executed calculation method comprising the steps of: acquiring information specifying the amount of decimal point shift of parameters of a neural network-type learning model; determining output values of the learning model for multiple input values converted to fixed-point format with different bit widths based on the information specifying the amount of decimal point shift of the parameters acquired in the acquiring step; shifting the decimal point of each of the multiple output values based on each of the multiple output values and the amount of decimal point shift of the output value; and deriving the precision of the result of shifting the decimal point of each of the multiple output values , wherein the input values are in fixed-point format.

本発明の実施形態によれば、固定小数点の形式の入力値に対する学習モデルの出力値の精度を向上できる演算装置、及び演算方法を提供できる。 According to an embodiment of the present invention, it is possible to provide a calculation device and a calculation method that can improve the accuracy of the output value of a learning model for an input value in fixed-point format.

本発明の実施形態に係る演算装置の構成図である。FIG. 2 is a configuration diagram of a calculation device according to an embodiment of the present invention. 本実施形態に係る演算装置が有する学習モデルの一例を示す図である。FIG. 2 is a diagram showing an example of a learning model possessed by the arithmetic device according to the present embodiment. 本実施形態に係る演算装置が処理する浮動小数点の形式の入力値の一例を説明するための図である。1 is a diagram for explaining an example of an input value in a floating-point format processed by the arithmetic device according to the present embodiment. FIG. 本実施形態に係る演算装置が処理する固定小数点の形式の入力値の一例を説明するための図である。1 is a diagram for explaining an example of an input value in a fixed-point format processed by the arithmetic device according to the present embodiment. FIG. 本実施形態に係る演算装置が実行する演算の一例を説明するための図である。FIG. 2 is a diagram for explaining an example of a calculation executed by the calculation device according to the present embodiment. 本実施形態に係る端末装置のパラメータの小数点のシフト量の導出を説明するための図である。11 is a diagram for explaining derivation of the decimal point shift amount of the parameter of the terminal device according to the present embodiment. FIG. 本実施形態に係る端末装置が有する学習モデルの一例を示す図である。FIG. 2 is a diagram showing an example of a learning model possessed by a terminal device according to the present embodiment. 本実施形態に係る演算装置の動作の一例を示すフローチャートである。5 is a flowchart showing an example of the operation of the arithmetic device according to the present embodiment. 本実施形態に係る端末装置の動作の一例を示すフローチャートである。6 is a flowchart showing an example of an operation of the terminal device according to the embodiment. 本実施形態に係る演算装置の精度を説明するための図である。1 is a diagram for explaining the accuracy of a calculation device according to the present embodiment. FIG. 実施形態の変形例に係る演算装置の構成図である。FIG. 13 is a configuration diagram of a calculation device according to a modified example of the embodiment. 実施形態の変形例に係る演算装置の動作の一例を示すフローチャートである。13 is a flowchart illustrating an example of an operation of a calculation device according to a modified example of the embodiment. 本実施形態の変形例に係る演算装置の出力の精度の導出結果の一例を示す図である。FIG. 11 is a diagram showing an example of a derived result of the accuracy of the output of a calculation device according to a modified example of the present embodiment.

次に、本発明の実施形態に係る演算装置、及び演算方法を、図面を参照しつつ説明する。以下で説明する実施形態は一例に過ぎず、本発明が適用される実施形態は、以下の実施形態に限られない。
なお、実施形態を説明するための全図において、同一の機能を有するものは同一符号を用い、繰り返しの説明は省略する。
また、本願でいう「XXに基づく」とは、「少なくともXXに基づく」ことを意味し、XXに加えて別の要素に基づく場合も含む。また、「XXに基づく」とは、XXを直接に用いる場合に限定されず、XXに対して演算や加工が行われたものに基づく場合も含む。「XX」は、任意の要素(例えば、任意の情報)である。
Next, a calculation device and a calculation method according to an embodiment of the present invention will be described with reference to the drawings. The embodiment described below is merely an example, and the embodiment to which the present invention is applied is not limited to the following embodiment.
In addition, in all the drawings for explaining the embodiments, the same reference numerals are used for the parts having the same functions, and the repeated explanation is omitted.
In addition, in this application, "based on XX" means "based on at least XX" and includes cases where it is based on other elements in addition to XX. Furthermore, "based on XX" is not limited to cases where XX is directly used, but also includes cases where it is based on XX that has been calculated or processed. "XX" is any element (for example, any information).

(実施形態)
[全体構成]
図1は、本発明の実施形態に係る演算装置の構成図である。
演算装置100に、入力値が入力される。入力値の一例は、浮動小数点の形式である。以下、入力値が、浮動小数点の形式である場合について説明を続ける。
演算装置100は、入力された入力値を受け付ける。演算装置100は、受け付けた入力値を浮動小数点の形式から固定小数点の形式へ変換する。固定小数点の形式へ変換するときの桁数(ビット幅)nは、予め設定されている。
(Embodiment)
[Overall configuration]
FIG. 1 is a configuration diagram of a computing device according to an embodiment of the present invention.
An input value is input to the arithmetic device 100. An example of the input value is a floating-point format. The following will continue with the explanation of the case where the input value is in the floating-point format.
The arithmetic unit 100 receives an input value. The arithmetic unit 100 converts the received input value from a floating-point format to a fixed-point format. The number of digits (bit width) n when converting to the fixed-point format is set in advance.

演算装置100は、学習モデルに基づいて、その学習モデルに含まれるパラメータの小数点のシフト量を特定する情報を取得する。学習モデルの一例は、ディープニューラルネットワークなどのニューラルネットワーク形式の学習モデルである。学習モデルの一例は、Pytonで記述されている。
演算装置100は、固定小数点の形式へ変換後の入力値およびパラメータの小数点のシフト量を特定する情報に基づいて、入力値に対する学習モデルの出力値を演算する。
演算装置100は、学習モデルの出力値の演算結果を導出する際に、出力値の小数点のシフト量osfに基づいて、積和演算の結果の小数点をシフトさせることによって最終出力値を導出する。演算装置100は、導出した最終出力値を出力する。
以下、演算装置100について説明する。
The arithmetic device 100 acquires information for specifying the amount of shift of the decimal point of a parameter included in the learning model based on the learning model. An example of the learning model is a neural network type learning model such as a deep neural network. An example of the learning model is written in Python.
The arithmetic device 100 calculates an output value of the learning model for an input value based on the input value converted into fixed-point format and information specifying the amount of shift of the decimal point of the parameter.
When deriving the calculation result of the output value of the learning model, the calculation device 100 derives the final output value by shifting the decimal point of the result of the product-sum calculation based on the shift amount osf of the decimal point of the output value. The calculation device 100 outputs the derived final output value.
The arithmetic device 100 will now be described.

[演算装置100]
演算装置100は、スマートフォン、携帯端末、又はパーソナルコンピュータ、タブレット端末装置、あるいはその他の情報処理機器として実現される。演算装置100は、例えば、入力部110と、受付部120と、取得部125と、演算部130と、出力部140と、記憶部150とを備える。
[Calculation device 100]
The arithmetic device 100 is realized as a smartphone, a mobile terminal, a personal computer, a tablet terminal device, or other information processing devices. The arithmetic device 100 includes, for example, an input unit 110, a reception unit 120, an acquisition unit 125, a arithmetic unit 130, an output unit 140, and a storage unit 150.

入力部110は、入力デバイスを備える。入力部110には、入力値を特定する情報が入力される。入力部110は、入力された入力値を特定する情報を取得する。入力値の一例は、32ビットの浮動小数点の形式の数である。以下、一例として、入力値が32ビットの浮動小数点の形式の数である場合について説明を続ける。 The input unit 110 includes an input device. Information that specifies an input value is input to the input unit 110. The input unit 110 acquires information that specifies the input value that has been input. An example of an input value is a number in a 32-bit floating-point format. Below, as an example, the explanation will continue for the case where the input value is a number in a 32-bit floating-point format.

記憶部150は、HDD(Hard Disk Drive)やフラッシュメモリ、RAM(Random Access Memory)、ROM(Read Only Memory)などにより実現される。記憶部150は、学習モデル152とシフト量情報154とが記憶される。
学習モデル152の一例は、ディープニューラルネットワーク形式の学習モデルである。この学習モデル152は、量子化されている。学習モデルを量子化する方法については、後述する。以下、学習モデル152が、ディープニューラルネットワーク形式の量子化された学習モデルである場合について説明を続ける。
The storage unit 150 is realized by a hard disk drive (HDD), a flash memory, a random access memory (RAM), a read only memory (ROM), etc. The storage unit 150 stores a learning model 152 and shift amount information 154.
An example of the learning model 152 is a learning model in the form of a deep neural network. This learning model 152 is quantized. A method for quantizing a learning model will be described later. Below, the explanation will be continued for the case where the learning model 152 is a quantized learning model in the form of a deep neural network.

図2は、本実施形態に係る演算装置が有する学習モデルの一例を示す図である。図2は、学習モデル152の一例として、ディープニューラルネットワーク形式の量子化された学習モデル152を示す。
学習モデル152は、入力層151-1と、中間層151-2と、出力層151-3とを備える。入力層151-1は一または複数のユニットを有し、中間層151-2は一または複数のユニットを有し、出力層151-3は一または複数のユニットを有する。入力層151-1に含まれる一または複数のユニットの各々は、中間層151-2に含まれる一または複数のユニットの各々と、一または複数のリンクによって接続される。中間層151-2に含まれる一または複数のユニットの各々は、出力層151-3に含まれる一または複数のユニットの各々と、一または複数のリンクによって接続される。
2 is a diagram showing an example of a learning model included in the arithmetic device according to the present embodiment. As an example of the learning model 152, FIG. 2 shows a quantized learning model 152 in a deep neural network format.
The learning model 152 includes an input layer 151-1, an intermediate layer 151-2, and an output layer 151-3. The input layer 151-1 has one or more units, the intermediate layer 151-2 has one or more units, and the output layer 151-3 has one or more units. Each of the one or more units included in the input layer 151-1 is connected to each of the one or more units included in the intermediate layer 151-2 by one or more links. Each of the one or more units included in the intermediate layer 151-2 is connected to each of the one or more units included in the output layer 151-3 by one or more links.

一または複数のユニットの各々は、一または複数の他のユニットが出力した情報を取得し、取得した情報を処理する。一または複数のユニットの各々は、情報を処理した結果を出力する。具体的には、一または複数のユニットの各々は、一または複数の入力値を取得する。一または複数のユニットの各々は、取得した一または複数の入力値とパラメータとに基づいて、出力を導出する。ここで、パラメータには、ウエイトが含まれる。
さらに、パラメータには、バイアスが含まれてもよい。一例として、パラメータには、ウエイトとバイアスとが含まれる場合について説明を続ける。一または複数のユニットの各々は、一または複数の入力値と一または複数のウエイトとをそれぞれ乗算した結果の和とバイアスとを加算する。
Each of the one or more units acquires information output by one or more other units and processes the acquired information. Each of the one or more units outputs a result of processing the information. Specifically, each of the one or more units acquires one or more input values. Each of the one or more units derives an output based on the acquired one or more input values and parameters. Here, the parameters include weights.
Furthermore, the parameters may include a bias. As an example, the description will be continued assuming that the parameters include a weight and a bias. Each of the one or more units multiplies one or more input values by one or more weights, respectively, and adds the sum of the results and the bias.

シフト量情報154は、学習モデル152に含まれる入力層151-1と中間層151-2と出力層151-3との各々の入力値の小数点のシフト量を特定する情報と、パラメータの小数点のシフト量を特定する情報と、入力層151-1と中間層151-2と出力層151-3との各々の出力の小数点のシフト量を特定する情報とを記憶する。パラメータには、ウエイトとバイアスとが含まれる。
つまり、パラメータの小数点のシフト量を特定する情報には、ウエイトの小数点のシフト量wsfを特定する情報とバイアスの小数点のシフト量を特定する情報とが含まれる。入力層151-1と中間層151-2と出力層151-3との各々の入力値の小数点のシフト量を特定する情報と、パラメータの小数点のシフト量と、入力層151-1と中間層151-2と出力層151-3との各々の出力の小数点のシフト量とを導出する方法については、後述する。
The shift amount information 154 stores information specifying the shift amount of the decimal point of each input value of the input layer 151-1, the intermediate layer 151-2, and the output layer 151-3 included in the learning model 152, information specifying the shift amount of the decimal point of the parameter, and information specifying the shift amount of the decimal point of each output of the input layer 151-1, the intermediate layer 151-2, and the output layer 151-3. The parameters include weights and biases.
That is, the information specifying the amount of shift of the decimal point of the parameter includes information specifying the amount of shift of the decimal point of the weight wsf and information specifying the amount of shift of the decimal point of the bias. A method for deriving information specifying the amount of shift of the decimal point of the input value of each of the input layer 151-1, the intermediate layer 151-2, and the output layer 151-3, the amount of shift of the decimal point of the parameter, and the amount of shift of the decimal point of the output of each of the input layer 151-1, the intermediate layer 151-2, and the output layer 151-3 will be described later.

受付部120は、入力部110に入力された入力値を特定する情報を取得し、取得した入力値を特定する情報を受け付ける。受付部120が受け付けた入力値を特定する情報は、演算部130へ出力される。
取得部125は、受付部120が入力値を特定する情報を受け付けた場合に、記憶部150のシフト量情報154に記憶されている入力層と中間層と出力層との各々の入力値の小数点のシフト量を特定する情報と、パラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とを取得する。取得部125が取得した入力層と中間層と出力層との各々の入力値の小数点のシフト量を特定する情報と、パラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とは、演算部130へ出力される。
The receiving unit 120 obtains information specifying an input value input to the input unit 110, and receives the obtained information specifying the input value. The information specifying the input value received by the receiving unit 120 is output to the calculation unit 130.
When the receiving unit 120 receives information specifying an input value, the acquiring unit 125 acquires information specifying the shift amount of the decimal point of each of the input values of the input layer, the intermediate layer, and the output layer, information specifying the shift amount of the decimal point of the parameter, and information specifying the shift amount of the decimal point of each of the outputs of the input layer, the intermediate layer, and the output layer, which are stored in the shift amount information 154 of the storage unit 150. The information specifying the shift amount of the decimal point of each of the input values of the input layer, the intermediate layer, and the output layer, information specifying the shift amount of the decimal point of the parameter, and information specifying the shift amount of the decimal point of each of the outputs of the input layer, the intermediate layer, and the output layer acquired by the acquiring unit 125 are output to the calculation unit 130.

演算部130は、受付部120が受け付けた入力値を特定する情報を取得する。演算部130は、取得した入力値を特定する情報と、入力値の小数点のシフト量を特定する情報とに基づいて、式(1)を演算することによって入力値を固定小数点の形式へ変換する。

Figure 0007614475000001
式(1)において、「xint」は浮動小数点の形式の数値を固定小数点の形式の数値へ変換したものである。「x」は浮動小数点の形式の数値である。「sf」は小数点のシフト量である。「xq」は、浮動小数点の形式の数値を固定小数点の形式の数値へ変換したものを浮動小数点の形式の数値へ変換したものである。「clamp(-2n-1,2n-1-1,xint)」は、xintが-2n-1以下である場合には-2n-1とし、xintが2n-1-1以上である場合には2n-1-1とすることを表す。
例えば、演算部130は、ビット幅nを8とした場合には、32ビットの浮動小数点の形式の入力値を、8ビットの固定小数点の形式に変換する。 The calculation unit 130 acquires information that identifies the input value accepted by the acceptance unit 120. The calculation unit 130 converts the input value into a fixed-point format by calculating formula (1) based on the acquired information that identifies the input value and information that identifies the amount of shift of the decimal point of the input value.
Figure 0007614475000001
In formula (1), "xint" is a floating-point number converted to a fixed-point number. "x" is a floating-point number. "sf" is the shift amount of the decimal point. "xq" is a floating-point number converted to a fixed-point number, which is then converted back to a floating-point number. "clamp(-2 n-1 , 2 n-1 -1, xint)" indicates that if xint is -2 n-1 or less, it is set to -2 n-1 , and if xint is 2 n-1 -1 or more, it is set to 2 n-1 -1.
For example, when the bit width n is 8, the calculation unit 130 converts an input value in a 32-bit floating-point format into an 8-bit fixed-point format.

図3は、本実施形態に係る演算装置が処理する浮動小数点の形式の入力値の一例を説明するための図である。
図3に示すように、浮動小数点形式の入力値200は、符号ビット210、指数部220および仮数部230を含む。浮動小数点は、1つの数を、小数点部分を示す部分と小数点位置を示す部分とに分けて表現する表記法である。仮数部230は、小数点部分を示す部分であり、指数部220は小数点位置を示す部分である。符号ビット210は、入力値200の符号を決定する部分である。
FIG. 3 is a diagram for explaining an example of an input value in a floating-point format processed by the arithmetic device according to the present embodiment.
3, an input value 200 in floating-point format includes a sign bit 210, an exponent part 220, and a mantissa part 230. Floating-point is a notation method that expresses a number by dividing it into a part indicating a decimal point and a part indicating the decimal point position. The mantissa part 230 is the part indicating the decimal point, and the exponent part 220 is the part indicating the decimal point position. The sign bit 210 is the part that determines the sign of the input value 200.

図4は、本実施形態に係る演算装置が処理する固定小数点の形式の入力値の一例を説明するための図である。
図4に示すように、固定小数点形式の入力値205は、符号ビット215、整数部225、小数部235および小数点245を含む。固定小数点は、小数点を使用して固定された桁数の小数を示す表記法を意味する。符号ビット215は入力値205の符号を決定し、整数部225は入力値205の整数を示す部分に対応し、小数部235は入力値205の小数を示す部分に対応する。小数点245は、入力値205の整数部225および小数部235を区分する基準になる点を示す。
FIG. 4 is a diagram for explaining an example of an input value in a fixed-point format processed by the arithmetic device according to the present embodiment.
4, the input value 205 in the fixed-point format includes a sign bit 215, an integer part 225, a fractional part 235, and a decimal point 245. The fixed-point format refers to a notation method that uses a decimal point to indicate a decimal number with a fixed number of digits. The sign bit 215 determines the sign of the input value 205, the integer part 225 corresponds to the part of the input value 205 that indicates an integer, and the fractional part 235 corresponds to the part of the input value 205 that indicates a decimal. The decimal point 245 indicates a reference point that divides the integer part 225 and the fractional part 235 of the input value 205.

演算部130は、取得部125が取得した入力層と中間層と出力層との各々の入力値の小数点のシフト量を特定する情報と、パラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とを取得する。
演算部130は、取得した入力層と中間層と出力層との各々の入力値の小数点のシフト量を特定する情報と、パラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とに基づいて、入力値に対する学習モデル152の出力値を演算する。
The calculation unit 130 acquires information specifying the amount of decimal point shift of each of the input values of the input layer, intermediate layer, and output layer acquired by the acquisition unit 125, information specifying the amount of decimal point shift of the parameters, and information specifying the amount of decimal point shift of each of the outputs of the input layer, intermediate layer, and output layer.
The calculation unit 130 calculates an output value of the learning model 152 for an input value based on information specifying the amount of decimal point shift of each of the acquired input values of the input layer, intermediate layer, and output layer, information specifying the amount of decimal point shift of the parameters, and information specifying the amount of decimal point shift of each of the outputs of the input layer, intermediate layer, and output layer.

図5は、本実施形態に係る演算装置が実行する演算の一例を説明するための図である。図5は、演算部130が実行するMAC(multiply-and-accumulate)演算を示す。
演算部130は、乗算器10と加算器20と加算器30とを備え、積和演算を行う。演算部130は、入力値inとパラメータの小数点のシフト量を特定する情報とを取得する。ここで、入力値inは、入力値の小数点のシフト量isfを特定する情報に基づいて、固定小数点の形式に変換されたものである。
演算部130は、パラメータの小数点のシフト量を特定する情報に基づいて、ウエイトWEの小数点をシフトさせる。
演算部130において、乗算器10は、入力値inと小数点をシフトさせたウエイトWEとを乗算する。加算器20は、入力値inと小数点をシフトさせたウエイトWEとを乗算した結果とを加算する。加算器30は、加算器20の出力値OUと出力の小数点のシフト量osfとに基づいて、出力値OUの小数点をシフトさせることによって、最終出力を導出する。具体的には、加算器30は、出力値OUに0.5を加算する。出力値OUの小数点をシフトさせることによって、出力値OUの精度を向上させることができる。
5 is a diagram for explaining an example of a calculation executed by the calculation device according to the present embodiment. FIG. 5 shows a MAC (multiply-and-accumulate) calculation executed by the calculation unit 130.
The calculation unit 130 includes a multiplier 10, an adder 20, and an adder 30, and performs a product-sum calculation. The calculation unit 130 acquires an input value in and information specifying the amount of shift of the decimal point of the parameter. Here, the input value in is converted into a fixed-point format based on the information specifying the amount of shift isf of the decimal point of the input value.
The calculation section 130 shifts the decimal point of the weight WE based on information specifying the amount of shift of the decimal point of the parameter.
In the calculation unit 130, the multiplier 10 multiplies the input value in by a weight WE with a shifted decimal point. The adder 20 adds the result of multiplying the input value in by the weight WE with a shifted decimal point. The adder 30 derives the final output by shifting the decimal point of the output value OU based on the output value OU of the adder 20 and the shift amount osf of the decimal point of the output. Specifically, the adder 30 adds 0.5 to the output value OU. By shifting the decimal point of the output value OU, the accuracy of the output value OU can be improved.

ここで、入力値の小数点のシフト量を特定する情報と、パラメータの小数点のシフト量の導出する処理について説明する。
入力値の小数点のシフト量を特定する情報と、パラメータの小数点のシフト量との導出は、端末装置によって実行される。
端末装置は、記憶している学習モデルから入力層を取得し、取得した入力層に含まれるウエイトとバイアスとに基づいて、入力層のウエイトの小数点のシフト量とバイアスの小数点のシフト量とを導出する。端末装置は、導出した入力層のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを記憶する。
端末装置は、ウエイトとバイアスとを固定小数点の形式に変換する。端末装置は、固定小数点の形式に変換したウエイトとバイアスとを含む入力層を新たに作成する。端末装置は、記憶している学習モデルの入力層を、新たに作成した入力層に交換する。
Here, information for specifying the amount of shift of the decimal point of the input value and a process for deriving the amount of shift of the decimal point of the parameter will be described.
The derivation of the information specifying the amount of shift of the decimal point of the input value and the amount of shift of the decimal point of the parameter is performed by the terminal device.
The terminal device acquires an input layer from the stored learning model, and derives the amount of shift of the decimal point of the weights of the input layer and the amount of shift of the decimal point of the bias based on the weights and biases included in the acquired input layer. The terminal device stores information specifying the amount of shift of the decimal point of the weights of the derived input layer and information specifying the amount of shift of the decimal point of the bias.
The terminal device converts the weights and biases into a fixed-point format. The terminal device creates a new input layer including the weights and biases converted into the fixed-point format. The terminal device replaces the input layer of the stored learning model with the newly created input layer.

端末装置は、記憶している学習モデルから中間層を取得し、取得した中間層に含まれるウエイトとバイアスとに基づいて、中間層のウエイトの小数点のシフト量とバイアスの小数点のシフト量とを導出する。端末装置は、導出した中間層のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを記憶する。
端末装置は、ウエイトとバイアスとを固定小数点の形式に変換する。端末装置は、固定小数点の形式に変換したウエイトとバイアスとを含む中間層を新たに作成する。端末装置は、記憶している学習モデルの中間層を、新たに作成した中間層に交換する。
The terminal device acquires an intermediate layer from the stored learning model, and derives the amount of shift of the decimal point of the weights of the intermediate layer and the amount of shift of the decimal point of the bias based on the weights and biases included in the acquired intermediate layer. The terminal device stores information specifying the amount of shift of the decimal point of the weights of the intermediate layer and information specifying the amount of shift of the decimal point of the bias.
The terminal device converts the weights and biases into a fixed-point format. The terminal device creates a new intermediate layer including the weights and biases converted into the fixed-point format. The terminal device replaces the intermediate layer of the stored learning model with the newly created intermediate layer.

端末装置は、記憶している学習モデルから出力層を取得し、取得した出力層に含まれるウエイトとバイアスとに基づいて、出力層のウエイトの小数点のシフト量とバイアスの小数点のシフト量とを導出する。端末装置は、導出した出力層のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを記憶する。
端末装置は、ウエイトとバイアスとを固定小数点の形式に変換する。端末装置は、固定小数点の形式に変換したウエイトとバイアスとを含む出力層を新たに作成する。端末装置は、記憶している学習モデルの出力層を、新たに作成した出力層に交換する。以上で、量子化した学習モデルが完成する。
The terminal device acquires an output layer from the stored learning model, and derives the amount of shift of the decimal point of the weights of the output layer and the amount of shift of the decimal point of the bias based on the weights and biases included in the acquired output layer. The terminal device stores information specifying the amount of shift of the decimal point of the weights of the output layer and information specifying the amount of shift of the decimal point of the bias derived.
The terminal device converts the weights and biases into a fixed-point format. The terminal device creates a new output layer including the weights and biases converted into the fixed-point format. The terminal device replaces the output layer of the stored learning model with the newly created output layer. This completes the quantized learning model.

量子化した学習モデルに含まれるウエイトとバイアスとは、浮動小数点の形式から固定小数点の形式へ変換されている。量子化した学習モデルを使用することによって、積和演算などを固定小数点の形式で実行できる。このため、エッジデバイスやAIチップでそのまま実行できる。
ただし、このままでは、学習モデルの演算結果の精度が低下する。この学習モデルの演算結果の精度の低下は、演算精度の減少だけが原因ではない。浮動小数点の形式の学習モデルでは、出力部分で(式1)の演算を行っている。
しかし、量子化された学習モデルの出力部分では(式1)と同等の処理をしてない。そのため、すべての層において、入力値、ウエイト、出力のシフト量から、整数でも実行できるようにすることによって、量子化された学習モデルの各層において、出力OUに、出力の小数点のシフト量を適用する。このように構成することによって、演算結果の精度の低下を防止できる。
The weights and biases included in the quantized learning model are converted from floating-point format to fixed-point format. By using the quantized learning model, multiplication and accumulation operations can be performed in fixed-point format. This allows them to be executed directly on edge devices and AI chips.
However, if this continues, the accuracy of the calculation results of the learning model will decrease. The decrease in accuracy of the calculation results of this learning model is not only caused by the decrease in calculation accuracy. In the learning model in the floating-point format, the calculation of (Equation 1) is performed in the output part.
However, the output part of the quantized learning model does not perform the same processing as (Equation 1). Therefore, in all layers, the input value, weight, and output shift amount are made executable even with integers, and the output decimal point shift amount is applied to the output OU in each layer of the quantized learning model. By configuring in this way, it is possible to prevent a decrease in the accuracy of the calculation result.

端末装置は、入力された入力値を特定する情報を取得し、取得した入力値を特定する情報を受け付ける。端末装置は、記憶している入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報を取得する。端末装置は、取得した入力値を特定する情報に基づいて、入力値を固定小数点の形式に変換する。
端末装置は、取得した入力層のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報に基づいて、固定小数点の形式に変換した入力値に対する量子化した学習モデルの入力層の出力を導出する。端末装置は、導出した入力層の出力に基づいて、入力層の出力の小数点のシフト量を導出する。このように構成することによって、仮に入力層の出力が量子化されていない場合でも、量子化を行うことができる。端末装置は、導出した入力層の出力の小数点のシフト量、換言すれば中間層の入力値の小数点のシフト量を特定する情報を記憶する。
The terminal device acquires information for identifying an input value that has been input, and accepts the information for identifying the acquired input value. The terminal device acquires information for identifying the amount of shift of the decimal point of each parameter of the stored input layer, intermediate layer, and output layer. The terminal device converts the input value into a fixed-point format based on the information for identifying the acquired input value.
The terminal device derives the output of the input layer of the quantized learning model for the input value converted to fixed-point format based on the acquired information specifying the shift amount of the decimal point of the weight of the input layer and the information specifying the shift amount of the decimal point of the bias. The terminal device derives the shift amount of the decimal point of the output of the input layer based on the derived output of the input layer. By configuring in this way, quantization can be performed even if the output of the input layer is not quantized. The terminal device stores information specifying the shift amount of the decimal point of the derived output of the input layer, in other words, the shift amount of the decimal point of the input value of the intermediate layer.

端末装置は、取得した中間層のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報に基づいて、量子化した学習モデルの入力層の出力値に対する量子化した学習モデルの中間層の出力を導出する。端末装置は、導出した中間層の出力に基づいて、中間層の出力の小数点のシフト量を導出する。
このように構成することによって、仮に中間層の出力が量子化されていない場合でも、量子化を行うことができる。端末装置は、導出した中間層の出力の小数点のシフト量、換言すれば出力層の入力値の小数点のシフト量を特定する情報を記憶する。
The terminal device derives an output of the intermediate layer of the quantized learning model for the output value of the input layer of the quantized learning model based on the acquired information specifying the shift amount of the decimal point of the intermediate layer weight and the information specifying the shift amount of the decimal point of the bias. The terminal device derives the shift amount of the decimal point of the intermediate layer output based on the derived output of the intermediate layer.
By configuring in this way, even if the output of the intermediate layer is not quantized, quantization can be performed. The terminal device stores information specifying the amount of shift of the decimal point of the derived output of the intermediate layer, in other words, the amount of shift of the decimal point of the input value of the output layer.

端末装置は、取得した出力層のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報に基づいて、量子化した学習モデルの中間層の出力値に対する量子化した学習モデルの出力層の出力を導出する。
端末装置は、導出した出力層の出力に基づいて、分散などの演算を行うことによって、出力層の出力の小数点のシフト量を導出する。このように構成することによって、仮に出力層の出力が量子化されていない場合でも、量子化を行うことができる。端末装置は、導出した出力層の出力の小数点のシフト量を特定する情報を記憶する。
以下、端末装置300について説明する。
図6は、本実施形態に係る端末装置のパラメータの小数点のシフト量の導出を説明するための図である。
The terminal device derives the output of the output layer of the quantized learning model for the output value of the intermediate layer of the quantized learning model based on the information specifying the amount of shift of the decimal point of the weight of the output layer and the information specifying the amount of shift of the decimal point of the bias acquired.
The terminal device derives the amount of shift of the decimal point of the output of the output layer by performing a calculation such as variance based on the derived output of the output layer. By configuring in this way, even if the output of the output layer is not quantized, quantization can be performed. The terminal device stores information that specifies the amount of shift of the decimal point of the derived output of the output layer.
The terminal device 300 will now be described.
FIG. 6 is a diagram for explaining derivation of the decimal point shift amount of the parameter of the terminal device according to this embodiment.

[端末装置300]
端末装置300は、パーソナルコンピュータ、サーバー、タブレットコンピュータ又は産業用コンピュータ等の装置によって実現される。端末装置300は、例えば、入力部310と、受付部320と、取得部325と、演算部330と、出力部340と、記憶部350とを備える。
[Terminal Device 300]
The terminal device 300 is realized by a device such as a personal computer, a server, a tablet computer, an industrial computer, etc. The terminal device 300 includes, for example, an input unit 310, a reception unit 320, an acquisition unit 325, a calculation unit 330, an output unit 340, and a storage unit 350.

記憶部350は、HDDやフラッシュメモリ、RAM、ROMなどにより実現される。記憶部350は、学習モデル352とシフト量情報354とが記憶される。
学習モデル352の一例は、ディープニューラルネットワーク形式の学習済の学習モデルである。以下、学習モデル352が、ディープニューラルネットワーク形式の学習済の学習モデルである場合について説明を続ける。
The storage unit 350 is realized by a HDD, a flash memory, a RAM, a ROM, etc. The storage unit 350 stores a learning model 352 and shift amount information 354.
An example of the learning model 352 is a trained learning model in the form of a deep neural network. Hereinafter, the case where the learning model 352 is a trained learning model in the form of a deep neural network will be described.

図7は、本実施形態に係る端末装置が有する学習モデルの一例を示す図である。
学習モデル352は、入力層351-1と、中間層351-2と、出力層351-3とを備える。入力層351-1は一または複数のユニットを有し、中間層351-2は一または複数のユニットを有し、出力層351-3は一または複数のユニットを有する。
入力層351-1に含まれる一または複数のユニットの各々は、中間層351-2に含まれる一または複数のユニットの各々と、一または複数のリンクによって接続される。中間層351-2に含まれる一または複数のユニットの各々は、出力層351-3に含まれる一または複数のユニットの各々と、一または複数のリンクによって接続される。
FIG. 7 is a diagram showing an example of a learning model possessed by a terminal device according to this embodiment.
The learning model 352 includes an input layer 351-1, an intermediate layer 351-2, and an output layer 351-3. The input layer 351-1 has one or more units, the intermediate layer 351-2 has one or more units, and the output layer 351-3 has one or more units.
Each of one or more units included in the input layer 351-1 is connected to each of one or more units included in the hidden layer 351-2 by one or more links. Each of one or more units included in the hidden layer 351-2 is connected to each of one or more units included in the output layer 351-3 by one or more links.

一または複数のユニットの各々は、一または複数の他のユニットが出力した情報を取得し、取得した情報を処理する。一または複数のユニットの各々は、情報を処理した結果を出力する。具体的には、一または複数のユニットの各々は、一または複数の入力値を取得する。一または複数のユニットの各々は、取得した一または複数の入力値とパラメータとに基づいて、出力を導出する。ここで、パラメータには、ウエイトとバイアスとが含まれる。一または複数のユニットの各々は、一または複数の入力値と一または複数のウエイトとをそれぞれ乗算した結果の和とバイアスとを加算する。 Each of the one or more units acquires information output by one or more other units and processes the acquired information. Each of the one or more units outputs the result of processing the information. Specifically, each of the one or more units acquires one or more input values. Each of the one or more units derives an output based on the acquired one or more input values and parameters. Here, the parameters include weights and biases. Each of the one or more units adds the sum of the results of multiplying the one or more input values by the one or more weights and the bias.

演算部330は、記憶部350の学習モデル352から入力層351-1を取得する(1)。演算部330は、取得した入力層351-1に含まれるウエイトとバイアスとに基づいて、分散などの演算を行うことによって、入力層351-1のウエイトの小数点のシフト量とバイアスの小数点のシフト量とを導出する。演算部330は、導出した入力層351-1のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを記憶部350のシフト量情報354に記憶させる。
演算部330は、ウエイトとバイアスとを固定小数点の形式に変換する。演算部330は、固定小数点の形式に変換したウエイトとバイアスとを含む入力層351a-1を作成する(2)。演算部330は、記憶部350の学習モデル352の入力層351-1を、作成した入力層351a-1に交換する(3)。
The calculation unit 330 acquires the input layer 351-1 from the learning model 352 in the storage unit 350 (1). The calculation unit 330 derives the amount of shift of the decimal point of the weights and the amount of shift of the decimal point of the bias of the input layer 351-1 by performing calculations such as variance based on the weights and biases included in the acquired input layer 351-1. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the weights and the amount of shift of the decimal point of the bias of the derived input layer 351-1 in the shift amount information 354 of the storage unit 350.
The calculation unit 330 converts the weights and biases into a fixed-point format. The calculation unit 330 creates an input layer 351a-1 including the weights and biases converted into the fixed-point format (2). The calculation unit 330 replaces the input layer 351-1 of the learning model 352 in the storage unit 350 with the created input layer 351a-1 (3).

演算部330は、中間層351-2を取得する。演算部330は、取得した中間層351-2に含まれるウエイトとバイアスとに基づいて、分散などの演算を行うことによって、中間層351-2のウエイトの小数点のシフト量とバイアスの小数点のシフト量とを導出する。演算部330は、導出した中間層351-2のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを、記憶部350のシフト量情報354に記憶させる。
演算部330は、ウエイトとバイアスとを固定小数点の形式に変換する。演算部130は、固定小数点の形式に変換したウエイトとバイアスとを含む中間層351a-2を作成する。演算部330は、学習モデル352の中間層351-2を、作成した中間層351a-2に交換する。
The calculation unit 330 acquires the intermediate layer 351-2. The calculation unit 330 derives the amount of shift of the decimal point of the weights and the amount of shift of the decimal point of the bias of the intermediate layer 351-2 by performing calculations such as variance based on the weights and biases included in the acquired intermediate layer 351-2. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the weights and the amount of shift of the decimal point of the bias of the derived intermediate layer 351-2 in the shift amount information 354 of the storage unit 350.
The calculation unit 330 converts the weights and biases into a fixed-point format. The calculation unit 130 creates an intermediate layer 351a-2 that includes the weights and biases converted into the fixed-point format. The calculation unit 330 replaces the intermediate layer 351-2 of the learning model 352 with the created intermediate layer 351a-2.

演算部330は、出力層351-3を取得する。演算部330は、取得した出力層351-3に含まれるウエイトとバイアスとに基づいて、分散などの演算を行うことによって、出力層351-3のウエイトの小数点のシフト量とバイアスの小数点のシフト量とを導出する。
演算部330は、導出した出力層351-3のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを、記憶部350のシフト量情報354に記憶させる。
演算部330は、ウエイトとバイアスとを固定小数点の形式に変換する。演算部330は、固定小数点の形式に変換したウエイトとバイアスとを含む出力層351a-3を作成する。演算部330は、学習モデル352の出力層351-3を、作成した出力層351a-3に交換する(4)。
前述した処理を行うことによって、演算部330は、学習モデル352から、量子化した学習モデル352aを作成する。
演算部330は、入力層351-1のウエイトの小数点のシフト量とバイアスの小数点のシフト量と、中間層351-2のウエイトの小数点のシフト量とバイアスの小数点のシフト量と、出力層351-3のウエイトの小数点のシフト量wsfとバイアスの小数点のシフト量とを導出できる。
The calculation unit 330 acquires the output layer 351-3. The calculation unit 330 performs calculations such as variance based on the weights and biases included in the acquired output layer 351-3 to derive the amount of shift of the decimal point of the weights and the amount of shift of the decimal point of the biases of the output layer 351-3.
The calculation unit 330 stores, in the shift amount information 354 of the storage unit 350, information specifying the shift amount of the decimal point of the weights of the derived output layer 351-3 and information specifying the shift amount of the decimal point of the biases.
The calculation unit 330 converts the weights and biases into a fixed-point format. The calculation unit 330 creates an output layer 351a-3 that includes the weights and biases converted into the fixed-point format. The calculation unit 330 replaces the output layer 351-3 of the learning model 352 with the created output layer 351a-3 (4).
By performing the above-described processing, the calculation unit 330 creates a quantized learning model 352 a from the learning model 352 .
The calculation unit 330 can derive the weight decimal point shift amount and bias decimal point shift amount of the input layer 351-1, the weight decimal point shift amount and bias decimal point shift amount of the intermediate layer 351-2, and the weight decimal point shift amount wsf and bias decimal point shift amount of the output layer 351-3.

入力部310は、入力デバイスを備える。例えば、この入力デバイスには、キーボード等の文字情報を入力するデバイス、マウス、タッチパネル等のポインティングデバイス、釦、ダイヤル、ジョイスティック、タッチセンサ、タッチパッド等が含まれる。入力部310に入力値を特定する情報が入力される。入力部310は、入力された入力値を特定する情報を取得する。入力値の一例は、32ビットの浮動小数点の形式の数である。以下、一例として、入力値が32ビットの浮動小数点の形式の数である場合について説明を続ける。 The input unit 310 includes an input device. For example, the input device includes a device for inputting character information such as a keyboard, a pointing device such as a mouse or a touch panel, a button, a dial, a joystick, a touch sensor, a touch pad, etc. Information specifying an input value is input to the input unit 310. The input unit 310 acquires information specifying the input value that has been input. An example of an input value is a number in a 32-bit floating-point format. Below, as an example, the explanation will continue for a case where the input value is a number in a 32-bit floating-point format.

受付部320は、入力部310に入力された入力値を特定する情報を取得し、取得した入力値を特定する情報を受け付ける。受付部320が受け付けた入力値を特定する情報は、演算部330へ出力される。 The reception unit 320 acquires information that identifies the input value input to the input unit 310, and accepts the information that identifies the acquired input value. The information that identifies the input value accepted by the reception unit 320 is output to the calculation unit 330.

取得部325は、受付部320が入力値を特定する情報を受け付けた場合に、記憶部350のシフト量情報354に記憶されている入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報を取得する。取得部325が取得した入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報は、演算部330へ出力される。 When the receiving unit 320 receives information specifying an input value, the acquiring unit 325 acquires information specifying the shift amount of the decimal point of each parameter of the input layer, intermediate layer, and output layer stored in the shift amount information 354 of the storage unit 350. The information specifying the shift amount of the decimal point of each parameter of the input layer, intermediate layer, and output layer acquired by the acquiring unit 325 is output to the calculation unit 330.

演算部330は、受付部320が受け付けた入力値を特定する情報を取得する。演算部330は、取得した入力値を特定する情報に基づいて、入力値を固定小数点の形式に変換する。
演算部330は、取得部325から入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報を取得する。演算部330は、取得した入力層351-1のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報に基づいて、固定小数点の形式に変換した入力値に対する量子化した学習モデル352aの入力層351a-1の出力を導出する。
演算部330は、導出した入力層351a-1の出力に基づいて、分散などの演算を行うことによって、入力層351a-1の出力の小数点のシフト量を導出する。このように構成することによって、仮に入力層351a-1の出力が量子化されていない場合でも、量子化を行うことができる。演算部330は、導出した入力層351a-1の出力の小数点のシフト量、換言すれば中間層351a-2の入力の小数点のシフト量を特定する情報を記憶部350のシフト量情報354に記憶させる。
The calculation unit 330 acquires information specifying the input value accepted by the acceptance unit 320. The calculation unit 330 converts the input value into a fixed-point format based on the acquired information specifying the input value.
The calculation unit 330 acquires information specifying the amount of decimal point shift of each parameter of the input layer, the intermediate layer, and the output layer from the acquisition unit 325. The calculation unit 330 derives an output of the input layer 351a-1 of the quantized learning model 352a for the input value converted to the fixed-point format, based on the acquired information specifying the amount of decimal point shift of the weight of the input layer 351-1 and the information specifying the amount of decimal point shift of the bias.
The calculation unit 330 derives the amount of shift of the decimal point of the output of the input layer 351a-1 by performing calculations such as variance based on the derived output of the input layer 351a-1. With this configuration, even if the output of the input layer 351a-1 is not quantized, quantization can be performed. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the derived output of the input layer 351a-1, in other words, the amount of shift of the decimal point of the input of the intermediate layer 351a-2, in the shift amount information 354 of the storage unit 350.

演算部330は、取得した中間層351a-2のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報に基づいて、学習モデル352aの入力層351a-1の出力値に対する量子化した学習モデル352aの中間層351a-2の出力を導出する。
演算部330は、導出した中間層351a-2の出力に基づいて、分散などの演算を行うことによって、中間層351a-2の出力の小数点のシフト量を導出する。このように構成することによって、仮に中間層351a-2の出力が量子化されていない場合でも、量子化を行うことができる。演算部330は、導出した中間層351a-2の出力の小数点のシフト量、換言すれば出力層351a-3の入力の小数点のシフト量を特定する情報を記憶部350のシフト量情報354に記憶させる。
演算部330は、取得した出力層351a-3のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報に基づいて、学習モデル352aの中間層351a-2の出力値に対する量子化した学習モデル352aの出力層351a-3の出力を導出する。
The calculation unit 330 derives the output of the quantized intermediate layer 351a-2 of the learning model 352a corresponding to the output value of the input layer 351a-1 of the learning model 352a, based on the acquired information specifying the amount of decimal point shift of the weight of the intermediate layer 351a-2 and information specifying the amount of decimal point shift of the bias.
The calculation unit 330 derives the amount of shift of the decimal point of the output of the intermediate layer 351a-2 by performing calculations such as variance based on the derived output of the intermediate layer 351a-2. With this configuration, even if the output of the intermediate layer 351a-2 is not quantized, quantization can be performed. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the derived output of the intermediate layer 351a-2, in other words, the amount of shift of the decimal point of the input of the output layer 351a-3, in the shift amount information 354 of the storage unit 350.
The calculation unit 330 derives the output of the quantized output layer 351a-3 of the learning model 352a for the output value of the intermediate layer 351a-2 of the learning model 352a based on the information specifying the amount of decimal point shift of the weight of the acquired output layer 351a-3 and the information specifying the amount of decimal point shift of the bias.

演算部330は、導出した出力層351a-3の出力に基づいて、分散などの演算を行うことによって、出力層351a-3の出力の小数点のシフト量を導出する。このように構成することによって、仮に出力層351a-3の出力が量子化されていない場合でも、量子化を行うことができる。演算部330は、導出した出力層351a-3の出力の小数点のシフト量を特定する情報を記憶部350のシフト量情報354に記憶させる。
前述した処理を行うことによって、演算部330は、入力層351a-1の出力の小数点のシフト量、換言すれば中間層351a-2の入力の小数点のシフト量と、中間層351a-2の出力の小数点のシフト量、換言すれば出力層351a-3の入力の小数点のシフト量と、出力層351a-3の出力の小数点のシフト量とを導出する。
端末装置300によって作成された量子化した学習モデル352aが、演算装置100において学習モデル152として使用される。端末装置300によって作成されたシフト量情報354が、演算装置100においてシフト量情報154として使用される。
The calculation unit 330 derives the amount of shift of the decimal point of the output of the output layer 351a-3 by performing calculations such as variance based on the derived output of the output layer 351a-3. By configuring in this way, even if the output of the output layer 351a-3 is not quantized, quantization can be performed. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the derived output of the output layer 351a-3 in the shift amount information 354 of the storage unit 350.
By performing the above-mentioned processing, the calculation unit 330 derives the amount of shift of the decimal point of the output of the input layer 351a-1, in other words, the amount of shift of the decimal point of the input of the intermediate layer 351a-2, and the amount of shift of the decimal point of the output of the intermediate layer 351a-2, in other words, the amount of shift of the decimal point of the input of the output layer 351a-3, and the amount of shift of the decimal point of the output of the output layer 351a-3.
The quantized learning model 352a created by the terminal device 300 is used as the learning model 152 in the arithmetic device 100. The shift amount information 354 created by the terminal device 300 is used as the shift amount information 154 in the arithmetic device 100.

(演算装置100の動作)
図8は、本実施形態に係る演算装置の動作の一例を示すフローチャートである。
(ステップS1-1)
演算装置100において、受付部120は、入力部110に入力された入力値を特定する情報を取得し、取得した入力値を特定する情報を受け付ける。
(ステップS2-1)
演算装置100において、取得部125は、記憶部150のシフト量情報154に記憶されている入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とを取得する。入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報には、入力層の入力値の小数点のシフト量を特定する情報と、中間層の入力値の小数点のシフト量を特定する情報と、出力層の入力値の小数点のシフト量を特定する情報とが含まれる。
(Operation of the arithmetic device 100)
FIG. 8 is a flowchart showing an example of the operation of the arithmetic device according to the present embodiment.
(Step S1-1)
In the arithmetic device 100, the receiving unit 120 obtains information specifying an input value input to the input unit 110, and receives the obtained information specifying the input value.
(Step S2-1)
In the arithmetic device 100, the acquiring unit 125 acquires information specifying the amount of shift of the decimal point of each parameter of the input layer, the intermediate layer, and the output layer, and information specifying the amount of shift of the decimal point of each output of the input layer, the intermediate layer, and the output layer, which are stored in the shift amount information 154 of the storage unit 150. The information specifying the amount of shift of the decimal point of each output of the input layer, the intermediate layer, and the output layer includes information specifying the amount of shift of the decimal point of an input value of the input layer, information specifying the amount of shift of the decimal point of an input value of the intermediate layer, and information specifying the amount of shift of the decimal point of an input value of the output layer.

(ステップS3-1)
演算装置100において、演算部130は、受付部120が受け付けた入力値を特定する情報を取得する。演算部130は、取得した入力値を特定する情報と、入力値の小数点のシフト量を特定する情報とに基づいて、入力値を固定小数点の形式へ変換する。
(ステップS4-1)
演算装置100において、演算部130は、取得部125が取得した入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とを取得する。演算部130は、取得した入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とに基づいて、入力値に対する出力値OUを演算する。
(ステップS5-1)
演算装置100において、演算部130は、出力値OUと出力の小数点のシフト量osfとに基づいて、出力値OUの小数点をシフトさせることによって、最終出力を導出する。
(Step S3-1)
In the arithmetic device 100, the arithmetic unit 130 acquires information that specifies an input value accepted by the acceptance unit 120. The arithmetic unit 130 converts the input value into a fixed-point format based on the acquired information that specifies the input value and information that specifies the amount of shift of the decimal point of the input value.
(Step S4-1)
In the calculation device 100, the calculation unit 130 acquires information specifying the amount of decimal point shift of each of the parameters of the input layer, the intermediate layer, and the output layer, and information specifying the amount of decimal point shift of each of the outputs of the input layer, the intermediate layer, and the output layer acquired by the acquisition unit 125. The calculation unit 130 calculates an output value OU for an input value, based on the acquired information specifying the amount of decimal point shift of each of the parameters of the input layer, the intermediate layer, and the output layer, and information specifying the amount of decimal point shift of each of the outputs of the input layer, the intermediate layer, and the output layer.
(Step S5-1)
In the calculation device 100, the calculation section 130 derives the final output by shifting the decimal point of the output value OU based on the output value OU and the shift amount osf of the decimal point of the output.

(端末装置300の動作)
図9は、本実施形態に係る端末装置の動作の一例を示すフローチャートである。
(ステップS1-2)
端末装置300において、演算部330は、記憶部350の学習モデル352から入力層351-1を取得する。演算部330は、取得した入力層351-1に含まれるウエイトとバイアスとに基づいて、入力層351-1のウエイトの小数点のシフト量とバイアスの小数点のシフト量とを導出する。
演算部330は、導出した入力層351-1のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを記憶部350のシフト量情報354に記憶させる。
(ステップS2-2)
端末装置300において、演算部330は、入力層351-1のウエイトとバイアスとを固定小数点の形式に変換する。
(Operation of Terminal Device 300)
FIG. 9 is a flowchart showing an example of the operation of the terminal device according to this embodiment.
(Step S1-2)
In the terminal device 300, the calculation unit 330 acquires the input layer 351-1 from the learning model 352 in the storage unit 350. The calculation unit 330 derives the amount of decimal point shift of the weights and the amount of decimal point shift of the biases of the input layer 351-1, based on the weights and biases included in the acquired input layer 351-1.
The calculation unit 330 stores, in the shift amount information 354 of the storage unit 350, information specifying the shift amount of the decimal point of the weights of the derived input layer 351-1 and information specifying the shift amount of the decimal point of the biases.
(Step S2-2)
In the terminal device 300, the calculation unit 330 converts the weights and biases of the input layer 351-1 into a fixed-point format.

(ステップS3-2)
端末装置300において、演算部330は、固定小数点の形式に変換したウエイトとバイアスとを含む入力層351a-1を作成する。演算部330は、記憶部350の学習モデル352の入力層351-1を、作成した入力層351a-1に交換する。
(ステップS4-2)
端末装置300において、演算部330は、記憶部350の学習モデル352から中間層351-2を取得する。演算部330は、取得した中間層351-2に含まれるウエイトとバイアスとに基づいて、中間層351-2のウエイトの小数点のシフト量とバイアスの小数点のシフト量とを導出する。演算部330は、導出した中間層351-2のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを記憶部350のシフト量情報354に記憶させる。
(ステップS5-2)
端末装置300において、演算部330は、中間層351-2のウエイトとバイアスとを固定小数点の形式に変換する。
(Step S3-2)
In the terminal device 300, the calculation unit 330 creates an input layer 351a-1 including weights and biases converted into a fixed-point format. The calculation unit 330 replaces the input layer 351-1 of the learning model 352 in the storage unit 350 with the created input layer 351a-1.
(Step S4-2)
In the terminal device 300, the calculation unit 330 acquires the intermediate layer 351-2 from the learning model 352 in the storage unit 350. The calculation unit 330 derives the amount of shift of the decimal point of the weights and the amount of shift of the decimal point of the bias of the intermediate layer 351-2 based on the weights and biases included in the acquired intermediate layer 351-2. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the weights and the amount of shift of the decimal point of the bias of the derived intermediate layer 351-2 in the shift amount information 354 of the storage unit 350.
(Step S5-2)
In the terminal device 300, the calculation unit 330 converts the weights and biases of the hidden layer 351-2 into a fixed-point format.

(ステップS6-2)
端末装置300において、演算部130は、固定小数点の形式に変換したウエイトとバイアスとを含む中間層351a-2を作成する。演算部330は、学習モデル352の中間層351-2を、作成した中間層351a-2に交換する。
(ステップS7-2)
端末装置300において、演算部330は、記憶部350の学習モデル352から出力層351-3を取得する。演算部330は、取得した出力層351-3に含まれるウエイトとバイアスとに基づいて、出力層351-3のウエイトの小数点のシフト量を導出する。演算部330は、導出した出力層351-3のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とを記憶部350のシフト量情報354に記憶させる。
(Step S6-2)
In the terminal device 300, the calculation unit 130 creates an intermediate layer 351a-2 including weights and biases converted into a fixed-point format. The calculation unit 330 replaces the intermediate layer 351-2 of the learning model 352 with the created intermediate layer 351a-2.
(Step S7-2)
In the terminal device 300, the calculation unit 330 acquires the output layer 351-3 from the learning model 352 in the storage unit 350. The calculation unit 330 derives the amount of shift of the decimal point of the weights of the output layer 351-3 based on the weights and biases included in the acquired output layer 351-3. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the weights of the derived output layer 351-3 and information specifying the amount of shift of the decimal point of the bias in the shift amount information 354 of the storage unit 350.

(ステップS8-2)
端末装置300において、演算部330は、出力層351-3のウエイトとバイアスとを固定小数点の形式に変換する。
(ステップS9-2)
端末装置300において、演算部330は、固定小数点の形式に変換したウエイトとバイアスとを含む出力層351a-3を作成する。演算部330は、学習モデル352の出力層351-3を、作成した出力層351a-3に交換する。
(ステップS10-2)
端末装置300において、受付部320は、入力部310に入力された入力値を特定する情報を取得し、取得した入力値を特定する情報を受け付ける。
(Step S8-2)
In the terminal device 300, the calculation unit 330 converts the weights and biases of the output layer 351-3 into a fixed-point format.
(Step S9-2)
In the terminal device 300, the calculation unit 330 creates an output layer 351a-3 including weights and biases converted into a fixed-point format. The calculation unit 330 replaces the output layer 351-3 of the learning model 352 with the created output layer 351a-3.
(Step S10-2)
In the terminal device 300, the receiving unit 320 obtains information specifying an input value input to the input unit 310, and receives the obtained information specifying the input value.

(ステップS11-2)
端末装置300において、取得部325は、記憶部350のシフト量情報354に記憶されている入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報を取得する。
(ステップS12-2)
端末装置300において、演算部330は、受付部320が受け付けた入力値を特定する情報を取得する。演算部330は、取得した入力値を特定する情報と、入力値の小数点のシフト量を特定する情報とに基づいて、入力値を固定小数点の形式に変換する。
(ステップS13-2)
端末装置300において、演算部330は、取得部325から入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報を取得する。演算部330は、取得した入力層351-1のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とに基づいて、固定小数点の形式に変換した入力値に対する量子化した学習モデル352aの入力層351a-1の出力を導出する。
演算部330は、導出した入力層351a-1の出力に基づいて、入力層351a-1の出力の小数点のシフト量を導出する。演算部330は、導出した入力層351a-1の出力の小数点のシフト量、換言すれば中間層351a-2の入力値の小数点のシフト量を特定する情報を記憶部350のシフト量情報354に記憶させる。
(Step S11-2)
In the terminal device 300, the acquisition unit 325 acquires information that specifies the amount of shift of the decimal point of each parameter of the input layer, the intermediate layer, and the output layer, which is stored in the shift amount information 354 of the storage unit 350.
(Step S12-2)
In the terminal device 300, the calculation unit 330 acquires information specifying the input value accepted by the acceptance unit 320. The calculation unit 330 converts the input value into a fixed-point format based on the acquired information specifying the input value and information specifying the amount of shift of the decimal point of the input value.
(Step S13-2)
In the terminal device 300, the calculation unit 330 acquires information specifying the amount of decimal point shift of each parameter of the input layer, the intermediate layer, and the output layer from the acquisition unit 325. The calculation unit 330 derives an output of the input layer 351a-1 of the quantized learning model 352a for the input value converted to the fixed-point format, based on the acquired information specifying the amount of decimal point shift of the weight of the input layer 351-1 and the information specifying the amount of decimal point shift of the bias.
The calculation unit 330 derives the amount of shift of the decimal point of the output of the input layer 351a-1 based on the derived output of the input layer 351a-1. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the derived output of the input layer 351a-1, in other words, the amount of shift of the decimal point of the input value of the intermediate layer 351a-2, in shift amount information 354 of the storage unit 350.

(ステップS14-2)
端末装置300において、演算部330は、取得した中間層351a-2のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とに基づいて、学習モデル352aの入力層351a-1の出力値に対する量子化した学習モデル352aの中間層351a-2の出力を導出する。
演算部330は、導出した中間層351a-2の出力に基づいて、中間層351a-2の出力の小数点のシフト量を導出する。演算部330は、導出した中間層351a-2の出力の小数点のシフト量、換言すれば出力層351a-3の入力値の小数点のシフト量を特定する情報を記憶部350のシフト量情報354に記憶させる。
(ステップS15-2)
端末装置300において、演算部330は、取得した出力層351a-3のウエイトの小数点のシフト量を特定する情報とバイアスの小数点のシフト量を特定する情報とに基づいて、学習モデル352aの中間層351a-2の出力値に対する量子化した学習モデル352aの出力層351a-3の出力を導出する。
演算部330は、導出した出力層351a-3の出力に基づいて、分散などの演算を行うことによって、出力層351a-3の出力の小数点のシフト量を導出する。演算部330は、導出した出力層351a-3の出力の小数点のシフト量を特定する情報を記憶部350のシフト量情報354に記憶させる。
(Step S14-2)
In the terminal device 300, the calculation unit 330 derives the output of the quantized intermediate layer 351a-2 of the learning model 352a corresponding to the output value of the input layer 351a-1 of the learning model 352a, based on the acquired information specifying the amount of decimal point shift of the weight of the intermediate layer 351a-2 and information specifying the amount of decimal point shift of the bias.
The calculation unit 330 derives the amount of shift of the decimal point of the output of the intermediate layer 351a-2 based on the derived output of the intermediate layer 351a-2. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the derived output of the intermediate layer 351a-2, in other words, the amount of shift of the decimal point of the input value of the output layer 351a-3, in the shift amount information 354 of the storage unit 350.
(Step S15-2)
In the terminal device 300, the calculation unit 330 derives the output of the quantized output layer 351a-3 of the learning model 352a for the output value of the intermediate layer 351a-2 of the learning model 352a based on the information specifying the amount of decimal point shift of the weight of the acquired output layer 351a-3 and the information specifying the amount of decimal point shift of the bias.
The calculation unit 330 derives the amount of shift of the decimal point of the output of the output layer 351a-3 by performing calculations such as variance based on the derived output of the output layer 351a-3. The calculation unit 330 stores information specifying the amount of shift of the decimal point of the derived output of the output layer 351a-3 in the shift amount information 354 of the storage unit 350.

本実施形態に係る演算装置100の最終的な出力値の精度について説明する。
図10は、本実施形態に係る演算装置100の精度の一例を説明するための図である。図10は、入力値を固定小数点の形式へ変換するときの桁数(ビット幅)nを2から8とした場合の各々について、出力値OUの小数点をシフトさせたものを最終出力値とした場合と、出力値OUを最終出力値とした場合について、最終出力値の精度の一例を示す。
図10によれば、ビット幅が6桁までは、出力値OUの小数点をシフトさせたか否かにかかわらず、小数点第二位まで等しい精度が得られているのが分かる。ビット幅が5桁では、出力値OUの小数点をシフトさせない場合と小数点をシフトさせた場合とでは、小数点第二位に差が生じている。ビット幅が4桁以下では、小数点をシフトさせない場合は、出力値OUの小数点をシフトさせた場合と比較して、精度が大きく低下する。
The accuracy of the final output value of the arithmetic device 100 according to this embodiment will be described.
Fig. 10 is a diagram for explaining an example of the accuracy of the arithmetic device 100 according to this embodiment. Fig. 10 shows an example of the accuracy of the final output value when the number of digits (bit width) n when converting an input value into a fixed-point format is set to 2 to 8, and when the final output value is the output value OU with the decimal point shifted, and when the output value OU is set to the final output value.
10, it can be seen that, for bit widths up to six digits, the same accuracy is obtained up to the first decimal place regardless of whether the decimal point of the output value OU is shifted or not. For bit widths of five digits, there is a difference in the first decimal place between when the decimal point of the output value OU is not shifted and when it is shifted. For bit widths of four digits or less, when the decimal point is not shifted, the accuracy is significantly reduced compared to when the decimal point of the output value OU is shifted.

前述した実施形態では、学習モデルの一例として、ディープニューラルネットワーク形式の学習モデルについて説明したがこの例に限られない。例えば、学習モデルに、畳み込みニューラルネットワーク形式の学習モデルが使用されてもよい。積和演算が含まれる層を有する学習モデルが使用可能である。
前述した実施形態では、学習モデルの一例が、Pytonで記述されている場合について説明したが、この例に限られない。例えば、学習モデルの一例が、Pytorch、Tensorflowなどのライブラリーで記述されていてもよい。
前述した実施形態では、入力値の一例として、32ビットの浮動小数点の形式の数である場合について説明したが、この例に限られない。例えば、入力値として、16ビットの浮動小数点の形式の数などの32ビット以外の浮動小数点の形式の数を使用してもよい。
前述した実施形態において、学習モデル152と学習モデル352との各々は、複数の中間層を備えてもよい。複数の中間層を備える場合に、複数の中間層の各々について、ウエイトの小数点のシフト量とバイアスの小数点のシフト量と出力の小数点のシフト量(入力の小数点のシフト量)が導出される。
前述した実施形態において、演算装置100は、出力値OUと出力の小数点のシフト量osfとに基づいて、出力値OUの小数点をシフトさせるか否かを選択できるようにしてもよい。例えば、図10に示すように、ビット幅nが6から8では、出力値OUの小数点をシフトさせたものを最終出力値とした場合と、出力値OUを最終出力値とした場合との間で精度の差が小さいため、出力値OUの小数点をシフトさせる必要がないためである。このように構成することによって、出力値OUの小数点をシフトさせるハードウェアを削減できる。
In the above embodiment, a deep neural network type learning model has been described as an example of the learning model, but the present invention is not limited to this example. For example, a convolutional neural network type learning model may be used as the learning model. A learning model having a layer including a product-sum operation may be used.
In the above embodiment, an example of the learning model is described in Python, but this is not limited to this example. For example, an example of the learning model may be described in a library such as Pytorch or Tensorflow.
In the above embodiment, the input value is, for example, a 32-bit floating-point number, but the input value is not limited to this example. For example, the input value may be a floating-point number other than 32 bits, such as a 16-bit floating-point number.
In the above-described embodiment, each of the learning model 152 and the learning model 352 may include multiple hidden layers. When multiple hidden layers are included, the weight decimal point shift amount, bias decimal point shift amount, and output decimal point shift amount (input decimal point shift amount) are derived for each of the multiple hidden layers.
In the above-mentioned embodiment, the arithmetic device 100 may select whether or not to shift the decimal point of the output value OU based on the output value OU and the shift amount osf of the decimal point of the output. For example, as shown in Fig. 10, when the bit width n is 6 to 8, the difference in precision between the case where the decimal point of the output value OU is shifted and the case where the output value OU is the final output value is small, so there is no need to shift the decimal point of the output value OU. By configuring in this way, the hardware for shifting the decimal point of the output value OU can be reduced.

実施形態に係る演算装置によれば、演算装置100は、ニューラルネットワーク形式の学習モデル152のパラメータの小数点のシフト量を特定する情報を取得する取得部125と、取得部125が取得したパラメータの小数点のシフト量を特定する情報に基づいて、入力値に対する学習モデル152の出力値を演算する演算部130と、出力値と出力値の小数点のシフト量とに基づいて、出力値の小数点をシフトさせ、小数点をシフトさせた出力値を出力する出力部140とを備え、入力値は、固定小数点の形式である。
このように構成することによって、演算装置100は、学習モデル152のパラメータの小数点のシフト量を特定する情報に基づいて、固定小数点の形式の入力値に対する学習モデル152の出力値を演算し、出力値と出力値の小数点のシフト量とに基づいて、出力値の小数点をシフトさせ、小数点をシフトさせた出力値を出力する。
出力値と出力値の小数点のシフト量とに基づいて、出力値の小数点をシフトさせることができるため、入力値を固定小数点の形式に変換した場合に演算精度を向上できる。このため、ハードウェアに実装する前に正確な精度を求めることができる。ハードウェアと同等のエミュレーションができるため、ハードウェアのデバッグに使用できる。エミュレーションの段階で、桁あふれをチェックできる。通常使用されているディープニューラルネットワークフレームワークと併用して使用できる。
According to the computing device of the embodiment, the computing device 100 includes an acquisition unit 125 that acquires information specifying the amount of decimal point shift of the parameters of a neural network-type learning model 152, a computation unit 130 that calculates an output value of the learning model 152 for an input value based on the information specifying the amount of decimal point shift of the parameters acquired by the acquisition unit 125, and an output unit 140 that shifts the decimal point of the output value based on the output value and the amount of decimal point shift of the output value, and outputs the output value with the shifted decimal point, and the input value is in a fixed-point format.
By configuring in this manner, the calculation device 100 calculates the output value of the learning model 152 for an input value in fixed-point format based on information specifying the amount of decimal point shift of the parameters of the learning model 152, shifts the decimal point of the output value based on the output value and the amount of decimal point shift of the output value, and outputs the output value with the shifted decimal point.
Since the decimal point of the output value can be shifted based on the output value and the amount of shift of the decimal point of the output value, the calculation accuracy can be improved when the input value is converted to a fixed-point format. Therefore, accurate accuracy can be obtained before implementing it in hardware. Since it is possible to perform emulation equivalent to hardware, it can be used for debugging hardware. It is possible to check for overflow at the emulation stage. It can be used in conjunction with commonly used deep neural network frameworks.

また、パラメータには、複数の層の各々のパラメータが含まれる。このように構成することによって、演算装置100は、学習モデル152の複数の層の各々のパラメータに基づいて、入力値に対する学習モデル152の出力値を演算できるため、入力値を固定小数点の形式に変換した場合に、演算精度を向上できる。
また、パラメータには、ウエイトおよび出力が含まれる。このように構成することによって、演算装置100は、学習モデル152の複数のウエイトの各々の小数点のシフト量と複数の層の各々の出力の小数点のシフト量とを特定する情報に基づいて、入力値に対する学習モデル152の出力値を演算できるため、入力値を固定小数点の形式に変換した場合に、演算精度を向上できる。
また、パラメータには、バイアスがさらに含まれる。このように構成することによって、演算装置100は、学習モデル152の複数のバイアスの各々の小数点のシフト量を特定する情報にさらに基づいて、入力値に対する学習モデル152の出力値を演算できるため、入力値を固定小数点の形式に変換した場合に、演算精度を向上できる。
Moreover, the parameters include parameters for each of the multiple layers. With this configuration, the arithmetic device 100 can calculate an output value of the learning model 152 for an input value based on the parameters for each of the multiple layers of the learning model 152, and therefore, when the input value is converted into a fixed-point format, the arithmetic accuracy can be improved.
In addition, the parameters include weights and outputs. With this configuration, the calculation device 100 can calculate the output value of the learning model 152 for the input value based on information specifying the amount of decimal point shift of each of the multiple weights of the learning model 152 and the amount of decimal point shift of each of the multiple layers of the output, and therefore can improve the calculation accuracy when the input value is converted into a fixed-point format.
In addition, the parameters further include a bias. With this configuration, the calculation device 100 can calculate the output value of the learning model 152 for the input value based on information specifying the amount of shift of the decimal point of each of the multiple biases of the learning model 152, and therefore can improve the calculation accuracy when the input value is converted into a fixed-point format.

また、パラメータは、固定小数点の形式である。このように構成することによって、演算装置100は、量子化された学習モデル152のパラメータの小数点のシフト量を特定する情報に基づいて、固定小数点の形式の入力値に対する学習モデル152の出力値を演算し、出力値と出力値の小数点のシフト量とに基づいて、出力値の小数点をシフトさせ、小数点をシフトさせた出力値を出力できる。このため、ハードウェアに実装する前に正確な精度を求めることができる。ハードウェアと同等のエミュレーションができるため、ハードウェアのデバッグに使用できる。通常使用されているディープニューラルネットワークフレームワークと併用して使用できる。
また、学習モデルは、ディープニューラルネットワーク形式の学習済モデルに基づいて、パラメータを固定小数点の形式に変換することによって作成されたものである。このように構成することによって、学習済モデルから学習モデルを用意できる。
また、演算部130は、パラメータに基づいて、入力値に対して、MAC(multiply-accumulate)演算を行う。このように構成することによって、入力値に対してMAC演算を行うことによって、入力値に対する学習モデル152の出力値を演算できる。
Moreover, the parameters are in a fixed-point format. With this configuration, the arithmetic device 100 calculates the output value of the learning model 152 for the input value in the fixed-point format based on information specifying the shift amount of the decimal point of the quantized learning model 152 parameters, shifts the decimal point of the output value based on the output value and the shift amount of the decimal point of the output value, and outputs the output value with the shifted decimal point. Therefore, accurate accuracy can be obtained before being implemented in hardware. Since it is possible to perform emulation equivalent to hardware, it can be used for debugging hardware. It can be used in conjunction with a commonly used deep neural network framework.
In addition, the learning model is created by converting parameters into a fixed-point format based on a trained model in the form of a deep neural network. By configuring in this way, it is possible to prepare a learning model from a trained model.
Furthermore, the calculation unit 130 performs a MAC (multiply-accumulate) calculation on the input value based on the parameters. With this configuration, it is possible to calculate the output value of the learning model 152 for the input value by performing a MAC calculation on the input value.

ニューラルネットワークを用いたシステムは、その応用範囲の広さから、様々な用途で使われ、特にエッジデバイスでの使用がされている。しかし、ニューラルネットワークは大量の計算が必要であるため、エッジデバイスで実行するには、計算量を削減する量子化が必須となる。このため、実施形態に係る演算装置の応用先としては監視カメラ、組込みカメラなどで使われるニューラルネットワークの量子化が挙げられる。特に演算方法は実際のハードウェアをエミュレーションすることが可能であり、検証をすばやく行える。また、どのようなニューラルネットワークにも対応可能であり、新しいモデルに対しても量子化を試すことができる。 Because of their wide range of applications, systems using neural networks are used for a variety of purposes, particularly in edge devices. However, because neural networks require a large amount of calculation, quantization to reduce the amount of calculation is essential to run them on edge devices. For this reason, applications of the arithmetic device according to the embodiment include quantization of neural networks used in surveillance cameras, embedded cameras, and the like. In particular, the arithmetic method is capable of emulating actual hardware, allowing for quick verification. In addition, it is compatible with any neural network, making it possible to try quantization on new models as well.

(実施形態の変形例)
[全体構成]
図11は、実施形態の変形例に係る演算装置の構成図である。
ユーザーUは、演算装置100aに、入力値を入力する操作を行う。入力値の一例は、浮動小数点の形式である。以下、入力値が、浮動小数点の形式である場合について説明を続ける。
演算装置100aは、ユーザーUが入力した入力値を受け付ける。演算装置100aは、受け付けた入力値を浮動小数点の形式から固定小数点の形式へ変換する。固定小数点の形式へ変換するときの桁数(ビット幅)nは、予め設定されている。ここで、本実施形態の変形例に係る演算装置100aでは、複数のビット幅nが設定されている。具体的には、n=6、7、8、9、10、16などである。
(Modification of the embodiment)
[Overall configuration]
FIG. 11 is a configuration diagram of a calculation device according to a modified example of the embodiment.
The user U performs an operation to input an input value to the arithmetic device 100a. An example of the input value is a floating-point format. The following will continue with the explanation of the case where the input value is in the floating-point format.
The arithmetic device 100a accepts an input value input by a user U. The arithmetic device 100a converts the accepted input value from floating-point format to fixed-point format. The number of digits (bit width) n when converting to the fixed-point format is set in advance. Here, in the arithmetic device 100a according to the modified example of this embodiment, a plurality of bit widths n are set. Specifically, n=6, 7, 8, 9, 10, 16, etc.

演算装置100aは、ディープニューラルネットワーク形式の学習モデルに基づいて、その学習モデルに含まれるパラメータを取得する。パラメータの一例は、浮動小数点の形式である。以下、入力値が、浮動小数点の形式である場合について説明を続ける。演算装置100aは、取得したパラメータを固定小数点の形式へ変換する。固定小数点の形式へ変換するときの桁数(ビット幅)nは、予め設定されている。 The arithmetic device 100a acquires parameters included in a learning model based on the learning model in the form of a deep neural network. An example of the parameters is a floating-point format. Below, the explanation will continue for the case where the input value is in floating-point format. The arithmetic device 100a converts the acquired parameters to a fixed-point format. The number of digits (bit width) n when converting to the fixed-point format is set in advance.

演算装置100aは、固定小数点の形式へ変換後の複数の入力値およびパラメータに基づいて、複数の入力値の各々に対する出力値ouを演算することによって導出する。演算装置100aは、導出した複数の出力値ouと出力値の小数点のシフト量osfとに基づいて、複数の出力値ouの各々の小数点をシフトさせることによって最終出力値を導出する。
演算装置100aは、複数の最終出力値の各々について、最終出力値の精度を導出する。演算装置100aは、入力値を固定小数点の形式へ変換するときの複数のビット幅nの各々について、ビット幅と精度とを関連付けて出力する。
以下、演算装置100aについて説明する。
The arithmetic device 100a derives an output value ou for each of a plurality of input values by calculating the output value ou for each of the plurality of input values based on the plurality of input values and parameters after conversion to a fixed-point format. The arithmetic device 100a derives a final output value by shifting the decimal point of each of the plurality of output values ou based on the derived plurality of output values ou and the shift amount osf of the decimal point of the output value.
The arithmetic device 100a derives the precision of each of a plurality of final output values. The arithmetic device 100a outputs the bit width and the precision in association with each other for each of a plurality of bit widths n when converting the input value into the fixed-point format.
The arithmetic device 100a will now be described.

[演算装置100a]
演算装置100aは、スマートフォン、携帯端末、又はパーソナルコンピュータ、タブレット端末装置、あるいはその他の情報処理機器として実現される。演算装置100aは、例えば、入力部110と、受付部120と、取得部125と、演算部130aと、導出部135と、出力部140aと、記憶部150とを備える。
[Calculation device 100a]
The arithmetic device 100a is realized as a smartphone, a mobile terminal, a personal computer, a tablet terminal device, or other information processing equipment. The arithmetic device 100a includes, for example, an input unit 110, a reception unit 120, an acquisition unit 125, a arithmetic unit 130a, a derivation unit 135, an output unit 140a, and a storage unit 150.

演算部130aは、取得部125が取得した入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とを取得する。演算部130aは、取得した入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とに基づいて、入力値に対する学習モデル152の出力値を演算する。 The calculation unit 130a acquires information specifying the amount of decimal point shift for each parameter of the input layer, intermediate layer, and output layer acquired by the acquisition unit 125, and information specifying the amount of decimal point shift for each output of the input layer, intermediate layer, and output layer. The calculation unit 130a calculates the output value of the learning model 152 for the input value based on the acquired information specifying the amount of decimal point shift for each parameter of the input layer, intermediate layer, and output layer, and information specifying the amount of decimal point shift for each output of the input layer, intermediate layer, and output layer.

演算部130aが実行するMAC演算は、図5を適用できる。演算部130aは、乗算器10と加算器20と加算器30とを備え、積和演算と加算演算とを行う。演算部130aは、入力値inとパラメータの小数点のシフト量を特定する情報とを取得する。ここで、入力値inは、入力値の小数点のシフト量を特定する情報に基づいて、固定小数点の形式に変換されたものである。
演算部130aは、パラメータの小数点のシフト量を特定する情報に基づいて、ウエイトWEの小数点をシフトさせる。演算部130aにおいて、乗算器10は、入力値inと小数点をシフトさせたウエイトWEとを乗算する。加算器20は、入力値inと小数点をシフトさせたウエイトWEとを乗算した結果とを加算する。
The MAC calculation performed by the calculation unit 130a can be applied to Fig. 5. The calculation unit 130a includes a multiplier 10, an adder 20, and an adder 30, and performs a multiply-and-accumulate calculation and an addition calculation. The calculation unit 130a acquires an input value in and information specifying the amount of shift of the decimal point of the parameter. Here, the input value in is converted to a fixed-point format based on the information specifying the amount of shift of the decimal point of the input value.
The calculation unit 130a shifts the decimal point of the weight WE based on information specifying the amount of shift of the decimal point of the parameter. In the calculation unit 130a, the multiplier 10 multiplies the input value in by the weight WE with the decimal point shifted. The adder 20 adds the result of multiplying the input value in by the weight WE with the decimal point shifted.

加算器30は、加算器20の出力値OUと出力の小数点のシフト量osfとに基づいて、出力値OUの小数点をシフトさせることによって、最終出力を導出する。具体的には、加算器30は、出力値OUに0.5を加算する。
導出部135は、演算部130aから、複数のビット幅nの各々について、最終出力を取得する。導出部135は、取得した複数の最終出力に基づいて、最終出力の精度を導出する。
出力部140aは、導出部135から、入力値を固定小数点の形式に変換したときの複数のビット幅の各々と、最終出力の精度とを関連付けた情報を取得する。出力部140aは、取得した複数のビット幅の各々と、最終出力の精度とを関連付けた情報を出力する。
The adder 30 derives the final output by shifting the decimal point of the output value OU based on the output value OU of the adder 20 and the shift amount osf of the decimal point of the output. Specifically, the adder 30 adds 0.5 to the output value OU.
The derivation unit 135 acquires the final output for each of the multiple bit widths n from the calculation unit 130a. The derivation unit 135 derives the accuracy of the final output based on the multiple acquired final outputs.
The output unit 140a acquires information associating each of a plurality of bit widths obtained when the input value is converted into a fixed-point format with the precision of the final output from the derivation unit 135. The output unit 140a outputs the information associating each of the acquired plurality of bit widths with the precision of the final output.

(演算装置100aの動作)
図12は、実施形態の変形例に係る演算装置の動作の一例を示すフローチャートである。
(ステップS1-3)
演算装置100aにおいて、受付部120は、入力部110に入力された入力値を特定する情報を取得し、取得した入力値を特定する情報を受け付ける。
(ステップS2-3)
演算装置100aにおいて、取得部125は、記憶部150のシフト量情報154に記憶されている入力値の小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とを取得する。
(ステップS3-3)
演算装置100aにおいて、演算部130aは、ビット幅を設定する。
(Operation of arithmetic device 100a)
FIG. 12 is a flowchart illustrating an example of the operation of a calculation device according to a modified example of the embodiment.
(Step S1-3)
In the arithmetic device 100a, the receiving unit 120 obtains information specifying an input value input to the input unit 110, and receives the obtained information specifying the input value.
(Step S2-3)
In the calculation device 100a, the acquisition unit 125 acquires information specifying the shift amount of the decimal point of the input value stored in the shift amount information 154 of the storage unit 150, information specifying the shift amount of the decimal point of each parameter of the input layer, the intermediate layer, and the output layer, and information specifying the shift amount of the decimal point of each output of the input layer, the intermediate layer, and the output layer.
(Step S3-3)
In the calculation device 100a, the calculation unit 130a sets the bit width.

(ステップS4-3)
演算装置100aにおいて、演算部130aは、受付部120が受け付けた入力値を特定する情報を取得する。演算部130aは、取得した入力値を特定する情報と設定したビット幅とに基づいて、入力値を固定小数点の形式へ変換する。
(ステップS5-3)
演算装置100aにおいて、演算部130aは、取得部125が取得した入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とを取得する。演算部130aは、取得した入力層と中間層と出力層との各々のパラメータの小数点のシフト量を特定する情報と、入力層と中間層と出力層との各々の出力の小数点のシフト量を特定する情報とに基づいて、入力値に対する学習モデル152の出力値を演算する。
(Step S4-3)
In the arithmetic device 100a, the arithmetic unit 130a acquires information specifying an input value accepted by the accepting unit 120. The arithmetic unit 130a converts the input value into a fixed-point format based on the acquired information specifying the input value and the set bit width.
(Step S5-3)
In the calculation device 100a, the calculation unit 130a acquires information specifying the amount of decimal point shift of each parameter of the input layer, the intermediate layer, and the output layer, and information specifying the amount of decimal point shift of each output of the input layer, the intermediate layer, and the output layer acquired by the acquisition unit 125. The calculation unit 130a calculates an output value of the learning model 152 for an input value, based on the acquired information specifying the amount of decimal point shift of each parameter of the input layer, the intermediate layer, and the output layer, and information specifying the amount of decimal point shift of each output of the input layer, the intermediate layer, and the output layer.

(ステップS6-3)
演算装置100aにおいて、演算部130aは、出力値と出力の小数点のシフト量osfとに基づいて、出力値OUの小数点をシフトさせることによって、最終出力を導出する。
(ステップS7-3)
演算装置100aにおいて、演算部130aは、全てのビット幅で最終出力を導出したか否かを判定する。最終出力を導出していないビット幅がある場合には、ステップS3-3へ戻る。
(ステップS8-3)
演算装置100aにおいて、導出部135は、演算部130aが全てのビット幅で最終出力を導出したと判定した場合に、演算部130aから、複数のビット幅nの各々について、最終出力を取得する。導出部135は、取得した複数の最終出力に基づいて、最終出力の精度を導出する。
(Step S6-3)
In the calculation device 100a, the calculation section 130a derives the final output by shifting the decimal point of the output value OU based on the output value and the shift amount osf of the decimal point of the output.
(Step S7-3)
In the calculation device 100a, the calculation unit 130a judges whether or not the final output has been derived for all bit widths. If there is a bit width for which the final output has not been derived, the process returns to step S3-3.
(Step S8-3)
In the computing device 100a, when it is determined that the computing unit 130a has derived the final output for all bit widths, the derivation unit 135 acquires the final output for each of the multiple bit widths n from the computing unit 130a. The derivation unit 135 derives the accuracy of the final output based on the multiple acquired final outputs.

(ステップS9-3)
演算装置100aにおいて、出力部140aは、導出部135から、入力値を固定小数点の形式に変換したときの複数のビット幅の各々と、最終出力の精度とを関連付けた情報を取得する。出力部140aは、取得した複数のビット幅の各々と、最終出力の精度とを関連付けた情報を出力する。
図12では、全てのビット幅で最終出力を導出した後に、最終出力の精度が導出される場合について説明したが、この例に限られない。例えば、最終出力が導出されるたびに、最終出力の精度が導出されるようにしてもよい。
(Step S9-3)
In the arithmetic device 100a, the output unit 140a acquires information associating each of a plurality of bit widths obtained when an input value is converted into a fixed-point format with the precision of the final output from the derivation unit 135. The output unit 140a outputs the information associating each of the acquired plurality of bit widths with the precision of the final output.
12, the case where the accuracy of the final output is derived after the final output is derived for all bit widths has been described, but this is not limiting. For example, the accuracy of the final output may be derived every time the final output is derived.

実施形態の変形例に係る演算装置100aによれば、演算装置100aは、前述した演算装置100において、演算部130aは、異なるビット幅で固定小数点の形式へ変換された複数の入力値に対する学習モデルの出力値を求め、求めた複数の出力値の各々と出力値の小数点のシフト量とに基づいて、求めた複数の出力値の各々の小数点をシフトさせる。演算装置100aは、複数の出力値の各々の小数点をシフトさせた結果の精度を導出する導出部を備える。
このように構成することによって、演算装置100aは、複数のビット幅の各々について、学習モデルの出力値の小数点をシフトさせた結果の精度を導出できる。このため、仮に学習モデルに要求される精度が設定された場合に、その要求される精度を満足するビット幅を求めることができる。つまり、複数の学習モデルが用意された場合に、許容できるビット幅を求めることができる。また、エミュレーションの時点で、量子化によってどの程度精度が低下するかが分かる。
According to the arithmetic device 100a according to the modified embodiment, the arithmetic device 100a is the arithmetic device 100 described above, in which the arithmetic unit 130a calculates output values of a learning model for a plurality of input values converted into fixed-point format with different bit widths, and shifts the decimal point of each of the calculated output values based on each of the calculated output values and the shift amount of the decimal point of the output value. The arithmetic device 100a includes a derivation unit that derives the precision of the result of shifting the decimal point of each of the plurality of output values.
By configuring in this way, the arithmetic device 100a can derive the accuracy of the result of shifting the decimal point of the output value of the learning model for each of a plurality of bit widths. Therefore, if the accuracy required for the learning model is set, it is possible to obtain a bit width that satisfies the required accuracy. In other words, if a plurality of learning models are prepared, it is possible to obtain an allowable bit width. In addition, it is possible to know the degree to which accuracy is reduced by quantization at the time of emulation.

図13は、本実施形態の変形例に係る演算装置の出力の精度の導出結果の一例を示す図である。図13において、横軸は入力値の形式であり、縦軸は精度を示す。
「FP32」は浮動小数点形式の32ビットであり、「FP16」は浮動小数点形式の16ビットである。「INT16」は固定小数点形式の16ビットであり、「INT10」は固定小数点形式の10ビットであり、「INT9」は固定小数点形式の9ビットである。「INT8」は固定小数点形式の8ビットであり、「INT7」は固定小数点形式の7ビットであり、「INT6」は固定小数点形式の6ビットである。
ImageNetとCIFAR100とで学習された学習モデルを使用して、精度の評価を行った。ここでは、学習モデルの一例として、AlexNetと、VGG16と、MobileNet-v2とについて示す。
13 is a diagram showing an example of a result of deriving the accuracy of the output of a calculation device according to a modified example of this embodiment, in which the horizontal axis indicates the format of the input value, and the vertical axis indicates the accuracy.
"FP32" is 32-bit floating point format, "FP16" is 16-bit floating point format, "INT16" is 16-bit fixed point format, "INT10" is 10-bit fixed point format, "INT9" is 9-bit fixed point format, "INT8" is 8-bit fixed point format, "INT7" is 7-bit fixed point format, and "INT6" is 6-bit fixed point format.
Accuracy was evaluated using a learning model trained on ImageNet and CIFAR 100. Here, AlexNet, VGG16, and MobileNet-v2 are shown as examples of the learning model.

図13によれば、ImageNetで学習されたAlexNet(Innet_AlexNet)の場合には、FP32、FP16、INT16、INT10、INT9に比べて、INT8、INT7、INT6については精度が低下することが分かる。
ImageNetで学習されたVGG16(Innet_VGG16)の場合には、FP32、FP16、INT16、INT10、INT9、INT8に比べて、INT7、INT6については精度が低下することが分かる。
ImageNetで学習されたMobileNet-v2(Innet_MobileNet-v2)の場合には、FP32、FP16、INT16、INT10に比べて、INT9、INT8、INT7、INT6については精度が低下することが分かる。
According to FIG. 13, in the case of AlexNet (Innet_AlexNet) trained with ImageNet, the accuracy is lower for INT8, INT7, and INT6 compared to FP32, FP16, INT16, INT10, and INT9.
In the case of VGG16 (Innet_VGG16) trained with ImageNet, it can be seen that the accuracy is lower for INT7 and INT6 compared to FP32, FP16, INT16, INT10, INT9, and INT8.
In the case of MobileNet-v2 (Innet_MobileNet-v2) trained with ImageNet, it can be seen that the accuracy is lower for INT9, INT8, INT7, and INT6 compared to FP32, FP16, INT16, and INT10.

さらに、図13によれば、CIFAR100で学習されたAlexNet(C100_AlexNet)の場合には、FP32、FP16、INT16、INT10、INT9に比べて、INT8、INT7、INT6については精度が低下することが分かる。
CIFAR100で学習されたVGG16(C100_VGG16)の場合には、FP32、FP16、INT16、INT10、INT9、INT8に比べて、INT7、INT6については精度が低下することが分かる。
CIFAR100で学習されたMobileNet-v2(C100_MobileNet-v2)の場合には、FP32、FP16、INT16、INT10、INT9に比べて、INT8、INT7、INT6については精度が低下することが分かる。
さらに、図13によれば、CIFAR100で学習されたAlexNetにGAP(Global average Pooling)を適用(C100_AlexNet_GAP)の場合には、FP32、FP16、INT16、INT10、INT9に比べて、INT8、INT7、INT6については精度が低下することが分かる。
CIFAR100で学習されたVGG16にGAPを適用(C100_VGG16_GAP)の場合には、FP32、FP16、INT16、INT10、INT9、INT8に比べて、INT7、INT6については精度が低下することが分かる。
図13によれば、学習モデルが用意された場合に、許容される精度に基づいて、何ビットまで許容できるか求めることができる。
Furthermore, according to FIG. 13, in the case of AlexNet trained with CIFAR100 (C100_AlexNet), the accuracy is lower for INT8, INT7, and INT6 compared to FP32, FP16, INT16, INT10, and INT9.
In the case of VGG16 (C100_VGG16) trained with CIFAR100, it can be seen that the accuracy is lower for INT7 and INT6 compared to FP32, FP16, INT16, INT10, INT9, and INT8.
In the case of MobileNet-v2 (C100_MobileNet-v2) trained with CIFAR100, it can be seen that the accuracy is lower for INT8, INT7, and INT6 compared to FP32, FP16, INT16, INT10, and INT9.
Furthermore, according to FIG. 13, when GAP (Global average Pooling) is applied to AlexNet trained with CIFAR100 (C100_AlexNet_GAP), the accuracy is lower for INT8, INT7, and INT6 compared to FP32, FP16, INT16, INT10, and INT9.
When GAP is applied to VGG16 trained with CIFAR100 (C100_VGG16_GAP), it can be seen that the accuracy is lower for INT7 and INT6 compared to FP32, FP16, INT16, INT10, INT9, and INT8.
According to FIG. 13, when a learning model is prepared, it is possible to find how many bits are permissible based on the permissible accuracy.

以上、本発明の実施形態を説明したが、これらの実施形態は、例として提示したものであり、発明の範囲を限定することは意図していない。これら実施形態は、その他の様々な形態で実施されることが可能であり、発明の要旨を逸脱しない範囲で、種々の省略、置き換え、変更、組合わせを行うことができる。これら実施形態及びその変形例は、発明の範囲や要旨に含まれると同時に、特許請求の範囲に記載された発明とその均等の範囲に含まれるものである。
なお、前述の演算装置100、端末装置300、演算装置100aは内部にコンピュータを有している。そして、前述した各装置の各処理の過程は、プログラムの形式でコンピュータ読み取り可能な記録媒体に記憶されており、このプログラムをコンピュータが読み出して実行することによって、上記処理が行われる。ここでコンピュータ読み取り可能な記録媒体とは、磁気ディスク、光磁気ディスク、CD-ROM、DVD-ROM、半導体メモリなどをいう。また、このコンピュータプログラムを通信回線によってコンピュータに配信し、この配信を受けたコンピュータが当該プログラムを実行するようにしてもよい。
また、上記プログラムは、前述した機能の一部を実現するためのものであってもよい。
さらに、前述した機能をコンピュータシステムにすでに記録されているプログラムとの組み合わせで実現できるもの、いわゆる差分ファイル(差分プログラム)であってもよい。
Although the embodiments of the present invention have been described above, these embodiments are presented as examples and are not intended to limit the scope of the invention. These embodiments can be implemented in various other forms, and various omissions, substitutions, modifications, and combinations can be made without departing from the spirit of the invention. These embodiments and their modifications are included in the scope and spirit of the invention, and are also included in the scope of the invention and its equivalents described in the claims.
The above-mentioned arithmetic device 100, terminal device 300, and arithmetic device 100a each have a computer inside. The process of each of the above-mentioned devices is stored in a computer-readable recording medium in the form of a program, and the above-mentioned processes are performed by the computer reading and executing this program. Here, the computer-readable recording medium refers to a magnetic disk, a magneto-optical disk, a CD-ROM, a DVD-ROM, a semiconductor memory, etc. Also, the computer program may be distributed to a computer via a communication line, and the computer that receives the program may execute the program.
The program may be for realizing part of the functions described above.
Furthermore, the above-mentioned functions may be realized in combination with a program already recorded in the computer system, that is, a so-called differential file (differential program).

10…乗算器、 20、30…加算器、100、100a…演算装置、 110…入力部、 120…受付部、 125…取得部、 130、130a…演算部、 135…導出部、 140、140a…出力部、 150…記憶部、 151-1…入力層、 151-2…中間層、 151-3…出力層、 152…学習モデル、 154…シフト量情報、 200、205…入力値、 210、215…符号ビット、 220…指数部、 225…整数部、 230…仮数部、 235…小数部、 245…小数点、300…端末装置、 310…入力部、 320…受付部、 325…取得部、 330…演算部、 340…出力部、 350…記憶部、 352、352a…学習モデル、 354…シフト量情報、 351-1、351a-1…入力層、 351-2、351a-2…中間層、 351-3、351a-3…出力層 10...multiplier, 20, 30...adder, 100, 100a...arithmetic unit, 110...input unit, 120...reception unit, 125...acquisition unit, 130, 130a...arithmetic unit, 135...derivation unit, 140, 140a...output unit, 150...storage unit, 151-1...input layer, 151-2...intermediate layer, 151-3...output layer, 152...learning model, 154...shift amount information, 200, 205...input value, 210, 215...sign bit, 220...exponent part, 225...integer part, 230...mantissa part, 235...fractional part, 245...decimal point, 300...terminal device, 310...input unit, 320...reception unit, 325...acquisition unit, 330: Calculation unit; 340: Output unit; 350: Storage unit; 352, 352a: Learning model; 354: Shift amount information; 351-1, 351a-1: Input layer; 351-2, 351a-2: Intermediate layer; 351-3, 351a-3: Output layer

Claims (8)

ニューラルネットワーク形式の学習モデルのパラメータの小数点のシフト量を特定する情報を取得する取得部と、
前記取得部が取得したパラメータの小数点のシフト量を特定する情報に基づいて、異なるビット幅で固定小数点の形式へ変換された複数の入力値に対する前記学習モデルの出力値を求め、求めた複数の前記出力値の各々と出力値の小数点のシフト量とに基づいて、求めた複数の前記出力値の各々の小数点をシフトさせる演算部と
複数の前記出力値の各々の小数点をシフトさせた結果の精度を導出する導出部と、
を備え、
前記入力値は、固定小数点の形式である、演算装置。
An acquisition unit that acquires information that specifies a decimal point shift amount of a parameter of a neural network type learning model;
a calculation unit that calculates output values of the learning model for a plurality of input values converted to a fixed-point format with different bit widths based on information specifying the amount of shift of a decimal point of the parameter acquired by the acquisition unit, and shifts the decimal point of each of the calculated output values based on each of the calculated output values and the amount of shift of the decimal point of the output value ;
a derivation unit that derives a precision of a result of shifting a decimal point of each of the plurality of output values;
Equipped with
The input values are in fixed-point format.
前記パラメータには、複数の層の各々のパラメータが含まれる、請求項1に記載の演算装置。 The computing device of claim 1, wherein the parameters include parameters for each of a plurality of layers. 前記パラメータには、ウエイトおよび出力が含まれる、請求項2に記載の演算装置。 The computing device of claim 2, wherein the parameters include weights and outputs. 前記パラメータには、バイアスがさらに含まれる、請求項3に記載の演算装置。 The computing device of claim 3, wherein the parameters further include a bias. 前記パラメータは、固定小数点の形式である、請求項1から請求項4のいずれか一項に記載の演算装置。 The arithmetic device according to any one of claims 1 to 4, wherein the parameters are in fixed-point format. 前記学習モデルは、ディープニューラルネットワーク形式の学習済モデルに基づいて、パラメータを固定小数点の形式に変換することによって作成されたものである、請求項1から請求項5のいずれか一項に記載の演算装置。 The arithmetic device according to any one of claims 1 to 5, wherein the learning model is created by converting parameters into a fixed-point format based on a learned model in a deep neural network format. 前記演算部は、前記パラメータに基づいて、入力値に対して、MAC(multiply-accumulate)演算を行う、請求項1から請求項6のいずれか一項に記載の演算装置。 The arithmetic device according to any one of claims 1 to 6, wherein the arithmetic unit performs a MAC (multiply-accumulate) operation on the input value based on the parameters. ニューラルネットワーク形式の学習モデルのパラメータの小数点のシフト量を特定する情報を取得するステップと、
取得する前記ステップで取得したパラメータの小数点のシフト量を特定する情報に基づいて、異なるビット幅で固定小数点の形式へ変換された複数の入力値に対する前記学習モデルの出力値を求め、求めた複数の前記出力値の各々と出力値の小数点のシフト量とに基づいて、求めた複数の前記出力値の各々の小数点をシフトさせるステップと、
複数の前記出力値の各々の小数点をシフトさせた結果の精度を導出するステップと、
を有し、
前記入力値は、固定小数点の形式である、コンピュータが実行する演算方法。
Obtaining information specifying a decimal point shift amount of a parameter of a neural network type learning model;
A step of obtaining output values of the learning model for a plurality of input values converted to a fixed-point format with different bit widths based on information specifying the amount of shift of the decimal point of the parameter obtained in the obtaining step, and shifting the decimal point of each of the obtained plurality of output values based on each of the obtained plurality of output values and the amount of shift of the decimal point of the output value;
deriving a precision resulting from shifting the decimal point of each of the plurality of output values;
having
A computer implemented method of arithmetic, wherein the input values are in fixed point format.
JP2020193718A 2020-11-20 2020-11-20 Calculation device and calculation method Active JP7614475B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2020193718A JP7614475B2 (en) 2020-11-20 2020-11-20 Calculation device and calculation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2020193718A JP7614475B2 (en) 2020-11-20 2020-11-20 Calculation device and calculation method

Publications (2)

Publication Number Publication Date
JP2022082257A JP2022082257A (en) 2022-06-01
JP7614475B2 true JP7614475B2 (en) 2025-01-16

Family

ID=81810679

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2020193718A Active JP7614475B2 (en) 2020-11-20 2020-11-20 Calculation device and calculation method

Country Status (1)

Country Link
JP (1) JP7614475B2 (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019139338A (en) 2018-02-07 2019-08-22 富士通株式会社 Information processor, information processing method and program
JP2020009444A (en) 2018-07-04 2020-01-16 三星電子株式会社Samsung Electronics Co.,Ltd. Method and apparatus of processing parameter in neural network

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019139338A (en) 2018-02-07 2019-08-22 富士通株式会社 Information processor, information processing method and program
JP2020009444A (en) 2018-07-04 2020-01-16 三星電子株式会社Samsung Electronics Co.,Ltd. Method and apparatus of processing parameter in neural network

Also Published As

Publication number Publication date
JP2022082257A (en) 2022-06-01

Similar Documents

Publication Publication Date Title
US11169778B2 (en) Converting floating point numbers to reduce the precision
CN113011425B (en) Image segmentation method, device, electronic equipment and computer readable storage medium
Mandelli et al. Adaptive sampling using support vector machines
US20080219352A1 (en) Motion vector searching apparatus, motion vector searching method and storage medium for storing motion vector searching program
US10628124B2 (en) Stochastic rounding logic
US11106431B2 (en) Apparatus and method of fast floating-point adder tree for neural networks
US20240404262A1 (en) Method and machine learning system to perform quantization of neural network
EP3798929A1 (en) Information processing apparatus, information processing method, and information processing program
WO2022247368A1 (en) Methods, systems, and mediafor low-bit neural networks using bit shift operations
JP4500358B2 (en) Arithmetic processing apparatus and arithmetic processing method
JP7614475B2 (en) Calculation device and calculation method
Santos Deep and Physics-Informed Neural Networks as a Substitute for Finite Element Analysis
CN112182729A (en) Tunnel face stability rapid determination method based on naive Bayes
JP7188237B2 (en) Information processing device, information processing method, information processing program
CN110337636A (en) Data conversion method and device
CN118070551A (en) Saddle point approximate line sampling method for reliability analysis of uncertain systems
US20080071852A1 (en) Method to perform a subtraction of two operands in a binary arithmetic unit plus arithmetic unit to perform such a method
JP2023031296A (en) Arithmetic method and device
CN112236749B (en) A floating point precision detection method and device
CN121434554B (en) Matrix multiplication device, method, electronic device, and storage medium
CN120431283B (en) Implicit geological modeling method, system and equipment based on GPU acceleration
CN120430143B (en) BIM-based tunnel soft rock deformation data processing method and system
CN120911144B (en) Single-precision hardware double-precision simulation method based on floating point decomposition reconstruction
CN119494414B (en) Dirty quantum constant comparator, dirty quantum variable comparator and quantum computer
CN110648287A (en) Parallel efficient calculation method for box type filter

Legal Events

Date Code Title Description
A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20201208

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20231102

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20240830

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20240903

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20241031

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20241119

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20241127

R150 Certificate of patent or registration of utility model

Ref document number: 7614475

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150