JP6984762B2 - Arithmetic processing unit and control method of arithmetic processing unit - Google Patents
Arithmetic processing unit and control method of arithmetic processing unit Download PDFInfo
- Publication number
- JP6984762B2 JP6984762B2 JP2020551748A JP2020551748A JP6984762B2 JP 6984762 B2 JP6984762 B2 JP 6984762B2 JP 2020551748 A JP2020551748 A JP 2020551748A JP 2020551748 A JP2020551748 A JP 2020551748A JP 6984762 B2 JP6984762 B2 JP 6984762B2
- Authority
- JP
- Japan
- Prior art keywords
- rounding
- random number
- unit
- digit
- output
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/38—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
- G06F7/48—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
- G06F7/499—Denomination or exception handling, e.g. rounding or overflow
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computational Mathematics (AREA)
- Computing Systems (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Complex Calculations (AREA)
Description
本発明は、演算処理装置及び演算処理装置の制御方法に関する。 The present invention relates to an arithmetic processing unit and a control method for the arithmetic processing unit.
昨今重要性を増す深層学習(Deep Learning)は、計算量やメモリ消費量が莫大である。計算量やメモリ消費量が増加すると、計算負荷及びメモリ負荷などが増加し、学習時間が長くなる。そこで、計算量やメモリ消費量を削減して学習時間を短縮するため、学習及び推論能力を維持しつつ、できる限り低い精度で計算を行う手法を用いることが望ましい。このような手法においては、固定小数点を用いた演算が行われることが多い。 Deep learning, which is becoming more important these days, requires a huge amount of calculation and memory consumption. When the amount of calculation and the amount of memory consumed increase, the calculation load and the memory load increase, and the learning time becomes long. Therefore, in order to reduce the amount of calculation and memory consumption and shorten the learning time, it is desirable to use a method of performing calculation with the lowest possible accuracy while maintaining learning and inference ability. In such a method, an operation using a fixed point is often performed.
ただし、低精度で計算を行う場合に挙げられる問題として、演算結果を丸めた値が、低精度ではある決まった値に偏り易くなる。丸めた値が偏ると、その時点から学習が進みにくくなるという問題が存在する。 However, as a problem raised when the calculation is performed with low accuracy, the rounded value of the calculation result tends to be biased to a certain fixed value with low accuracy. If the rounded values are biased, there is a problem that learning does not proceed easily from that point.
そのような低精度における値の偏りを解消するために、確率的丸めを導入した従来技術がある。これは、丸める前の計算結果の丸めようとする桁より下位の値に応じた確率で、丸め値を丸め桁で打ち切った(truncated)値にするか、その値に1を加算した値にするかを選択して、丸め結果がとる期待値と丸め前の値とを同等にする技術である。例えば、演算結果1.8を整数に丸める場合、確率的丸めを用いると、丸め結果として80%の確率で2が得られ、20%の確率で1が得られる。これにより、丸め結果の期待値は、丸め前の値と同じ1.8となる。 In order to eliminate the value bias in such low accuracy, there is a conventional technique that introduces stochastic rounding. This is the probability according to the value lower than the digit to be rounded in the calculation result before rounding, and the rounded value is either a truncated value or a value obtained by adding 1 to the rounded value. It is a technique to make the expected value of the rounding result equal to the value before rounding by selecting. For example, when the calculation result 1.8 is rounded to an integer, if probabilistic rounding is used, 2 is obtained with a probability of 80% and 1 is obtained with a probability of 20% as the rounding result. As a result, the expected value of the rounding result is 1.8, which is the same as the value before rounding.
ここで、深層学習においては、行列の要素に対し積和累積演算が多用される。積和累積演算とは、C’=C+A×Bの形の演算であり、ある時点までの計算結果に次の要素の積を累積していく演算である。このとき累積演算を継続する間、累積結果は、乗算への入力数よりかなり高い精度を有する値で保持されることが一般的である。例えば、上述の式における乗算への入力数であるA及びBが16ビット幅であるとき、乗算結果であるA×Bは、32ビットとなる。このとき乗算結果の累積を格納する累積レジスタについては、32ビットの値の累積結果を格納する大きさを有することが好ましく、例えば、40ビット幅とされるような場合がある。 Here, in deep learning, product-sum accumulation operations are often used for matrix elements. The product-sum accumulation operation is an operation in the form of C'= C + A × B, and is an operation in which the product of the next element is accumulated in the calculation result up to a certain point in time. At this time, while the cumulative operation is continued, the cumulative result is generally held at a value having a accuracy considerably higher than the number of inputs to the multiplication. For example, when A and B, which are the number of inputs to multiplication in the above equation, are 16 bits wide, A × B, which is the result of multiplication, is 32 bits. At this time, the cumulative register that stores the cumulative result of the multiplication result is preferably large enough to store the cumulative result of the 32-bit value, and may be, for example, 40 bits wide.
以上のことから、乗算結果を丸めた場合、精度の低下が大きくなるおそれがある。そこで、深層学習を実行するハードウェアにおいては、乗算への入力数よりもビット数が多い積和累積演算の結果に対し、確率的丸めを行い低精度にした結果を出力するという処理が行われることが望ましい。 From the above, when the multiplication result is rounded, the accuracy may be significantly reduced. Therefore, in the hardware that executes deep learning, a process is performed in which the result of the product-sum cumulative operation, which has more bits than the number of inputs to multiplication, is probabilistically rounded and the result is output with low accuracy. Is desirable.
丸めを行う際、丸めにより捨てられることになる下位桁に、何らかの数を加算することで所望する場合に繰り上がりを発生させ、丸め位置により上位桁に所望の丸め結果を得るという手法が存在する。この手法は確率的丸めにおいても有効である。そこで、積和演算器内の加算回路を活用して下位桁に加算を行うことで確率的丸めを行う従来技術が提案されている。また、ランダムノイズ回路からの出力をデータの端数部に加算して丸め処理を実行する従来技術がある。さらに、累積レジスタの丸めを行う装置として、丸め回路が、乱数生成器から値を受け取り丸めの判断に用いる従来技術がある。 When performing rounding, there is a method of adding some number to the lower digit that will be discarded by rounding to generate a carry when desired, and obtaining the desired rounding result in the upper digit depending on the rounding position. .. This method is also effective in stochastic rounding. Therefore, a conventional technique has been proposed in which probabilistic rounding is performed by adding to the lower digits by utilizing the addition circuit in the product-sum calculator. Further, there is a conventional technique of adding the output from the random noise circuit to the fractional part of the data and executing the rounding process. Further, as a device for rounding the cumulative register, there is a conventional technique in which a rounding circuit receives a value from a random number generator and uses it for determining rounding.
しかしながら、確率的丸めに積和演算器内の加算回路を用いる従来技術では、乗算結果に対する丸めが行われる。先に述べたとおり、一般には、乗算結果への入力値のビット幅は、乗算結果の累積レジスタのビット幅よりはるかに狭い。そのため、乗算結果の丸めにより累積レジスタの値を低精度に丸めることは、丸め値が不適切な値になるおそれがある。また、丸め回路に乱数生成器から取得した値を用いて丸めを判断させる従来技術では、丸め回路への大規模な改造が加えられる。丸め回路による丸め処理は浮動小数点演算のクリティカルパスを有する。そのため、丸め回路に対して確率的丸めを行うための規模の大きな改造を加えた場合、既存演算のクリティカルパスのディレイ悪化要因となるおそれがある。すなわち、浮動小数点積和演算器に大規模な改造を加えることは困難である。 However, in the prior art using an adder circuit in a multiply-accumulate calculator for stochastic rounding, rounding is performed on the multiplication result. As mentioned earlier, the bit width of the input value to the multiplication result is generally much narrower than the bit width of the cumulative register of the multiplication result. Therefore, rounding the value of the cumulative register with low precision by rounding the multiplication result may result in an inappropriate rounding value. Further, in the conventional technique of making the rounding circuit judge the rounding by using the value obtained from the random number generator, a large-scale modification to the rounding circuit is added. Rounding by the rounding circuit has a critical path for floating point arithmetic. Therefore, if a large-scale modification is made to the rounding circuit for probabilistic rounding, it may cause a deterioration in the delay of the critical path of the existing operation. That is, it is difficult to make a large-scale modification to the floating-point multiply-accumulate unit.
開示の技術は、上記に鑑みてなされたものであって、簡易な構成で適切な確率的丸めを実行する演算処理装置及び演算処理装置の制御方法を提供することを目的とする。 The disclosed technique has been made in view of the above, and an object of the present invention is to provide an arithmetic processing unit and a control method of the arithmetic processing unit that execute appropriate stochastic rounding with a simple configuration.
本願の開示する演算処理装置及び演算処理装置の制御方法は、一つの態様において、乱数生成部は、乱数を生成する。乱数移動部は、丸め対象数が配置される位置及び出力データの小数点位置情報を基に、前記乱数の先頭が前記丸め対象数の丸め位置に一致するように前記乱数の位置を移動する。加算部は、前記乱数移動部により移動された前記乱数と前記所定位置に配置された前記丸め対象数とを加算する。出力部は、前記加算部による加算結果における前記丸め位置から所定桁の有効数字を含む所定範囲のデータを前記出力データとして出力する。 In one embodiment of the arithmetic processing unit and the control method of the arithmetic processing unit disclosed in the present application, the random number generation unit generates a random number. The random number moving unit moves the position of the random number so that the head of the random number coincides with the rounding position of the number of rounding targets based on the position where the number of rounding targets is arranged and the decimal point position information of the output data. The adding unit adds the random number moved by the random number moving unit and the number of rounding targets arranged at the predetermined positions. The output unit outputs data in a predetermined range including significant digits of a predetermined digit from the rounding position in the addition result by the addition unit as the output data.
1つの側面では、本発明は、簡易な構成で適切な確率的丸めを実行することができる。 In one aspect, the invention can perform appropriate stochastic rounding with a simple configuration.
以下に、本願の開示する演算処理装置及び演算処理装置の制御方法の実施例を図面に基づいて詳細に説明する。なお、以下の実施例により本願の開示する演算処理装置及び演算処理装置の制御方法が限定されるものではない。 Hereinafter, examples of the arithmetic processing unit and the control method of the arithmetic processing unit disclosed in the present application will be described in detail with reference to the drawings. The following embodiments do not limit the arithmetic processing unit and the control method of the arithmetic processing unit disclosed in the present application.
図1は、情報処理装置の全体構成図である。情報処理装置50は、PCI(Peripheral Component Interconnect)カード1及びホストコンピュータ2を有する。PCIカード1とホストコンピュータ2とはPCIバスで接続され、互いにデータの送受信を行う。
FIG. 1 is an overall configuration diagram of an information processing device. The
ホストコンピュータ2は、例えば、深層学習を実行する際の全体的な管理を行う。深層学習を実行する場合、ホストコンピュータ2は、PCIカード1に対して畳み込み演算などの深層学習における所定の演算の実行を指示する。
The
PCIカード1は、ホストコンピュータ2からの指示を受けて演算を実行し、演算結果をホストコンピュータ2に出力する。PCIカード1は、図1に示すように、複数の処理ユニット10、全体命令制御部11、メモリコントローラ12、メモリ13及びPCI制御部14を有する。このPCIカード1が、「演算処理装置」の一例にあたる。
The
PCI制御部14は、演算の実行を指示する演算命令や演算で使用する演算データの入力をホストコンピュータ2から受ける。そして、PCI制御部14は、取得した演算命令や演算データをメモリコントローラ12へ出力する。
The
また、PCI制御部14は、指示された演算に対する演算結果の入力をメモリコントローラ12から受ける。そして、PCI制御部14は、演算結果をホストコンピュータ2へ出力する。具体的には、PCI制御部14は、メモリコントローラ12に、メモリ13内の演算結果を読み出す指示を出し、読み出したデータを、自信を経由させてホストコンピュータ2へ出力させる。
Further, the
メモリコントローラ12は、演算命令や演算で使用する演算データの入力をPCI制御部14から受ける。そして、メモリコントローラ12は、取得した演算命令及び演算データをメモリ13へ格納する。
The
また、メモリコントローラ12は、演算を実行する際に用いる演算データのベクタレジスタ111への格納の指示を全体命令制御部11から受ける。そして、メモリコントローラ12は、指定された演算データを指定されたベクタレジスタ111へ格納する。ここで、メモリコントローラ12は、直列に並んだ処理ユニット10のうちの後段の処理ユニット10に対してデータを送信する場合、積和演算部100を迂回させてマルチプレクサ103へ演算データを出力する。
Further, the
また、全体命令制御部11は、演算が完了すると、演算完了の通知を全体命令制御部11から受けるとともに、所定の命令によりメモリコントローラ12に指示することで、ベクタレジスタ111内の演算結果を直列に並んだ処理ユニット10のチェーン(連鎖)か引き出し、メモリ13に格納させる。
Further, when the operation is completed, the whole
全体命令制御部11は、ホストコンピュータ2から実行が指示された演算の全体の統括管理を行う。全体命令制御部11は、ホストコンピュータ2からの指示をPCI制御部14経由で受け、メモリ13に格納された全体命令列を次々と読んでは実行する。全体命令には、メモリ13から演算命令バッファ102に演算命令列を転送する命令、メモリ13から演算データをベクタレジスタ111に格納する命令、演算命令バッファ102に格納された演算命令列を演算命令制御部101に実行開始させる命令、ベクタレジスタ111に格納された演算結果をメモリ13に格納する命令、命令列の実行を終了する命令などがある。
The general
全体命令制御部11は、演算命令列を処理ユニット10に実行させる。演算を処理ユニットに実行させる場合、全体命令制御部11は、演算を実行する際に用いる演算データの取得をメモリコントローラ12に指示する。また、処理ユニット10における演算が完了すると、全体命令制御部11は、演算結果の格納をメモリコントローラ12に指示する。さらに、実行が指示された演算の全ての処理が完了すると、全体命令制御部11は、演算完了をメモリコントローラ12へ通知する。
The general
次に、処理ユニット10について説明する。処理ユニット10は、図1に示すように1つのPCIカード1に複数搭載される。各処理ユニット10は、並列及び直列に複数接続される。処理ユニット10の数は、ある太陽においては128個である。処理ユニット10は、積和演算部100、演算命令制御部101、演算命令バッファ102及びマルチプレクサ103を有する。
Next, the
演算命令制御部101は、演算命令の実行処理を管理制御する。演算命令制御部101は、演算命令列の実行の指示を全体命令制御部11から受ける。ここで、処理ユニット10で実行できる命令を、全体命令と対比させて演算命令と呼んでいるが、命令には、積和演算部に演算を行わせる狭義の演算命令のほか、汎用レジスタ(図示しない)の操作命令、分岐命令、繰り返し命令、命令列の実行を停止する命令などが含まれる。
The arithmetic
そして、演算命令制御部101は、演算命令バッファ102に格納された演算命令を順次取得する。次に、演算命令制御部101は、取得した演算命令で指定された演算データの出力をベクタレジスタ111に指示する。また、演算命令制御部101は、取得した演算命令にしたがい、積和演算器112に演算実行の指示を積和演算器112へ出力する。その後、演算命令制御部101は、積和演算器112内で演算結果を用いた演算をループさせる。
Then, the arithmetic
そして、演算が完了すると、演算命令制御部101は、確率的丸め処理の実行の指示とともに、累積レジスタの第何ビットを出力の小数点位置とするかを示す情報である小数点位置情報を積和演算器112へ出力する。小数点位置情報は、ニューラルネットワークにおける各層の重みパラメータを、演算可能なビット幅の範囲でできるだけ有効な値に保つように学習結果から算出される小数点位置を表す。この値は深層学習のプログラムを実行していく過程で決まる値であり、情報処理装置50にとっては可変の値である。その後、メモリコントローラ12からの指示があると、ベクタレジスタ111に格納された確率的丸め処理が施された演算結果は、処理ユニットのチェーンとメモリコントローラ12を経由してメモリ13に格納される。
Then, when the operation is completed, the operation
演算命令制御部101は、例えば、VECTOR.h.accstrnd ELE#,QNUM,DST#といった命令を発行する。ここで、QNUMは、小数点位置情報を表す。また、ELE#は、積和演算器112内に複数要素のレジスタがある場合に、どの要素を確率的丸め対象とするかを示す番号である。DST#は、確率的丸めの結果を格納するレジスタの番号を表す。この命令が実行されると、ELE#で指定された固定小数点累積レジスタの要素のQNUMに応じたビット範囲について、指定範囲よりも下位の値に基づく確率的丸めが行われ、その結果が固定小数点値をDST#で指定されたレジスタに格納される。
The arithmetic
演算命令バッファ102は、演算命令列を格納する記憶領域である。演算命令バッファ102は、メモリコントローラ12から入力された演算命令列を指示されたアドレスから入力順に格納する。その後、演算命令制御部101からの演算命令の取得要求を受けて、演算命令バッファ102は、演算命令制御部101に要求されたアドレスの演算命令を出力する。
The
積和演算部100は、ベクタレジスタ111及び積和演算器112を有する。ただし、積和演算部100が有するベクタレジスタ111は、処理ユニット10に搭載されたベクタレジスタ全体の一部にあたる。
The product-
ベクタレジスタ111は、演算を実行する際に用いる演算データの入力をメモリコントローラ12から受けて、入力された演算データを格納する。その後、ベクタレジスタ111は、演算命令制御部101からの指示を受けて、演算で使用する演算データを積和演算器112に出力する。また、積和累積演算の場合、積和演算器112による演算のループ処理が完了後、ベクタレジスタ111は、確率的丸め処理が施された演算結果の入力を積和演算器112から受ける。そして、メモリ13への出力の指示をメモリコントローラ12から受けると、ベクタレジスタ111は、保持する確率的丸め処理が施された積和演算器112の演算結果をマルチプレクサ103へ出力する。
The
積和演算器112は、演算命令制御部101からの演算実行の指示を受ける。そして、積和演算器112は、ベクタレジスタ111から入力された演算データを用いて積和演算を実行する。その後、積和演算器112は、演算結果をベクタレジスタ111へ出力する。命令により累積を指示された場合は、積和演算器112は、累積演算結果を演算器内のレジスタ(アキュムレータ)に保持し、後続の累積演算命令で使用する。積和演算器112は、積和累積演算が完了するまでベクタレジスタ111から入力された値に対する積和演算を繰返す。
The product-
その後、積和累積演算のループ処理が終了すると、積和演算器112は、確率的丸め処理の実行の指示を演算命令制御部101から受ける。そのとき、積和演算器112は、小数点位置情報の入力を演算命令制御部101から受ける。そして、積和演算器112は、内部のレジスタに保持している、ループ処理が完了した演算結果を確率的丸め対象数として、積和演算を行う回路を用いて確率的丸め対象数に対する確率的丸め処理を実行する。その後、積和演算器112は、確率的丸め処理を施した演算結果をベクタレジスタ111へ出力し、格納させる。
After that, when the loop processing of the product-sum accumulation operation is completed, the product-
ここで、図2を参照して、積和演算器112の確率的丸めを行う機能について詳細に説明する。図2は、積和演算器の回路図である。
Here, with reference to FIG. 2, the function of performing the stochastic rounding of the multiply-accumulate
積和演算器112は、乱数生成回路121、冪乗数生成部122、マルチプレクサ123及び124、乗算器125、指数符号演算部126、桁合シフタ127、マルチプレクサ128、加算器129を有する。さらに、積和演算器112は、固定小数点レジスタ130、桁落量予測部131、シフト量算出部132、マルチプレクサ133、正規化シフタ134及び丸め回路135を有する。ここで、積和演算器112は、畳み込みなどのホストコンピュータ2が要求した実際の演算処理と、演算結果の確率的丸め値を算出する処理との2つの処理を行う。そこで、実際の演算処理を実演算といい、演算結果の確率的丸め値を算出する処理を確率的丸め処理という。
The product-
実演算における各部の動作を説明する。実演算の場合、マルチプレクサ124は、乗算を行う一方の演算データの入力を受ける。また、マルチプレクサ123は、乗算を行う他方の演算データの入力を受ける。この場合、マルチプレクサ123及び124は、演算データを乗算器125へ出力する。乗算器125は、マルチプレクサ123及び124から入力された2つの演算データを乗算する。そして、乗算器125は、乗算結果を加算器129へ出力する。
The operation of each part in the actual calculation will be described. In the case of an actual operation, the
一方、指数符号演算部126は、実演算に用いる3つの演算データの入力をベクタレジスタ111から受ける。そして、指数符号演算部126は、演算命令が浮動小数点の積和演算である場合に、積と加数の仮数どうしを桁合わせするためのシフト量を算出する。固定小数点演算命令の場合は、指数符号演算部126は、桁合わせするためシフト量を算出する。固定小数点演算命令の場合は、指数符号演算部126は、乗算結果の桁に加数の桁が合うようハードウェアにあらかじめ組み込まれた定数を桁合シフタのシフト量とする。また、指数符号演算部126は、演算結果の符号を算出する。そして、指数符号演算部126は、マルチプレクサ123及び124に入力された演算データ以外の残りの演算データ及びその演算データ(加数)と乗算器125の乗算結果とを桁合わせするためのシフト量を桁合シフタ127へ出力する。
On the other hand, the exponential
また、指数符号演算部126は、演算命令が浮動小数点の積和演算である場合、桁落ち量の予測結果の入力を桁落量予測部131から受ける。そして、指数符号演算部126は、取得した桁落ち量から、演算結果の仮数の正規化に用いる左シフト量を算出する。仮数の正規化とは、仮数の最上位桁が1になるように仮数全体のビット位置を調整(シフト)させることである。その後、指数符号演算部126は、算出した左シフト量をマルチプレクサ133へ出力する。
Further, when the operation instruction is a floating-point product-sum operation, the exponential
桁落量予測部131が求める桁落ち量は、回路構成により、本当の桁落ち量から、決まった範囲内の誤差を含む場合がある。正規化シフタ134で、指定された量のシフトをおこなった結果が、仮数の正規化が正しくなされているか否かを見ることで、予測した桁落ち量の誤差の有無を知ることができる。正規化シフタ134は、桁落ち量に誤差があったと分かった場合、調整のための追加のシフトをおこなうとともに、指数符号演算部に、予測に誤差があったことを通知する。指数符号演算部126は、正規化シフタ134から誤差あり通知を受けた場合、誤差調整のための追加シフトを考慮に入れた指数を算出する。これに対して、正規化シフタ134から誤差あり通知を受けない場合、指数符号演算部126は、追加シフトのない場合の指数を算出する。また、指数符号演算部126は、仮数の丸めで桁上がりが発生した場合、丸め回路135から通知を受け、指数を調整する。指数符号演算部126は、最終的に求まった符号と指数を出力し、これを後述する丸め回路135から出力される仮数の丸め結果と連接することで、浮動小数点演算結果が完成する。演算結果は、ベクタレジスタ111に出力される。
The digit loss amount obtained by the digit loss amount prediction unit 131 may include an error within a fixed range from the true digit loss amount depending on the circuit configuration. By seeing whether or not the mantissa is normalized correctly as a result of shifting the specified amount in the normalized
桁合シフタ127は、指数符号演算部126から指定されたシフト量だけ、指数符号演算部126から入力された演算データをシフトさせる。そして、桁合わせを行った演算データをマルチプレクサ128へ出力する。
The digit shifter 127 shifts the calculation data input from the exponential
マルチプレクサ128は、浮動小数点の実演算の場合、桁合シフタ127からの入力を選択する。固定小数点の累積演算で、累積途中の場合、加算対象の数は桁合わせの必要はないので、固定小数点レジスタ130からの入力を選択する。固定小数点の累積演算で、累積の初回の場合は、ベクタレジスタ111から積和演算器112に入力された数を加数として選択するため、桁合シフタ127からの入力を選択する。そして、マルチプレクサ128は、桁合シフタ127からの入力された演算データを加算器129へ出力する。
The
加算器129は、2つの演算データの乗算結果の入力を乗算器125から受ける。また、加算器129は、桁合わせされた残りの演算データ(加数)の入力をマルチプレクサ128から受ける。そして、加算器129は、2つの演算データの乗算結果と桁合わせされた残りの演算データ(加数)を加算する。そして、加算器129は、加算結果を正規化シフタ134及び桁落量予測部131へ出力する。ここで、実際には加算器129は加算結果信号及び桁上げ信号の2つの数を用いて、桁上げ保存加算と桁上げ伝搬加算という2段階の加算を行うが、本実施例では、この2段階の加算をまとめたものを単に加算とよぶ。そして、実際には、加算器129は、桁上げ保存加算の結果を桁落量予測部131へ出力する。
The
桁落量予測部131は、加算途中結果の入力を加算器129から受ける。そして、桁落量予測部131は、取得した加算途中結果から桁落ち量を予測する。その後、桁落量予測部131は、予測した桁落ち量を指数符号演算部126へ出力する。
The digit loss prediction unit 131 receives the input of the result during addition from the
マルチプレクサ133は、実演算の場合、指数符号演算部126からの入力を選択する。そして、マルチプレクサ133は、指数符号演算部126から入力された左シフト量を正規化シフタ134へ出力する。
In the case of an actual operation, the multiplexer 133 selects an input from the exponential
正規化シフタ134は、加算結果の入力を加算器129から受ける。また、正規化シフタ134は、左シフト量の入力をマルチプレクサ133から受ける。そして、正規化シフタ134は、入力された左シフト量に合わせて加算結果を左シフトさせて出力される位置を合わせる。その後、正規化シフタ134は、左シフトさせた演算結果を丸め回路135へ出力する。ここで、左シフトによる位置合わせで桁落ち量の予測に誤差があったと判明した場合、正規化シフタ134は、誤差調整のための追加シフトを行うとともに、誤差あり通知を指数符号演算部126に送信する。
The normalized
丸め回路135は、演算結果の入力を正規化シフタ134から受ける。そして、丸め回路135は、所定の桁数における丸めを実行する。その後、丸め回路135は、所定の桁で丸められた演算結果をベクタレジスタ111へ出力する。
The rounding circuit 135 receives the input of the calculation result from the normalized
次に、確率的丸め処理における各部の動作を説明する。確率的丸め処理の場合、乱数生成回路121が、nビットの一様乱数を生成する。そして、乱数生成回路121は、生成した乱数をマルチプレクサ123へ出力する。ここで、乱数生成回路121により生成される乱数は、真に一様な乱数でなくても、実用に耐え得る範囲の疑似乱数でよい。
Next, the operation of each part in the stochastic rounding process will be described. In the case of the stochastic rounding process, the random
乱数生成回路121は、例えば、積和演算器112内に配置されたLFSR(Linear Feedback Shift Register)を利用する。例えば、LFSRを用いる場合、本実施例では、確率的丸め命令を実行する毎にLFSRの内部状態が更新され、次の確率的丸め命令の発行時には、LFSRは新しい乱数値を出力する。
The random
ただし、乱数生成回路121は、LFSRに限らず、よりランダム性の高い疑似乱数発生回路でもよいし、環境の揺らぎからランダムビットを取得する回路でもよい。また、乱数生成回路121は、各積和演算器112に付随する回路であってもよいし、複数の積和演算器112で共有する回路であってもよい。この乱数生成回路121が、「乱数生成部」の一例にあたる。
However, the random
ここで、乱数のビット数の選び方について説明する。確率的に丸めを行う場合、最終的に確率的丸め対象数において丸め位置より下位にあるビットの値が捨てられる。例えば、乱数のビット数をnとし、捨てられるビット数をmとした場合、乱数が一様であれば、nがmと同じもしくはそれ以上であれば、確率的丸め後の期待値を確率的丸め対象数と等しい値にすることができる。しかし、mが多い場合でも同様にn≧mの関係を維持しようとすると、演算するビット数が多くなり、それに応じて桁合わせや加算を行う回路が大きくなる。あまり回路が大きくなると、既存の積和演算器112のハードウェアでは、使用するビット数の演算回路が収納が困難となる。その場合、不足する部分について、確率的丸めのために演算回路を付加するなどの対処は回路量が増加するため好ましくない。
Here, how to select the number of bits of a random number will be described. When rounding is performed stochastically, the value of the bit lower than the rounding position in the number of stochastic rounding targets is finally discarded. For example, when the number of bits of a random number is n and the number of bits to be discarded is m, if the random number is uniform, and if n is the same as or more than m, the expected value after stochastic rounding is stochastic. The value can be equal to the number of rounding targets. However, even when m is large, if the relationship of n ≧ m is to be maintained, the number of bits to be calculated increases, and the circuit for performing digit matching and addition increases accordingly. If the circuit becomes too large, it becomes difficult to store the arithmetic circuit of the number of bits to be used in the hardware of the existing multiply-accumulate
そこで、n≧mの関係を維持せず、nの方がmより小さくてもよいとすれば、既存の積和演算器112に収納できるだけのビット数にnをとどめておく方法が考えられる。その場合、捨てられるmビットのうち、丸め位置から下位にnビットよりさらに下位のビットについては、乱数との加算が行われず、丸め後の結果に寄与しないことになる。丸め後の期待値は、その分丸め前の値から乖離する。しかし、nを1増やすごとに期待値のずれは半分程度に縮小するため、ある程度以上にnを大きくすれば、mが大きいことによるずれは十分小さくなり、実用上は問題にならない。そのため、nは実用上の要件と既存の演算回路量に応じて妥当な値が決定されることが好ましい。
Therefore, if the relationship of n ≧ m is not maintained and n may be smaller than m, a method of keeping n in the number of bits that can be stored in the existing multiply-accumulate
確率的丸め処理の場合、マルチプレクサ123は、乱数生成回路121から入力されたnビットの一様乱数を選択する。そして、マルチプレクサ123は、nビットの一様乱数を乗算器125へ出力する。
In the case of stochastic rounding, the
冪乗数生成部122は、確率的丸め命令の入力を演算命令制御部101から受ける。同時に、冪乗数生成部122は、確率的丸め命令に含まれるオペランドの小数点位置情報を取得する。そして、冪乗数生成部122は、小数点位置情報を用いて丸めたい位置に応じた2の冪乗数を生成する。ここで、丸めたい位置とは、その桁の1つ上の桁が有効数字の桁となる桁にあたる。その後、冪乗数生成部122は、生成した2の冪乗数をマルチプレクサ124へ出力する。
The exponentiation generation unit 122 receives an input of a stochastic rounding instruction from the arithmetic
確率的丸め処理の場合、マルチプレクサ124は、冪乗数生成部122から入力された2の冪乗数を選択する。そして、マルチプレクサ124は、2の冪乗数を乗算器125へ出力する。
In the case of stochastic rounding, the
乗算器125は、nビットの一様乱数の入力をマルチプレクサ123から受ける。また、乗算器125は、丸めたい位置に応じた2の冪乗数の入力をマルチプレクサ124から受ける。そして、乗算器125は、取得した2の冪乗数を取得した乱数に乗算することで、乱数の先頭の桁を確率的丸め対象数における丸めたい位置に合わせる。
The
ここで、図3を参照して、本実施例に係る積和演算器112による確率的丸め処理の計算の概要を説明する。図3は、実施例に係る積和演算器による確率的丸め処理の計算の概要を表す図である。確率的丸め対象数200における位置Pは、丸め位置を表す。また、範囲Lは、演算結果として使用される範囲である。
Here, with reference to FIG. 3, the outline of the calculation of the stochastic rounding process by the product-
まず、乱数生成回路121により、nビットの一様乱数である乱数201が生成される。そして、乱数201は、乗算器125により、2の冪乗数が乗算され、乱数201の先頭が確率的丸め対象数200の丸め位置Pに一致するように乱数201が左シフトされる。この時、乱数201は丸め位置から下位にnビットの桁を有する乱数となる。
First, the random
ここで、図4を参照して、乱数の桁合わせシフトをさらに詳細に説明する。図4は、乱数の桁合わせシフトを説明するための図である。ここでは、乱数201が12ビットの乱数で且つ小数点以下3ビットの乱数である場合で説明する。また、固定小数アキュムレータ211(確率的丸め対象数)の小数点位置が最下位ビットの直ぐ右である場合で説明する。
Here, with reference to FIG. 4, the digit alignment shift of the random number will be described in more detail. FIG. 4 is a diagram for explaining the digit alignment shift of random numbers. Here, the case where the
乗算器125は、乱数201に2の冪数である2^Eを乗算することで、乱数をシフトする。ここで、小数点位置情報をQNUMとして表し、E=QNUM−9とする。QNUM=0で、乱数の全桁が、固定小数アキュムレータ211の最下位ビットより下に埋没する。また、QNUM=12の時、乱数の最下位桁が固定小数アキュムレータ211の最下位に合う位置となる。この場合、位置Dが小数点位置を表す。
The
図4において枠210は、単精度で24ビット×24ビットの乗算を行う乗算器125による乱数201のシフトを表す。図4において、12ビット乱数201Aが、QNUM=0の場合の位置である。ここで、この場合の乗算器125の最下位桁は、16ビットの固定小数で考えると2^−8にあたる。QNUM=0のときはE=−9であり、乗算器125は2^−9を乗算する処理を行うことになるが、乗算器125その桁の回路を有さない。しかし、QNUM=0の場合、乱数全桁が固定小数アキュムレータ211の最下位ビットより下位に埋没し、丸めでは切り捨てとなるため、乱数を足さなくてもよい。そこで、QNUM=0の場合、乗算器125は、乗算する値である2^Eを0とする。
In FIG. 4, the
QNUM=1の場合、E=−8となり、乗算器125は、12ビット乱数201Aに2^−8を乗算して、12ビット乱数201Aをシフトさせて12ビット乱数201Bとする。また、QNUM=8の場合、E=−1となり、乗算器125は、12ビット乱数201に2^−1を乗算して、12ビット乱数201Aをシフトさせて12ビット乱数201Cとする。また、QNUM=24の場合、E=15となり、乗算器125は、12ビット乱数201に2^15を乗算して、12ビット乱数201Aをシフトさせて12ビット乱数201Dとする。
When QNUM = 1, E = -8, and the
すなわち、固定小数アキュムレータ211の最下位側の16ビットであるデータ213を出力結果とする場合、QNUM=0となる。また、固定小数アキュムレータ211の最上位側の16ビットであるデータ212を出力結果とする場合、QNUM=24となる。すなわち、命令により与えられるQNUMにより、固定小数アキュムレータ211におけるどの位置の桁以上を有効数字とするかが決定される。そして、図4の場合、乗算器125は、0〜24の間の値を採るQNUMから求められた2の冪乗数を乱数201に乗算することで、固定小数アキュムレータ211における有効数字の最下位の桁の1つ下の桁に乱数201の先頭の位置を合わせる。
That is, when the
図2に戻って説明を続ける。乗算器125は、乗算結果である有効数字の最下位の桁の1つ下の桁に先頭の桁を合わせた乱数を加算器129へ出力する。この乗算器125が、「乱数移動部」の一例にあたる。
The explanation will be continued by returning to FIG. The
固定小数点レジスタ130は、積和累積演算で用いられる累積レジスタ(アキュムレータ)である。固定小数点レジスタ130は、確率的丸めの対象となる確率的丸め対象数を格納する。確率的丸め対象数は、実演算において算出された算出結果である。累積演算では、累積レジスタの値に乗算結果を加算していくため、固定小数点レジスタ130は、累積レジスタの値をセットするのに十分なビット幅を有する。そして、確率的丸め処理の場合、固定小数点レジスタ130は、確率的丸め対象数をマルチプレクサ128へ出力する。
The fixed-point register 130 is a cumulative register (accumulator) used in the product-sum accumulation operation. The fixed-point register 130 stores the number of stochastic rounding targets to be stochastic rounded. The number of stochastic rounding targets is the calculation result calculated in the actual calculation. Since the multiplication result is added to the value of the cumulative register in the cumulative operation, the fixed-point register 130 has a bit width sufficient to set the value of the cumulative register. Then, in the case of the stochastic rounding process, the fixed-point register 130 outputs the number of stochastic rounding targets to the
確率的丸め処理の場合、マルチプレクサ128は、固定小数点レジスタ130から入力された確率的丸め対象数を選択する。そして、マルチプレクサ128は、確率的丸め対象数を加算器129へ出力する。
In the case of stochastic rounding, the
加算器129は、有効数字の最下位の桁の1つ下の桁に先頭の桁を合わせた乱数の入力を乗算器125から受ける。また、加算器129は、確率的丸め対象数の入力をマルチプレクサ128から受ける。そして、加算器129は、確率的丸め対象数に乱数を加算する。これにより、確率的丸め対象数のうち乱数の先頭より下の桁の数に応じて確率的に繰り上げが行われる。すなわち、加算器129は、確率的丸め対象数に乱数を加算することで確率的丸めを行う。その後、加算器129は、加算結果を正規化シフタ134へ出力する。この加算器129が、「加算部」の一例にあたる。
The
ここで、図3を参照して、加算器129による確率的丸めの処理をさらに説明する。確率的丸め対象数200は、固定小数点レジスタ130から提供される。そして、範囲Lが丸め処理の結果として使用したい数値の範囲を表す。加算器129は、乗算器125により先頭位置が丸め位置であるPにシフトされた乱数201を確率的丸め対象数200に加算する。ここで、確率的丸め対象数200の最下位桁が乱数201の最下位桁よりも高い場合、加算器129は、確率的丸め対象数200に0の値のビットを付加して最下位桁を一致させた上で加算を行う。この加算により、丸め位置P以下の値に応じて確率的に桁上がりM1が発生した加算値202が得られる。
Here, with reference to FIG. 3, the process of stochastic rounding by the
ここで、桁上がりはおおよそ下の値に応じて確率的に発生する。これは、前述の通り乱数のビット数nの選び方によっては、確率的丸め結果の期待値が、丸め前の値からずれることがあり、そのずれ量はnの値により異なる。本実施例では、既存の単精度浮動小数点用の積和演算器112に収納可能な乗加算ビット数と、深層学習の収束シミュレーションに基づいた実用性の判断によりn=12とした。この場合、丸め後の期待値のずれは、最大で0.00025程度である。ただし、乱数のビット数はこれに限らず、演算に期待される要件と、既存回路や許容できる追加回路量のバランスに応じて、1以上の任意の妥当なビット数が選択されることが好ましい。
Here, the carry occurs stochastically according to the value below. This is because, as described above, the expected value of the stochastic rounding result may deviate from the value before rounding depending on how the number of bits n of the random number is selected, and the deviation amount differs depending on the value of n. In this embodiment, n = 12 is determined based on the number of multiply-accumulate bits that can be stored in the existing multiply-accumulate
図2に戻って説明を続ける。シフト量算出部132は、小数点位置情報の入力を演算命令制御部101から受ける。そして、シフト量算出部132は、小数点位置情報に応じたシフト量を算出する。具体的には、シフト量算出部132は、加算器129から出力されるデータのうち有効とするデータが配置されている位置から、正規化シフタの出力における有効データの位置への移動に用いるシフト量を、QNUM算出する。その後、シフト量算出部132は、算出したシフト量をマルチプレクサ133へ出力する。
The explanation will be continued by returning to FIG. The shift amount calculation unit 132 receives the input of the decimal point position information from the operation
確率的丸め処理の場合、マルチプレクサ133は、シフト量算出部132から入力されたシフト量を選択する。そして、マルチプレクサ133は、シフト量を正規化シフタ134へ出力する。
In the case of the stochastic rounding process, the multiplexer 133 selects the shift amount input from the shift amount calculation unit 132. Then, the multiplexer 133 outputs the shift amount to the normalized
正規化シフタ134は、確率的丸め処理が施された確率的丸め対象数の入力を加算器129から受ける。また、正規化シフタ134は、シフト量の入力をマルチプレクサ133から受ける。そして、正規化シフタ134は、確率的丸め対象数をシフト量に応じてシフトさせる。具体的には、正規化シフタ134は、入力された対象数のうち丸め位置のすぐ上の桁がちょうど積和演算器112から出力される有効な数の最下位桁に移動されるように左シフトをおこなう。正規化シフタ134は、左シフトを施した確率的丸め対象数を丸め回路135へ出力する。この正規化シフタ134が、「移動部」の一例にあたる。
The normalized
例えば、図3において、正規化シフタ134は、加算値202において演算結果として使用する範囲Lの最下位桁が出力されるデータの最下位桁に一致するように加算値202をシフトさせてシフト値203とする。
For example, in FIG. 3, the normalized
ここで、図5を参照して正規化シフタ134による加算値の位置合わせについて説明する。図5は、正規化シフタによる加算値の位置合わせを説明するための図である。
Here, the alignment of the added value by the normalized
図5では、以下の条件の場合を例に記載した。加算器129から、40ビットの加算値202が出力される。そして、加算器129から出力された値は、正規化シフタ134の出力前の中間バスのビット16からビット55までの位置にあたる。さらに、値の内16ビットのデータが出力される。そして、正規化シフタ134からデータが出力される演算結果バスのビット48からビット63までがデータとして出力される。
In FIG. 5, the case of the following conditions is described as an example. A 40-bit addition value 202 is output from the
正規化シフタ134は、加算値202を左シフトする。これにより、正規化シフタ134は、加算値202の使用される16ビットを演算結果バスのビット48からビット63にあたる出力位置214に移動させる。
The normalized
例えば、図5では、小数点位置情報を表す値をQNUMとしてQNUM=0の場合に、固定小数アキュムレータ211の最下位側の16ビットのデータ213が出力対象であるとする。この場合、QNUM=0であれば、正規化シフタ134は、中間結果バスのビット16からビット32までのデータ213を演算結果バスのビット48からビット63の出力位置214に移動させる。この場合、左シフト量は32である。また、QNUM=24の場合に、固定小数アキュムレータ211の最上位側の16ビットのデータ212が出力対象であるとする。この場合、QNUM=24であれば、正規化シフタ134は、中間結果バスのビット40からビット55までのデータ212を演算結果バスのビット48からビット63の出力位置214に移動させる。この場合、左シフト量は8である。すなわち、図5の例では、シフト量算出部132により「32−QNUM」として求められた左シフト量を用いて、正規化シフタ134は、左シフトを実行する。
For example, in FIG. 5, when the value representing the decimal point position information is QNUM and QNUM = 0, it is assumed that the 16-
図2に戻って説明を続ける。丸め回路135は、左シフトが施された確率的丸め対象数の入力を正規化シフタ134から受ける。そして、確率的丸め処理の場合、丸め回路135は、入力された確率的丸め対象数の所定桁より下の桁を打ち切る。そして、丸め回路135は、所定桁より下の桁を打ち切った確率的丸め対象数を出力する。丸め回路135からの出力が出力データとしてベクタレジスタ111に送られる。呼の丸め回路135が、「出力部」の一例にあたる。
The explanation will be continued by returning to FIG. The rounding circuit 135 receives an input of the number of stochastic rounding targets to which the left shift is applied from the normalized
例えば、図3において、丸め回路135は、シフト値203のうち使用する範囲Lよりも下位の桁に対して打ち切りM2を行う。そして、丸め回路135から出力されたデータの、使用する範囲Lよりも上位の桁である範囲204は、出力データ205には含まれず破棄される。そして、出力データ205が、ベクタレジスタ111に送られる。
For example, in FIG. 3, the rounding circuit 135 performs a truncation M2 on a digit lower than the range L used in the shift value 203. Then, the
ここで、丸め回路135は、通常の浮動小数点演算の回路である。浮動小数点演算の通常の丸めでは、下位桁から得られる丸めビットやstickyビット、丸め最下位桁の値、演算結果の正負及び指定された丸めモードに基づき、丸め回路135は、入力値に対して以下の2処理のいずれかを行う。第1の処理は、丸め回路135は、入力値の丸め位置より下を打ち切った値をそのまま出力する処理である。第2の処理は、丸め回路135は、入力値の丸め位置より下を打ち切った値に1を加算して出力する処理である。確率的丸め処理を実行する場合、丸め回路135は、上述した第1の処理を常に選択するように論理が指定される。 Here, the rounding circuit 135 is a circuit for ordinary floating-point arithmetic. In normal rounding of floating-point operations, the rounding circuit 135 is based on the rounding bit or sticky bit obtained from the lower digit, the value of the least significant rounding digit, the positive or negative of the operation result, and the specified rounding mode. Perform one of the following two processes. The first process is a process in which the rounding circuit 135 outputs the value cut off below the rounding position of the input value as it is. The second process is a process in which the rounding circuit 135 adds 1 to the value cut off below the rounding position of the input value and outputs the input value. When performing the stochastic rounding process, the rounding circuit 135 is logically designated to always select the first process described above.
次に、図6を参照して、具体的なデータを用いて確率的丸め処理について説明する。図6は、確率的丸め処理についての具体例を表す図である。図6では、64ビットの幅のバスを用いて処理を行う場合で説明する。また、各データの位置を[x:y]と表し、xが最上位ビット、yが最下位ビットを表すものとして説明する。 Next, with reference to FIG. 6, the stochastic rounding process will be described using specific data. FIG. 6 is a diagram showing a specific example of the stochastic rounding process. FIG. 6 describes a case where processing is performed using a bus having a width of 64 bits. Further, the position of each data is represented as [x: y], where x represents the most significant bit and y represents the least significant bit.
この場合、演算命令制御部101は、小数点位置情報としてQNUM=16を出力する。固定小数点レジスタ130から出力された確率的丸め対象数300は、[55:16]に位置する。ここで、ビット15以下が、小数点以下にあたる。そして、確率的丸め対象数300のうちビット31以下は丸められ、[47:32]が使用される範囲である。
In this case, the arithmetic
乱数生成回路121により生成された乱数301は、論理的には、小数点以下がビット15以下となるように配置され、破線で囲われた場所に位置する。実際には、乱数301は、QNUM=0の場合の位置に回路上の初期位置として配置される。QNUM=0の場合の位置は、具体的には、確率的丸め対象数300の最下位ビットの次のビットに乱数301の先頭のビットが来る位置である。そして、冪乗数生成部122は、QNUM=16に応じた2の冪乗数として2^7を求める。乗算器125は、乱数に2^7を乗算して乱数301を[31:20]の位置にシフトさせる。
The
加算器129は、[31:20]に位置する乱数301に確率的丸め対象数300と最下位ビットが一致するように0の値のビットを付加して、確率的丸め対象数300に加算し、加算値302を算出する。加算値302は、[55:16]に位置する。ここで、出力範囲303は[63:48]である。
The
そこで、正規化シフタ134は、確率的丸め対象数300における使用される範囲[47:32]のデータが[63:48]に位置するように確率的丸め対象数300をシフトさせる。
Therefore, the normalized
その後、丸め回路135により、シフト後の確率的丸め対象数300におけるビット49以下が打ち切られ破棄される。さらに、シフト後の確率的丸め対象数300におけるビット64以上が出力されず破棄される。これにより、残った16ビットの出力データ304が演算結果として出力される。
After that, the rounding circuit 135 cuts off and discards bits 49 or less in the stochastic rounding
次に、図7を参照して、積和演算部100が実行する処理の全体的な流れを説明する。図7は、積和演算部が実行する処理全体のフローチャートである。
Next, with reference to FIG. 7, the overall flow of processing executed by the product-
積和演算部100は、積和演算器112を用いて実演算における積和演算を実行する(ステップS1)。
The product-
そして、積和演算部100は、積和累積演算が完了したか否かを判定する(ステップS2)。積和累積演算が完了していない場合(ステップS2:否定)、積和演算部100は、ステップS1へ戻り積和演算を繰返す。
Then, the product-
これに対して、積和累積演算が完了した場合(ステップS2:肯定)、積和演算部100は、積和演算器112を用いて確率的丸め処理を実行する(ステップS3)。
On the other hand, when the product-sum accumulation calculation is completed (step S2: affirmative), the product-
その後、メモリコントローラ12からの指示にしたがい、ベクタレジスタ111に格納された演算結果は、処理ユニットのチェーンとメモリコントローラ12とを経由してメモリ13に出力される(ステップS4)。
After that, according to the instruction from the
次に、図8を参照して、本実施例に係る積和演算器による確率的丸め処理の流れを説明する。図8は、実施例に係る積和演算器112による確率的丸め処理のフローチャートである。図8のフローチャートで示した処理は、図7のステップS3で行われる処理の一例にあたる。
Next, with reference to FIG. 8, the flow of the stochastic rounding process by the product-sum calculator according to the present embodiment will be described. FIG. 8 is a flowchart of the stochastic rounding process by the product-
乱数生成回路121は、n桁の一様な乱数を取得する(ステップS101)。そして、乱数生成回路121は、生成した乱数をマルチプレクサ123を介して乗算器125へ出力する。
The random
また、冪乗数生成部122は、QNUMに応じた2の冪乗数を生成する(ステップS102)。そして、乱数生成回路121は、生成した2の冪乗数をマルチプレクサ124を介して乗算器125へ出力する。
Further, the power generation unit 122 generates a power of 2 according to the QNUM (step S102). Then, the random
乗算器125は、乱数の入力を乱数生成回路121から受ける。また、乗算器125は、QNUMに応じた2の冪乗数の入力をマルチプレクサ124から受ける。そして、乗算器125は、乱数と2の冪乗数とを乗算して乱数の先頭が丸め位置に位置するように乱数をシフトさせる(ステップS103)。その後、乗算器125は、乗算結果を加算器129へ出力する。
The
加算器129は、マルチプレクサ128を介して、固定小数点レジスタ130に格納された確率的丸め対象数を取得する(ステップS104)。
The
また、加算器129は、乗算結果の入力を乗算器125から受ける。そして、加算器129は、確率的丸め対象数に乗算器125による乗算結果を加算して確率的丸めを実行する(ステップS105)。その後、加算器129は、確率的丸めの処理を施した確率的丸め対象数を表す加算結果を正規化シフタ134へ出力する。
Further, the
シフト量算出部132は、演算命令制御部101から取得した小数点位置情報に応じたシフト量を算出する(ステップS106)。そして、シフト量算出部132は、算出したシフト量をマルチプレクサ133を介して正規化シフタ134へ出力する。
The shift amount calculation unit 132 calculates the shift amount according to the decimal point position information acquired from the operation instruction control unit 101 (step S106). Then, the shift amount calculation unit 132 outputs the calculated shift amount to the normalized
正規化シフタ134は、確率的丸めの処理を施した確率的丸め対象数を表す加算結果の入力を加算器129から受ける。また、正規化シフタ134は、シフト量の入力をシフト量算出部132から受ける。そして、加算結果をシフト量分左シフトする(ステップS107)。そして、正規化シフタ134は、左シフトした値を丸め回路135へ出力する。
The normalized
丸め回路135は、左シフトされた値の入力を正規化シフタ134から受ける。そして、丸め回路135は、左シフトされた値の所定桁以下を打ち切り出力範囲以下のビットを破棄する(ステップS108)。
The rounding circuit 135 receives an input of a left-shifted value from the normalized
その後、丸め回路135から、下位から所定のビット数が結果として出力される(ステップS109)。 After that, a predetermined number of bits is output as a result from the lower order from the rounding circuit 135 (step S109).
本実施例に係る積和演算器112は、浮動小数点の演算を行う回路に、乱数生成回路121、冪乗数生成回路122、シフト量算出部132、並びに、マルチプレクサ123、124及び133を追加することで、固定小数点を用いた確率的丸め処理を実行する。
The product-
以上に説明したように、本実施例に係る積和演算器112は、浮動小数点の積和演算に用いる回路に対して少量の回路追加を行うことで、固定小数点の確率的丸めが実行可能となる。また、本実施例に係る積和演算器112は、乗算の累積演算結果に対する確率的丸めを実行する。したがって、簡易な構成で適切な確率的丸めを実行することができる。
As described above, the multiply-accumulate
1 PCIカード
2 ホストコンピュータ
10 処理ユニット
11 全体命令制御部
12 メモリコントローラ
13 メモリ
14 PCI制御部
50 情報処理装置
100 積和演算部
101 演算命令制御部
102 演算命令バッファ
103 マルチプレクサ
111 ベクタレジスタ
112 積和演算器
121 乱数生成回路
122 冪乗数生成部
125 乗算器
126 指数符号演算部
127 桁合シフタ
129 加算器
130 固定小数点レジスタ
131 桁落量予測部
132 シフト量算出部
134 正規化シフタ
135 丸め回路
123,124,128,133 マルチプレクサ1
125
Claims (5)
丸め対象数が配置される所定位置及び出力データの小数点位置情報を基に、前記乱数の先頭が前記丸め対象数の丸め位置に一致するように前記乱数の位置を移動する乱数移動部と、
前記乱数移動部により移動された前記乱数と前記所定位置に配置された前記丸め対象数とを加算する加算部と、
前記加算部による加算結果における前記丸め位置から所定桁の有効数字を含む所定範囲のデータを前記出力データとして出力する出力部と
を備えたことを特徴とする演算処理装置。A random number generator that generates random numbers, and a random number generator
A random number moving unit that moves the position of the random number so that the beginning of the random number matches the rounding position of the number of rounding targets based on the predetermined position where the number of rounding targets is arranged and the decimal point position information of the output data.
An addition unit that adds the random number moved by the random number movement unit and the number of rounding targets arranged at the predetermined positions, and an addition unit.
An arithmetic processing unit including an output unit that outputs data in a predetermined range including significant figures of a predetermined digit from the rounded position in the addition result by the addition unit as the output data.
前記出力部は、前記丸め位置から前記所定桁の前記有効数字が前記出力位置に一致するように移動された前記加算結果の前記出力位置以外の値を破棄して出力する
ことを特徴とする請求項1に記載の演算処理装置。Further provided is a moving unit that moves the significant digit of the predetermined digit from the rounding position in the addition result by the addition unit so as to match the output position of the predetermined digit.
The claim is characterized in that the output unit discards and outputs a value other than the output position of the addition result in which the significant digit of the predetermined digit is moved from the rounding position so as to match the output position. Item 1. The arithmetic processing unit according to item 1.
前記乱数生成部は、2進数で表される乱数を生成し
前記乱数移動部は、前記冪乗数生成部により求められた前記冪乗数を前記乱数に乗算することで前記乱数の位置を移動する
ことを特徴とする請求項1に記載の演算処理装置。A power generation unit for obtaining a power of 2 for matching the beginning of the random number with the rounding position of the rounding target number based on the position where the rounding target number is arranged and the decimal point position information of the output data. Further prepare,
The random number generation unit generates a random number represented by a binary number, and the random number moving unit moves the position of the random number by multiplying the random number by the power obtained by the power generation unit. The arithmetic processing apparatus according to claim 1.
前記加算部は、前記乱数移動部による乗算結果に対して入力されたデータを加算して浮動小数点演算を行う
ことを特徴とする請求項1に記載の演算処理装置。The random number moving unit multiplies the two input data to perform a floating point operation.
The arithmetic processing apparatus according to claim 1, wherein the addition unit adds data input to a multiplication result by the random number movement unit to perform a floating-point operation.
丸め対象数が配置される所定位置及び出力データの小数点位置情報を基に、前記乱数の先頭が前記丸め対象数の丸め位置に一致するように前記乱数の位置を移動し、
移動した前記乱数と前記所定位置に配置された前記丸め対象数とを加算し、
加算結果の前記丸め位置から所定桁の有効数字を含むデータを前記出力データとして出力する
ことを特徴とする演算処理装置の制御方法。Generate random numbers,
Based on the predetermined position where the number of rounding targets is placed and the decimal point position information of the output data, the position of the random number is moved so that the beginning of the random number matches the rounding position of the number of rounding targets.
The moved random number and the number of rounding targets placed at the predetermined positions are added.
A control method of an arithmetic processing unit, characterized in that data including significant digits of a predetermined digit is output as the output data from the rounded position of the addition result.
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/JP2018/039370 WO2020084692A1 (en) | 2018-10-23 | 2018-10-23 | Computation processing device and computation processing device control method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPWO2020084692A1 JPWO2020084692A1 (en) | 2021-09-02 |
| JP6984762B2 true JP6984762B2 (en) | 2021-12-22 |
Family
ID=70331786
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2020551748A Active JP6984762B2 (en) | 2018-10-23 | 2018-10-23 | Arithmetic processing unit and control method of arithmetic processing unit |
Country Status (2)
| Country | Link |
|---|---|
| JP (1) | JP6984762B2 (en) |
| WO (1) | WO2020084692A1 (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US12554489B2 (en) * | 2021-03-25 | 2026-02-17 | Intel Corporation | Supporting 8-bit floating point format operands in a computing architecture |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS62260229A (en) * | 1986-05-06 | 1987-11-12 | Yamaha Corp | Multiplying circuit |
| JP2009010489A (en) * | 2007-06-26 | 2009-01-15 | Fujifilm Corp | Image processing apparatus and image processing method |
| US10552370B2 (en) * | 2015-10-08 | 2020-02-04 | Via Alliance Semiconductor Co., Ltd. | Neural network unit with output buffer feedback for performing recurrent neural network computations |
-
2018
- 2018-10-23 JP JP2020551748A patent/JP6984762B2/en active Active
- 2018-10-23 WO PCT/JP2018/039370 patent/WO2020084692A1/en not_active Ceased
Also Published As
| Publication number | Publication date |
|---|---|
| WO2020084692A1 (en) | 2020-04-30 |
| JPWO2020084692A1 (en) | 2021-09-02 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Demmel et al. | Parallel reproducible summation | |
| TWI438678B (en) | Method, system, and computer program product for large number multiplication | |
| KR100323338B1 (en) | Sticky bit calculation circuit for floating point division / square root operation | |
| KR101533516B1 (en) | Multiply add functional unit capable of executing scale, round, getexp, round, getmant, reduce, range and class instructions | |
| KR102697307B1 (en) | Stochastic rounding logic | |
| JP2000347832A (en) | Floating-point operation method, floating-point operation device, and semiconductor integrated circuit device having the same | |
| CN109284827A (en) | Neural network computing method, device, processor and computer-readable storage medium | |
| JPH0969040A (en) | Circuit for radix-2 square root operation / division by three overlapping stages with speculative operation | |
| US20180217815A1 (en) | Apparatus and method for processing input operand values | |
| EP4231135A1 (en) | Method and system for calculating dot products | |
| JP6984762B2 (en) | Arithmetic processing unit and control method of arithmetic processing unit | |
| EP0550188A2 (en) | Arithmetic system for performing integer power calculations | |
| EP1335278A2 (en) | Higher precision divide and square root approximations | |
| US20200311545A1 (en) | Information processor, information processing method, and storage medium | |
| US5867413A (en) | Fast method of floating-point multiplication and accumulation | |
| US20200249942A1 (en) | Anchored data element conversion | |
| JP2022034897A (en) | Information processing device, machine learning method and machine learning program | |
| JP7036224B2 (en) | Arithmetic processing unit and control method of arithmetic processing unit | |
| EP4345600A1 (en) | Multiplication hardware block with adaptive fidelity control system | |
| US6529924B1 (en) | Method and apparatus for generating shift amount signals for an alignment shifter | |
| US20210224040A1 (en) | Arithmetic processing apparatus and control method for arithmetic processing apparatus | |
| JPWO2002029546A1 (en) | Arithmetic unit and electronic circuit device using the same | |
| JP7371499B2 (en) | Arithmetic processing unit, control method for the arithmetic processing unit, and arithmetic processing program | |
| US20240211211A1 (en) | Mac apparatus using floating point unit and control method thereof | |
| JP2002358196A (en) | Method for calculating reciprocal of square root, calculating circuit and program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20210224 |
|
| 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: 20211026 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20211108 |
|
| R150 | Certificate of patent or registration of utility model |
Ref document number: 6984762 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |