JPH0748207B2 - Matrix operation device - Google Patents
Matrix operation deviceInfo
- Publication number
- JPH0748207B2 JPH0748207B2 JP1096079A JP9607989A JPH0748207B2 JP H0748207 B2 JPH0748207 B2 JP H0748207B2 JP 1096079 A JP1096079 A JP 1096079A JP 9607989 A JP9607989 A JP 9607989A JP H0748207 B2 JPH0748207 B2 JP H0748207B2
- Authority
- JP
- Japan
- Prior art keywords
- matrix
- memory
- zero
- elements
- data
- 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.)
- Expired - Fee Related
Links
Landscapes
- Complex Calculations (AREA)
Description
【発明の詳細な説明】 〈産業上の利用分野〉 この発明は、零成分を多く含む行列(スパース行列)と
ベクトルとの演算に適した行列演算装置に関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a matrix computing device suitable for computing a matrix (sparse matrix) containing many zero components and a vector.
〈従来の技術〉 自然界における現象を計算機を用いてシュミレーション
する場合、2次元配列で表わされる行列を変換行列とし
て、1次元配列で表わされるベクトルの1次変換を計算
することが多い。例えば、次式(1),(2)に示すよ
うな行列演算が挙げられる。<Prior Art> When simulating a phenomenon in nature using a computer, a matrix represented by a two-dimensional array is often used as a conversion matrix to perform a primary transformation of a vector represented by a one-dimensional array. For example, the matrix calculation as shown in the following equations (1) and (2) can be given.
y=Wx …(1) vt=utW …(2) ここで、x=(x1,x2,x3,…,xM)tは入力ベクトル、y
=(y1,y2,y3,…,yN)tは出力ベクトル、W={Wji}は
一次変換のためのN行M列の変換行列、u=(u1,u2,
u3,…,uN)tは入力ベクトル、v=(v1,v2,v3,…,vM)t
は出力ベクトル、(*)tは行と列を入れ換えた転置行
列を示している。y = Wx (1) v t = u t W (2) where x = (x 1 , x 2 , x 3 , ..., x M ) t is the input vector, y
= (Y 1, y 2, y 3, ..., y N) t is output vector, W = {Wji} is the transformation matrix of N rows and M columns for the linear transformation, u = (u 1, u 2,
u 3 , ..., u N ) t is the input vector, v = (v 1 , v 2 , v 3 , ..., v M ) t
Indicates an output vector, and (*) t indicates a transposed matrix in which rows and columns are interchanged.
従来のベクトルプロセッサなどの行列演算装置は、上記
変換行列Wの各要素Wjiを表わすデータを記憶するメモ
リと、この要素Wjiと入力ベクトルの要素との積和の計
算アルゴリズムを記憶する記憶手段と、この計算アルゴ
リズムに従って計算する演算手段とを備えて、(1)式
の計算のとき出力yj(j=1,2,…,N)を、次式(3)に
従って計算するようにしている。A matrix operation device such as a conventional vector processor has a memory for storing data representing each element Wji of the transformation matrix W, and a storage means for storing a calculation algorithm of a product sum of the element Wji and an element of an input vector. The output yj (j = 1, 2, ..., N) at the time of the calculation of the formula (1) is provided according to the following formula (3).
また(2)式の計算のとき各列の出力vi(i=1,2,…,
M)を、次式(4)に従って計算するようにしている。 Further, when calculating the equation (2), the output v i (i = 1, 2, ..., Of each column)
M) is calculated according to the following equation (4).
なお、これら式(3),(4)の計算を模式的に示すと
それぞれ第16図、第17図のようになる。 Note that the calculations of these equations (3) and (4) are schematically shown in FIGS. 16 and 17, respectively.
〈発明が解決しようとする課題〉 ところで、上記行列演算を現実の問題に適用するにあた
って、上記変換行列Wの要素Wjiのうち零である要素
(以下、「零要素」と呼ぶ)の占める割合が大きくなる
場合がある。たとえば、神経回路網のシュミレーション
において、一方の神経回路素子群が他方の神経回路素子
群から受け取る伝達信号は、送り手の各素子の出力を入
力ベクトルxとし、送り手側の各素子から受け手側の各
素子への結合の強さ(結合係数)を変換行列Wとした一
次変換y=Wxと考えることができるが、このとき、すべ
ての神経回路素子間が接続されていることは稀であっ
て、逆に、各素子間の結合係数すなわち変換行列Wの要
素のうち大部分が零要素である(スパース行列である)
場合が多い。この傾向は神経回路網が大規模になるほど
強くなる。<Problems to be Solved by the Invention> By the way, in applying the above matrix operation to a real problem, the proportion of zero elements (hereinafter, referred to as “zero elements”) among the elements Wji of the transformation matrix W is It can grow. For example, in a simulation of a neural network, a transmission signal that one neural circuit element group receives from the other neural circuit element group is such that the output of each element of the sender is an input vector x and each element on the sender side receives from the receiver side. It can be considered as a linear transformation y = Wx in which the coupling strength (coupling coefficient) to each element of is a transformation matrix W, but at this time, it is rare that all neural circuit elements are connected. On the contrary, most of the coupling coefficients between the elements, that is, the elements of the transformation matrix W are zero elements (a sparse matrix).
In many cases. This tendency becomes stronger as the neural network becomes larger.
このような場合、上記従来の演算処理装置は、零でない
要素(以下、「非零要素」と呼ぶ)が多い行列を取り扱
う場合と同様に、上記N行M列の変換行列Wの各要素Wj
iをそのままN×M個の実数としてメモリに割り当てて
記憶する必要があり、また、上記行列演算処理1回につ
き乗算と加算とをN×M回ずつ行なっている。このた
め、零要素を記憶・計算する無駄が生じていると考えら
れる。In such a case, the above-mentioned conventional arithmetic processing device treats each element Wj of the conversion matrix W of N rows and M columns as in the case of handling a matrix having many non-zero elements (hereinafter referred to as “non-zero elements”).
It is necessary to allocate and store i as N × M real numbers in the memory as it is, and the multiplication and addition are performed N × M times for each matrix calculation process. Therefore, it is considered that there is a waste of storing and calculating the zero element.
そこで、スパース行列の非零要素からなるデータ列を格
納した行列メモリと、上記スパース行列内での各非零要
素の位置情報を記憶したインデックスメモリを備えて、
上記インデックスメモリの位置情報を参照しつつ上記ス
パース行列の非零要素のみと入力ベクトルの要素との積
和を演算する線形変換方式が提案されている(特開昭53
-64439号公報)。この線形変換方式によれば、メモリの
記憶量と計算量を低減することができる。Therefore, with a matrix memory that stores a data string consisting of non-zero elements of a sparse matrix, and an index memory that stores the position information of each non-zero element in the sparse matrix,
A linear conversion method has been proposed which calculates the sum of products of only the non-zero elements of the sparse matrix and the elements of the input vector while referring to the position information of the index memory (Japanese Patent Laid-Open No. 53-53115)
-64439 publication). According to this linear conversion method, the storage amount and calculation amount of the memory can be reduced.
しかしながら、この線形変換方式では、インデックスメ
モリに位置情報として行番号を表す整数と列番号を表す
整数とを格納しているため、行列メモリの非零要素を読
み出すためには、別途アドレスコントローラによって上
記インデックスメモリの内容に基づいてアドレスを指定
しなければならない。つまり、行列メモリのアドレスを
指定するために複雑な制御を行わなければならないとい
う問題がある。However, in this linear conversion method, since an integer representing a row number and an integer representing a column number are stored as position information in the index memory, in order to read the non-zero element of the matrix memory, the address controller separately uses The address must be specified based on the contents of the index memory. That is, there is a problem that complicated control must be performed to specify the address of the matrix memory.
そこで、この発明の目的は、大規模なスパース行列演算
処理を行なうときにメモリの記憶量と計算量を低減する
ことができる上、簡単に制御できる行列演算装置を提供
することにある。Therefore, an object of the present invention is to provide a matrix calculation device that can reduce the memory storage amount and calculation amount when performing a large-scale sparse matrix calculation process and can be easily controlled.
〈課題を解決するための手段〉 上記目的を達成するために、この発明の行列演算装置
は、2次元配列で表わされる行列の各要素について零で
ある要素か零でない要素かを特定するデータを格納する
第1のメモリと、上記行列の零でない要素の内容を表わ
すデータを格納する第2のメモリと、上記第1のメモリ
に格納されたデータを参照して、上記行列の要素が零で
あるか否かを判別する判別手段と、上記判別手段によっ
て零でないと判別された行列の要素について、上記第2
のメモリに格納されたデータと入力ベクトルの要素とを
乗算して、積和を求める演算手段を備えた行列演算装置
において、上記第1のメモリは、上記行列内で、零であ
る要素が連続して並ぶ数を表わす整数と、零でない要素
が連続して並ぶ数を表す整数とを、上記行列内の各連続
する並びの順に格納していることを特徴としている。<Means for Solving the Problem> In order to achieve the above-mentioned object, the matrix operation device of the present invention provides data for specifying whether each element of a matrix represented by a two-dimensional array is zero or non-zero. Referring to the first memory for storing, the second memory for storing the data representing the content of the non-zero element of the matrix, and the data stored in the first memory, the elements of the matrix are zero. Regarding the discriminating means for discriminating whether or not there is any, and the elements of the matrix discriminated as non-zero by the discriminating means, the second
In the matrix operation device provided with the operation means for multiplying the data stored in the memory and the element of the input vector to obtain the sum of products, in the first memory, the elements having zero in the matrix are consecutive. It is characterized in that an integer representing the number arranged in parallel and an integer representing the number in which non-zero elements are arranged consecutively are stored in the order of each continuous arrangement in the matrix.
〈作用〉 上記判別手段によって第1のメモリに格納されたデータ
を参照して、参照した上記行列の要素が零であるとき
は、何ら計算を行なうことなく、次の要素の参照を続け
る。そして、参照した要素が零でないとき、上記演算手
段によって上記第2のメモリに格納されたデータと、入
力ベクトルのこのデータに対応する要素とを乗算する。
1つの行または列について、この積和を計算して、出力
ベクトルの1つの要素とする。そして、各行または各列
について、この計算を行なって、出力ベクトルの全要素
を求める。<Operation> Referring to the data stored in the first memory by the discriminating means, when the element of the referred matrix is zero, the next element is continuously referred without performing any calculation. Then, when the referenced element is not zero, the data stored in the second memory by the computing means is multiplied by the element corresponding to this data of the input vector.
This sum of products is calculated for one row or column to be one element of the output vector. Then, this calculation is performed for each row or each column to obtain all the elements of the output vector.
このように行列演算処理を行なう場合、例えば上記行列
の全要素(N×M個の実数)のうち非零要素の占める割
合がk%であるとき、この行列の要素を記憶するための
上記第2のメモリの記憶量は、実数にしてN×M×k/10
0個分となる。また、上記行列演算処理1回につき乗算
と加算を行なう回数は、それぞれN×M×k/100とな
る。したがって、非零要素の占める割合が少ない(kが
小さい)ときに、上記行列の要素の記憶量と上記演算処
理の計算量が低減される。When the matrix calculation process is performed in this way, for example, when the non-zero element occupies k% of all elements (N × M real numbers) of the matrix, the first element for storing the element of the matrix is stored. The memory capacity of memory 2 is N × M × k / 10 in real numbers.
It will be 0. Further, the number of times multiplication and addition are performed per matrix operation processing is N × M × k / 100. Therefore, when the ratio of non-zero elements is small (k is small), the storage amount of elements of the matrix and the calculation amount of the arithmetic processing are reduced.
しかも、上記第1のメモリは、上記行列内で、零である
要素が連続して並ぶ数を表わす整数と、零でない要素が
連続して並ぶ数を表す整数とを、上記行列内の各連続す
る並びの順に格納しているので、第2のメモリの内容を
読み出すときにそのアドレス指定が簡単に行われる。す
なわち、第1のメモリを例えばポインタによって順にス
キャンして、非零要素が並ぶ数を表す整数が検出された
とき、この整数分だけ順に第2のメモリに格納された非
零要素の内容を表すデータを読み出せば良い。このよう
に、第1のメモリの内容検出と、第2のメモリの内容読
み出しとを並行して進めることによって、簡単に第2の
メモリのアドレス指定が行われる。この結果、この行列
演算装置の制御は簡単に行われる。Moreover, the first memory stores an integer representing the number of consecutive zero elements in the matrix and an integer representing the number of consecutive non-zero elements in each matrix. Since the contents are stored in the order of arrangement, the addressing is easily performed when reading the contents of the second memory. That is, when the first memory is sequentially scanned by, for example, a pointer, and an integer representing the number of non-zero elements arranged is detected, the contents of the non-zero elements stored in the second memory are sequentially represented by this integer. Just read the data. In this manner, the addressing of the second memory is easily performed by advancing the content detection of the first memory and the content reading of the second memory in parallel. As a result, the control of this matrix operation device is easily performed.
〈実施例〉 以下、この発明の行列演算装置を実施例により詳細に説
明する。<Embodiment> Hereinafter, the matrix calculation device of the present invention will be described in detail with reference to an embodiment.
第1図はこの発明の基礎となる第1の行列演算装置を示
している。この行列演算装置は、CPU(中央演算処理装
置)1と、所定の計算アルゴリズムを記憶するROM2と、
変換行列Wについての情報を記憶する第1のメモリ11お
よび第2のメモリ12と、入力ベクトルx=(x1,…,xj,
…,xM)tまたはu=(u1,…,uj,…uN)tの情報を入力
する入力装置21と、出力ベクトルy=(y1,…,yj,…
yN)tまたはv=(v1,…,vj,…,vM)tの情報を出力す
る出力装置22を備えている。FIG. 1 shows a first matrix operation device which is the basis of the present invention. This matrix operation device includes a CPU (central processing unit) 1, a ROM 2 for storing a predetermined calculation algorithm,
A first memory 11 and a second memory 12 that store information about a transformation matrix W, and an input vector x = (x 1 , ..., Xj,
, X M ) t or u = (u 1 , ..., uj, ... u N ) t , and the output vector y = (y 1 , ..., yj, ...
An output device 22 for outputting information of y N ) t or v = (v 1 , ..., Vj, ..., V M ) t is provided.
上記CPU1は、上記入力装置21から入力ベクトルxの各要
素を表わすデータを受けて、上記第1のメモリ11および
第2のメモリ12を参照し、ROM2が記憶する計算アルゴリ
ズムに従って、上記入力ベクトルxまたはuの一次変換
を計算して、出力ベクトルyまたはvを表わすデータを
上記出力装置22に出力することができる。第7図に示す
ように、上記入力装置21は、入力ベクトルxの各要素xi
を表わすデータを保持可能な入力バッファ302およびこ
の入力バッファ302の各データXTxp(xp=1,2,…,M)を
指すポインタ(指示値xp)306と、入力ベクトルuの各
要素ujを表わすデータを保持可能な入力バッファ304お
よびこの入力バッファ304の各データUTup(up=1,2,…
N)を指すポインタ(指示値up)308とからなってい
る。上記出力装置22は、出力ベクトルyの各要素tjを表
わすデータを保持可能な積和演算バッファ兼用の出力バ
ッフア303およびこの出力バッフア303の各データYTyp
(yp=1,2,…,N)を指すポインタ(指示値yp)307と、
出力ベクトルvの各要素viを表わすデータを保持可能な
積和演算バッファ兼用の出力バッフア305およびこの出
力バッフア305の各データVTvp(vp=1,2,…M)を指す
ポインタ(指示値vp)309とからなっている。なお、第
7図中の301は、この行列演算装置の機能を説明するた
めに、例として変換行列Wの各要素Wjiを2次元配列に
よって表わしたものである。図中、“0"はWji=0であ
る零要素、“W"はWji≠0である非零要素を表わしてい
る。また、piは零要素が行方向に並ぶ数、qiは非零要素
が行方向に並ぶ数を表わしている。第2図に示すよう
に、上記第1のメモリ11は、上記変換行列Wの零要素が
連続して並ぶ数を表わす整数を記憶しているインデック
ステーブル401と、このインデックステーブル401の各デ
ータITip(ip=1,2,…)を指すポインタ(指示値ip)40
3とからなっている。一方、第3図に示すように、上記
第2のメモリ12は、上記変換行列Wの非零要素の内容を
表わすデータを順に格納している係数メモリ402と、こ
の係数メモリ402の各データWTwp(wp=1,2,…)を指す
ポインタ(指示値wp)404とからなっている。The CPU 1 receives data representing each element of the input vector x from the input device 21, refers to the first memory 11 and the second memory 12, and according to the calculation algorithm stored in the ROM 2, the input vector x Alternatively, the linear transformation of u can be calculated and the data representing the output vector y or v can be output to the output device 22. As shown in FIG. 7, the input device 21 uses the elements xi of the input vector x.
Represents an input buffer 302 capable of holding data representing the data, a pointer (instruction value xp) 306 pointing to each data XTxp (xp = 1, 2, ..., M) of the input buffer 302, and each element uj of the input vector u. An input buffer 304 that can hold data and each data UTup (up = 1, 2, ...) Of this input buffer 304
N) indicating a pointer (instruction value up) 308. The output device 22 includes an output buffer 303 which can also hold data representing each element tj of the output vector y and also serves as a product-sum operation buffer, and each data YTyp of this output buffer 303.
A pointer (instruction value yp) 307 that points to (yp = 1, 2, ..., N),
An output buffer 305 which also serves as a product-sum operation buffer capable of holding data representing each element vi of the output vector v, and a pointer (instruction value vp) pointing to each data VTvp (vp = 1, 2, ... M) of this output buffer 305 It consists of 309. In addition, 301 in FIG. 7 represents each element Wji of the conversion matrix W by a two-dimensional array as an example in order to explain the function of this matrix operation device. In the figure, "0" represents a zero element with Wji = 0, and "W" represents a non-zero element with Wji ≠ 0. Further, pi represents the number of zero elements arranged in the row direction, and qi represents the number of non-zero elements arranged in the row direction. As shown in FIG. 2, the first memory 11 stores an index table 401 that stores an integer that represents the number of zero elements of the conversion matrix W that are consecutively arranged, and each data ITip of the index table 401. Pointer (instruction value ip) that points to (ip = 1,2, ...) 40
It consists of 3. On the other hand, as shown in FIG. 3, the second memory 12 stores a coefficient memory 402 in which data representing the contents of non-zero elements of the conversion matrix W are stored in order, and each data WTWp of the coefficient memory 402. (Wp = 1,2, ...) Pointer (instruction value wp) 404.
上記インデックステーブル401、係数メモリ402は、次の
ようにして作成される。第7図に示した上記変換行列W3
01の各行を1行目から順に左から右に調べてゆき、非零
要素のときその内容(実数)を表わすデータを、上記係
数メモリ402に格納する一方、この非零要素の左側に並
ぶ零要素の数piに1を足した整数(pi+1)をnビット
のデータで表わして上記インデックステーブル401に格
納する(以下、単に「整数を登録する」という)。な
お、上記非零要素の左隣が非零要素である場合、pi=0
であるため、登録する整数は1となる。非零要素がqi個
並ぶときは上記インデックステーブル401には整数1を
(qi−1)個続けて登録することになる。各行の行末に
きたときは、行末記号delim(delim=2n−1)を登録す
る。行末が零要素である場合、この行末の零要素を含む
零要素の並びの数(零要素が並んでおらず、左隣が非零
要素のときは1)を登録するのでなく、行末記号delim
を登録する。ところで、このようにnビットのデータ
(1ワード)で整数を表わす場合、表わすことができる
整数は(2n−1)までであり、さらに整数(2n−1)を
上に述べたように行末記号delimに使用しているので、
結局、1ワードで表すことができる整数は(2n−2)ま
でとなっている。そこで、(2n−2)個以上零要素が並
ぶときは、次のように2ワード以上使ってその数を表わ
して登録する。例えば、零要素が並ぶ数をpiとすると、 pi+1=(2n−2)a+b a,bは整数 0≦a 0≦b<(2n−2) と表わせるときは、(a+1)個のワードを使って表わ
す。すなわち、a個のワードのデータは(2n−2)と
し、最後の1ワードのデータはbとする。The index table 401 and the coefficient memory 402 are created as follows. The transformation matrix W3 shown in FIG.
Each row of 01 is sequentially examined from left to right from the first row, and data representing the content (real number) of the non-zero element is stored in the coefficient memory 402 while zeros arranged on the left side of the non-zero element. An integer (pi + 1) obtained by adding 1 to the number of elements pi is represented by n-bit data and stored in the index table 401 (hereinafter, simply referred to as "registering an integer"). If the element on the left of the non-zero element is a non-zero element, pi = 0
Therefore, the integer to be registered is 1. When qi non-zero elements are lined up, (qi-1) integers 1 are continuously registered in the index table 401. When the end of each line is reached, the end-of-line symbol delim (delim = 2 n -1) is registered. If the end of line is a zero element, the number of the array of zero elements including the zero element at the end of the line (1 if the zero elements are not aligned and the next element on the left is a nonzero element) is not registered, but the end-of-line symbol delim
To register. By the way, when an integer is represented by n-bit data (1 word) in this way, the integer that can be represented is up to (2 n −1), and the integer (2 n −1) is as described above. Since it is used for the line delimiter delim,
After all, the integer that can be expressed by one word is up to (2 n -2). Therefore, when (2 n −2) or more zero elements are arranged, the number is expressed by using two words or more and registered as follows. For example, if the number of zero elements arranged is pi, then pi + 1 = (2 n −2) a + b a, b can be expressed as an integer 0 ≦ a 0 ≦ b <(2 n −2), then (a + 1) Express using words. That is, the data of a words is (2 n −2), and the data of the last one word is b.
この行列演算装置は、上記述べたように、変換行列Wの
零要素が並ぶ数piと行末記号delimをインデックスとし
て、次のように演算処理を行なう。As described above, this matrix operation device uses the number pi in which the zero elements of the conversion matrix W are lined up and the line end symbol delim as an index to perform the following operation processing.
入力ベクトルxの一次変換として式(1)を計算をする
場合、第8図に示す計算アルゴリズムに従って計算す
る。When the equation (1) is calculated as the linear transformation of the input vector x, it is calculated according to the calculation algorithm shown in FIG.
まず、ステップS1に示すように、各ポインタ403,404,30
6,307の指示値をそれぞれip,wp,yp=1、xp=0とし、
出力バッフア303のデータYTyp(yp=1,…,M)を0とす
る(初期化)。次に、インデックステーブル401のデー
タITipが行末記号delim(=2n−1)であるかどうか判
別(S2)して、行末であれば改行(S3)する。行末でな
ければ、行方向向きにITip分だけ移動(S5)して、ITip
が最大数(2n−2)であるかどうかを判別(S6)する。
最大数であれば、インデックステーブル401の次のデー
タを調べにゆく(S7)。最大数でなければ、積WTwp×XT
xpをYTypに加算(S8)し、係数メモリ404の次のデータ
を出せるように指示値wpを1つ進めると共に、インデッ
クステーブル401の次のデータを調べにゆく(S9)。そ
して、ステップS2に戻って、再びITipが行末記号delim
であるかどうかを判別して、行末であれば改行(S3)し
て、さらに、N行まで調べ終わったとき、この演算を終
了する。First, as shown in step S 1 , each pointer 403, 404, 30
Set the indicated values of 6,307 to ip, wp, yp = 1 and xp = 0 respectively,
The data YTyp (yp = 1, ..., M) of the output buffer 303 is set to 0 (initialization). Next, the data ITip the index table 401 is judged whether it is a line terminator delim (= 2 n -1) and (S 2), and line feed if the end of the line (S 3) to. If it is not the end of the line, move it in the direction of the line by ITip (S 5 ), and then ITip
Is determined to be the maximum number (2 n −2) (S 6 ).
If it is the maximum number, the next data of the index table 401 is examined (S 7 ). If not the maximum number, the product WTwp × XT
xp is added to YTyp (S 8 ), the instruction value wp is advanced by 1 so that the next data in the coefficient memory 404 can be output, and the next data in the index table 401 is examined (S 9 ). Then, returning to step S 2 , ITip again delimits the line terminator.
If it is the end of the line, a line feed (S 3 ) is performed, and when the search up to the Nth line is completed, this operation is ended.
入力ベクトルutの一次変換式(2)を計算する場合、上
記演算と同様の手順によって、第9図に示す計算アルゴ
リズムに従って計算する。When the linear transformation equation (2) of the input vector u t is calculated, it is calculated according to the calculation algorithm shown in FIG. 9 by the same procedure as the above calculation.
このように演算処理を行なうことによって、例えばN行
M列の変換行列Wの全要素(N×M個の実数)のうち非
零要素の占める割合がk%であるとき、この行列Wの要
素を記憶するための上記係数メモリ402の記憶量は、実
数にしてN×M×k/100個分となり、一方、上記インデ
ックステーブル401の記憶量は、整数にして約N×M×k
/100個分となる。したがって、非零要素の占める割合が
少ない(kが小さいとき)上記変換行列Wの要素の記憶
量を低減することができる。また、上記行列演算処理1
回につき乗算と加算を行なう回数はそれぞれN×M×k/
100回となって、kが小さいとき計算量を低減すること
ができる。By performing the arithmetic processing in this manner, for example, when the ratio of non-zero elements among all the elements (N × M real numbers) of the conversion matrix W of N rows and M columns is k%, the elements of this matrix W are The storage amount of the coefficient memory 402 for storing is a real number of N × M × k / 100, while the storage amount of the index table 401 is an integer of about N × M × k.
/ It will be 100 pieces. Therefore, it is possible to reduce the storage amount of the elements of the conversion matrix W when the ratio of non-zero elements is small (when k is small). In addition, the matrix calculation process 1
The number of times of multiplication and addition is N × M × k /
The number of calculations is 100, and the calculation amount can be reduced when k is small.
次に、この発明の基礎となる第2の行列演算装置を説明
する。Next, a second matrix operation device which is the basis of the present invention will be described.
この行列演算装置は、第1の行列演算装置のインデック
ステーブル401に代えて、第4図に示すインデックステ
ーブル411を備えている。他の構成は第1の行列演算装
置と同一である。上記インデックステーブル411は次の
ようにして作成される。インデックステーブル401と同
様に、零要素の並びの数piに1を足した整数(pi+1)
を登録する。ただし、行末記号delimを使用せず、零要
素が行末から次行の行頭へ続く場合は、行末の零要素の
並び数と次行の行頭の零要素の並び数とを足した数に1
を加えて登録する。例えば、第7図に示す変換行列W301
の1行目の行末と2行目の行頭の場合、整数(p2+p3+
1)を登録する。This matrix operation device has an index table 411 shown in FIG. 4 in place of the index table 401 of the first matrix operation device. Other configurations are the same as those of the first matrix operation device. The index table 411 is created as follows. Similar to the index table 401, an integer (pi + 1) obtained by adding 1 to the number pi of the array of zero elements
To register. However, if the zero element continues from the end of the line to the beginning of the next line without using the end-of-line symbol delim, the number of arrangements of zero elements at the end of the line and the number of arrangements of zero elements at the beginning of the next line is added to 1
Add and register. For example, the transformation matrix W301 shown in FIG.
For the end of the first line and the beginning of the second line of, the integer (p 2 + p 3 +
Register 1).
上記入力ベクトルx,入力ベクトルutの一次変換式
(1),式(2)を計算する場合、それぞれ第10図、第
11図に示す計算アルゴリズムに従って行なう。なお、簡
単のため、各データ、指示値は第1の行列演算装置と同
一記号を使用している(後に述べる第3、第4の行列演
算装置において同様)。第1の行列演算装置に対して略
同一手順であるが、式(1)の計算の場合、行末を検出
するためにxpとMとを比較して、xp>Mならば行が変わ
ったと判断(S25)して、ypをint(xp/M)だけ進める
(S26)点が異なっている。式(2)の計算の場合、vp
を使ってこれを行なう。なお、int(*)は括弧内の式
の値の整数部を示している。When calculating the linear transformation equations (1) and (2) of the input vector x and the input vector u t , respectively, as shown in FIG. 10 and FIG.
Follow the calculation algorithm shown in Fig. 11. For the sake of simplicity, the same symbols are used for each data and instruction value as in the first matrix operation device (the same applies to the third and fourth matrix operation devices described later). Although the procedure is almost the same as that of the first matrix operation device, in the case of the calculation of the equation (1), xp and M are compared to detect the end of the line, and if xp> M, it is determined that the line has changed. (S 25 ) and then advance yp by int (xp / M) (S 26 ). In the case of calculation of formula (2), vp
Do this using. Note that int (*) indicates the integer part of the value of the expression in parentheses.
次に、この発明を具現化した第3の行列演算装置を説明
する。Next, a third matrix operation device embodying the present invention will be described.
この行列演算装置は、第1の行列演算装置のインデック
ステーブル401に代えて、第5図に示すインデックステ
ーブル421を備えている。他の構成は第1の行列演算装
置と同一である。上記インデックステーブル421は、零
要素の並びの数piと別に非零要素の並びの数qiを登録す
る。すなわち、非零要素が並んでいる場合、第1の行列
演算装置,第2の行列演算装置と異なり、(qi−1)個
の整数1をそれぞれ別個に登録するのでなく、1つのデ
ータとして整数qiを登録する。そして、1ワード当たり
nビットのうち最上位ビットを、零要素の並びの数piで
あるか非零要素の並びの数qiであるかの区別に使用す
る。零要素または非零要素が行末から次行の行頭へ続く
ときは、それらの並びの数を足した整数(pi+pi+1),
(qi+qi+1)を登録する。このようにした場合、第1の
行列演算装置,第2の行列演算装置に比して、インデッ
クステーブルのデータ量を少なくすることができる。This matrix operation device has an index table 421 shown in FIG. 5 in place of the index table 401 of the first matrix operation device. Other configurations are the same as those of the first matrix operation device. The index table 421 registers the number qi of non-zero element sequences in addition to the number pi of zero element sequences. That is, when the non-zero elements are lined up, unlike the first matrix operation device and the second matrix operation device, (qi−1) integers 1 are not individually registered, but integers are regarded as one data. Register qi. Then, the most significant bit of n bits per word is used to distinguish whether it is the number pi of arrangements of zero elements or the number qi of arrangements of non-zero elements. When zero elements or non-zero elements continue from the end of the line to the beginning of the next line, an integer (pi + pi +1 ), which is the number of those sequences,
Register (qi + qi + 1 ). In this case, the data amount of the index table can be reduced as compared with the first matrix operation device and the second matrix operation device.
上記入力ベクトルx、入力ベクトルutの一次変換として
式(1),(2)を計算する場合、それぞれ第12図,第
13図に示す計算アルゴリズムに従って演算処理を行な
う。第1の行列演算装置および第2の行列演算装置に対
して略同一手順であるが、ITipが零要素または非零要素
のいずれを示しているかを判断(S53,S74)して、零要
素を示しているときは、その数だけxpまたはvpをスキッ
プする点が異なっている(S54,S75)。非零要素を示し
ているときは、その数だけ入力XTxpと係数WTwpとの積和
を計算する(S57乃至S61,S78乃至S82)。ただし、第2
の行列演算装置と同様に、その途中で行末になったかど
うかを、xpまたはvpの値をMの値と比較して判断する
(S60,S80)。When equations (1) and (2) are calculated as the linear transformation of the input vector x and the input vector u t , they are shown in FIG. 12 and FIG.
Calculation processing is performed according to the calculation algorithm shown in FIG. Although the procedure is substantially the same for the first matrix operation device and the second matrix operation device, it is determined whether ITip indicates a zero element or a non-zero element (S 53 , S 74 ), and zero is determined. When elements are shown, the difference is that xp or vp is skipped by that number (S 54 , S 75 ). When non-zero elements are shown, the sum of products of the input XTxp and the coefficient WTwp is calculated by that number (S 57 to S 61 , S 78 to S 82 ). However, the second
Similar to the matrix operation device of (1), it is determined whether the line end is reached in the middle by comparing the value of xp or vp with the value of M (S 60 , S 80 ).
このように、インデックステーブル421の内容検出と、
第2のメモリ12の内容読み出しとを並行して進めること
によって、簡単に第2のメモリのアドレス指定を行うこ
とができる。この結果、この行列演算装置の制御を簡単
に行うことができる。In this way, when the contents of the index table 421 are detected,
By advancing the reading of the contents of the second memory 12 in parallel, the addressing of the second memory can be easily performed. As a result, the matrix operation device can be easily controlled.
次に、この発明を具現化した第4の行列演算装置を説明
する。Next, a fourth matrix operation device embodying the present invention will be described.
この行列演算装置は、第1の行列演算装置のインデック
ステーブルに代えて、第6図に示すインデックステーブ
ル431を備えている。他の構成は第1の行列演算装置と
同一である。上記インデックステーブル431は、第3の
行列演算装置と同様に、零要素の並びの数piと別に非零
要素の並びの数qiを登録する。ただし、行末では零要素
または非零要素の並びの数のいずれかの最大値を行末記
号delimとして登録する。なお、行末が零要素または零
要素の並びで終わるときは、1または並びの数を登録せ
ず、上記行末記号delimを登録する。このようにした場
合、第1の行列演算装置,第2の行列演算装置に比し
て、インデックステーブルのデータ量を少なくすること
ができる。This matrix operation device has an index table 431 shown in FIG. 6 in place of the index table of the first matrix operation device. Other configurations are the same as those of the first matrix operation device. The index table 431 registers the number qi of non-zero element sequences separately from the number pi of zero element sequences, as in the third matrix operation device. However, at the end of the line, the maximum value of either the number of zero elements or the sequence of non-zero elements is registered as the line end symbol delim. When the line end ends with a zero element or a sequence of zero elements, 1 or the number of sequences is not registered, and the line end symbol delim is registered. In this case, the data amount of the index table can be reduced as compared with the first matrix operation device and the second matrix operation device.
上記入力ベクトルx,入力ベクトルutの一次変換式
(1),式(2)を計算する場合、それぞれ第14図,第
15図に示す計算アルゴリズムに従って演算処理を行な
う。第3の行列演算装置に対して、行末であるかどうか
行末記号delimを使用して判断(S93,S104)する点のみ
が異なっている。When calculating the linear transformation equations (1) and (2) of the input vector x and the input vector u t , respectively, as shown in FIG. 14 and FIG.
Calculation processing is performed according to the calculation algorithm shown in FIG. The third matrix operation device differs from the third matrix operation device only in that the end of line symbol delim is used to determine (S 93 , S 104 ).
このように、インデックステーブル431の内容検出と、
第2のメモリ12の内容読み出しとを並行して進めること
によって、簡単に第2のメモリのアドレス指定を行うこ
とができる。この結果、この行列演算装置の制御を簡単
に行うことができる。In this way, detecting the contents of the index table 431,
By advancing the reading of the contents of the second memory 12 in parallel, the addressing of the second memory can be easily performed. As a result, the matrix operation device can be easily controlled.
なお、第1乃至第4の行列演算装置において、変換行列
Wの各行を左から右へスキャンしたが、当然ながら、列
方向にスキャンしても良い。In addition, in each of the first to fourth matrix calculation devices, each row of the conversion matrix W is scanned from left to right, but of course, the rows may be scanned in the column direction.
<発明の効果> 以上より明らかなように、この発明の行列演算装置は、
2次元配列で表わされる行列の各要素について零要素か
非零要素かを特定するデータを格納する第1のメモリ
と、上記行列の非零要素の内容を表わすデータを格納す
る第2のメモリと、上記第1のメモリに格納されたデー
タを参照して、上記行列の要素が零であるか否かを判別
する判別手段と、上記判別手段によって零でないと判別
された行列の要素について、上記第2のメモリに格納さ
れたデータと入力ベクトルの要素とを乗算して、積和を
求める演算手段を備えているので、大規模なスパース行
列の演算処理を行なう場合、変換行列において非零要素
の占める割合がk%であるとき、メモリの記憶量と計算
量をk%に低減することができる。<Effects of the Invention> As is clear from the above, the matrix operation device of the present invention is
A first memory that stores data that specifies whether each element of a matrix represented by a two-dimensional array is a zero element or a nonzero element; and a second memory that stores data that represents the contents of the nonzero elements of the matrix. , With reference to the data stored in the first memory, the discriminating means for discriminating whether or not the element of the matrix is zero, and the element of the matrix discriminated by the discriminating means to be non-zero, Since the arithmetic means for multiplying the data stored in the second memory and the elements of the input vector to obtain the sum of products is provided, when performing the arithmetic processing of a large-scale sparse matrix, non-zero elements in the conversion matrix are included. When the ratio occupied by k is k%, the memory storage amount and calculation amount can be reduced to k%.
しかも、上記第1のメモリは、上記行列内で、零である
要素が連続して並ぶ数を表わす整数と、零でない要素が
連続して並ぶ数を表す整数とを、上記行列内の各連続す
る並びの順に格納しているので、第2のメモリの内容を
読み出すときにそのアドレス指定を簡単に行うことがで
きる。すなわち、第1のメモリを例えばポインタによっ
て順にスキャンして、非零要素が並ぶ数を表す整数が検
出されたとき、この整数分だけ順に第2のメモリに格納
された非零要素の内容を表すデータを読み出す。このよ
うに、第1のメモリの内容検出と、第2のメモリの内容
読み出しとを並行して進めることによって、簡単に第2
のメモリのアドレス指定を行うことができる。この結
果、この行列演算装置の制御を簡単に行うことができ
る。Moreover, the first memory stores an integer representing the number of consecutive zero elements in the matrix and an integer representing the number of consecutive non-zero elements in each matrix. Since the contents are stored in the order of arrangement, the address can be easily specified when reading the contents of the second memory. That is, when the first memory is sequentially scanned by, for example, a pointer, and an integer representing the number of non-zero elements arranged is detected, the contents of the non-zero elements stored in the second memory are sequentially represented by this integer. Read the data. In this way, by performing the content detection of the first memory and the content reading of the second memory in parallel, the second memory can be easily
The memory can be addressed. As a result, the matrix operation device can be easily controlled.
第1図はこの発明の行列演算装置の構成を示すブロック
図、第2図,第4図,第5図および第6図は上記行列演
算装置のインデックステーブルを示す図、第3図は上記
行列演算装置の係数メモリを示す図、第7図は上記行列
演算装置の入出力バッファ,ポインタと変換行列Wの要
素を示す図、第8図乃至第15図は上記行列演算装置の計
算アルゴリズムを示すフローチャート、第16図および第
17図は従来の行列演算装置による演算を模式的に示す図
である。 1……CPU、2……ROM、11……第1のメモリ、12……第
2のメモリ、21……入力装置、22……出力装置、301…
…変換行列W、302,308……入力バッファ、303,305……
出力バッフア、401,411,421,431……インデックステー
ブル、402……係数メモリ、306,307,308,309,403,404…
…ポインタ。FIG. 1 is a block diagram showing a configuration of a matrix operation device of the present invention, FIGS. 2, 4, 5, and 6 are views showing an index table of the matrix operation device, and FIG. FIG. 7 is a diagram showing a coefficient memory of the arithmetic unit, FIG. 7 is a diagram showing input / output buffers, pointers and elements of the transformation matrix W of the matrix arithmetic unit, and FIGS. 8 to 15 are calculation algorithms of the matrix arithmetic unit. Flow chart, Figure 16 and Figure
FIG. 17 is a diagram schematically showing calculation by a conventional matrix calculation device. 1 ... CPU, 2 ... ROM, 11 ... first memory, 12 ... second memory, 21 ... input device, 22 ... output device, 301 ...
… Conversion matrix W, 302,308 …… Input buffer, 303,305 ……
Output buffer, 401,411,421,431 ... Index table, 402 ... Coefficient memory, 306,307,308,309,403,404 ...
… A pointer.
Claims (1)
いて零である要素か零でない要素かを特定するデータを
格納する第1のメモリと、 上記行列の零でない要素の内容を表わすデータを格納す
る第2のメモリと、 上記第1のメモリに格納されたデータを参照して、上記
行列の要素が零であるか否かを判別する判別手段と、 上記判別手段によって零でないと判別された行列の要素
について、上記第2のメモリに格納されたデータと入力
ベクトルの要素とを乗算して、積和を求める演算手段を
備えた行列演算装置において、 上記第1のメモリは、上記行列内で、零である要素が連
続して並ぶ数を表わす整数と、零でない要素が連続して
並ぶ数を表す整数とを、上記行列内の各連続する並びの
順に格納していることを特徴とする行列演算装置。1. A first memory for storing data specifying whether each element of a matrix represented by a two-dimensional array is zero or nonzero, and data representing the contents of the nonzero elements of the matrix. A second memory to store the data, and a determination unit that determines whether the element of the matrix is zero with reference to the data stored in the first memory, and the determination unit determines that the matrix is not zero. In the matrix operation device having an operation means for multiplying the data stored in the second memory and the element of the input vector with respect to the elements of the matrix to obtain the sum of products, the first memory is the matrix In which an integer representing the number of consecutive zero elements and an integer representing the number of non-zero consecutive elements are stored in the order of each consecutive row in the matrix. Matrix computing device.
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1096079A JPH0748207B2 (en) | 1989-04-14 | 1989-04-14 | Matrix operation device |
| US07/798,939 US5267185A (en) | 1989-04-14 | 1991-11-27 | Apparatus for calculating matrices |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1096079A JPH0748207B2 (en) | 1989-04-14 | 1989-04-14 | Matrix operation device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPH02273867A JPH02273867A (en) | 1990-11-08 |
| JPH0748207B2 true JPH0748207B2 (en) | 1995-05-24 |
Family
ID=14155390
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP1096079A Expired - Fee Related JPH0748207B2 (en) | 1989-04-14 | 1989-04-14 | Matrix operation device |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH0748207B2 (en) |
Families Citing this family (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6895421B1 (en) | 2000-10-06 | 2005-05-17 | Intel Corporation | Method and apparatus for effectively performing linear transformations |
| CN109328361B (en) * | 2016-06-14 | 2020-03-27 | 多伦多大学管理委员会 | Accelerator for deep neural network |
| US10360163B2 (en) * | 2016-10-27 | 2019-07-23 | Google Llc | Exploiting input data sparsity in neural network compute units |
| US10175980B2 (en) | 2016-10-27 | 2019-01-08 | Google Llc | Neural network compute tile |
| DE112017008040T5 (en) * | 2017-09-14 | 2020-07-09 | Mitsubishi Electric Corporation | COMPUTING OPERATION CIRCUIT, COMPUTING OPERATION PROCEDURE AND PROGRAM |
| DE112018004972T5 (en) * | 2017-10-18 | 2020-06-18 | Mitsubishi Electric Corporation | OPERATING CIRCUIT AND OPERATING METHOD |
| CN113228057B (en) * | 2019-01-11 | 2024-05-31 | 三菱电机株式会社 | Reasoning device and reasoning method |
| CN117290653B (en) * | 2023-11-24 | 2024-02-20 | 巨霖科技(上海)有限公司 | Matrix solving method and system based on EDA system |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS5364439A (en) * | 1976-11-20 | 1978-06-08 | Agency Of Ind Science & Technol | Linear coversion system |
| JPS60250473A (en) * | 1984-05-25 | 1985-12-11 | Hitachi Ltd | vector processor |
-
1989
- 1989-04-14 JP JP1096079A patent/JPH0748207B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JPH02273867A (en) | 1990-11-08 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US5267185A (en) | Apparatus for calculating matrices | |
| US5301136A (en) | Method and apparatus for fast implementation of inverse discrete cosine transform in a digital image processing system using low cost accumulators | |
| US11803360B2 (en) | Compilation method, apparatus, computing device and medium | |
| JP3323949B2 (en) | Method and apparatus for efficiently performing IDCT | |
| JPH06162171A (en) | Vertex-index cache system of polygon in computer graphics | |
| CN115392450B (en) | Operation method and operation system | |
| JPH03231383A (en) | Image reduction/expansion method and apparatus | |
| JPH0526229B2 (en) | ||
| JP3526976B2 (en) | Processor and data processing device | |
| US5794065A (en) | Data driven information processor | |
| US20230068450A1 (en) | Method and apparatus for processing sparse data | |
| CN115481364B (en) | A parallel computing method for large-scale elliptic curve multi-scalar multiplication based on GPU acceleration | |
| JPH0748207B2 (en) | Matrix operation device | |
| US7478363B2 (en) | Method for translating a given source program into an object program containing computing expressions | |
| US4916649A (en) | Method and apparatus for transforming a bit-reversed order vector into a natural order vector | |
| JPH036546B2 (en) | ||
| WO1988007242A2 (en) | Arithmetic computation modifier based upon data dependent operations | |
| JP2662124B2 (en) | Method, apparatus and system for generating signal sequence in fast Fourier transform and fast Fourier transform processing apparatus | |
| JPH1049665A (en) | Device and method for image processing | |
| JP2026031990A (en) | In situ sparse matrix expansion | |
| EP0327001A2 (en) | Pattern data generating system | |
| WO1993019431A1 (en) | Parallel vector processor architecture | |
| CN118363923A (en) | A low-cost matrix operation FPGA implementation method based on operator reuse | |
| US6938064B1 (en) | Method for computing fast Fourier transform and inverse fast Fourier transform | |
| JPH07220062A (en) | Method and apparatus for reduction of size of display by substantially maintaining information content of display |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| LAPS | Cancellation because of no payment of annual fees |