CN101122896A - 一种基于矩阵运算的高效asic数据处理方法 - Google Patents

一种基于矩阵运算的高效asic数据处理方法 Download PDF

Info

Publication number
CN101122896A
CN101122896A CNA2006100300035A CN200610030003A CN101122896A CN 101122896 A CN101122896 A CN 101122896A CN A2006100300035 A CNA2006100300035 A CN A2006100300035A CN 200610030003 A CN200610030003 A CN 200610030003A CN 101122896 A CN101122896 A CN 101122896A
Authority
CN
China
Prior art keywords
matrix
data processing
row
processing method
relevant
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.)
Pending
Application number
CNA2006100300035A
Other languages
English (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.)
Spreadtrum Communications Shanghai Co Ltd
Original Assignee
Spreadtrum Communications Shanghai Co Ltd
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 Spreadtrum Communications Shanghai Co Ltd filed Critical Spreadtrum Communications Shanghai Co Ltd
Priority to CNA2006100300035A priority Critical patent/CN101122896A/zh
Publication of CN101122896A publication Critical patent/CN101122896A/zh
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Processing (AREA)

Abstract

本发明涉及数据处理方法,特别是一种基于矩阵运算的高效ASIC数据处理方法。它是在矩阵运算中,首先将矩阵按列分细粒度,一列为一个颗粒,一次仅做一个颗粒的运算,然后将每个粒度值累加到Pipeline寄存器中。藉由上述方法主要解决现有数据处理方法中使用ASIC实现结构进行运算时矩阵运算需要用到很多乘法器和加法器,影响运算速度和增加运算逻辑面积的技术问题,节省了加法器且提高了数据处理的效率。

Description

一种基于矩阵运算的高效ASIC数据处理方法
技术领域
本发明涉及数据处理方法,特别是一种基于矩阵运算的高效ASIC数据处理方法。
背景技术
在ASIC数据处理运算中,会有很多矩阵运算。而矩阵运算需要用到很多乘法器和加法器,不但影响运算速度,还增加芯片运算逻辑的面积。在如图1所示的ASIC数据处理方法的5×5矩阵运算中:
Y(l,j)=D(i-2,j-2)×(i-2,j-2)+
         D(i-2,j-1)×(i-2,j-1)+
                               ...+
         D(i+2,j+2)×(i+2,j+2)
         =∑D(k,l)×(k,l)
其中:k=i-2 to i+2;l=j-2 to j+2
总共需要25个乘法器和24个加法器。当然,随着级数的增加,比如16×16,384×384...需要的乘法器和加法器也越来越多。
发明内容
本发明的目的在于提供一种基于矩阵运算的高效ASIC数据处理方法,解决现有数据处理方法中使用ASIC实现结构进行运算时矩阵运算需要用到很多乘法器和加法器,影响运算速度和增加运算逻辑面积的技术问题,节省了加法器且提高了数据处理的效率。
为解决上述问题,本发明是这样实现的:
一种基于矩阵运算的高效数据处理方法,其特征在于:在矩阵运算中,首先将矩阵按列分细粒度,一列为一个颗粒,一次仅做一个颗粒的运算(如图3所示),然后将每个粒度值累加到Pipeline寄存器中。
附图说明
图1现有数据处理方法中矩阵运算的矩阵图。
图2是图形图象数据处理矩阵图。
图3是本发明方法中的矩阵图。
图4是本发明方法中的体现pipeline结构的矩阵图。
具体实施方式
为了更清楚的表达本发明方法,特别用一个5×5矩阵说明。参见图4,定义第j-2列到第j+2列组成的5×5矩阵为J1,第j-1列到第j+3列组成的5×5矩阵为J2,第j到第j+4列组成的5×5矩阵为J3,第j+1到第j+5列组成的5×5矩阵为J4,第j+2到第j+6列组成的5×5矩阵为J5。
该矩阵中每个颗粒同时具有最少1最多5种身份:
●对于第j-2列的5个数,仅仅和矩阵J1相关作为J1的第一列。
●对于第j-1列的5个数,和矩阵J1相关作为J1的第二列,同时和J2相关作为J2的第一列。
●对于第j列的5个数,和矩阵J1相关作为J1的第三列,和J2相关作为J2的第二列,和J3相关作为J3的第一列。
●对于第j+1列的5个数,和矩阵J1相关作为J1的第四列,和J2相关作为J2的第三列,和J3相关作为J3的第二列,和J4相关作为J4的第一列。
●对于第j+2列的5个数,和矩阵J1相关作为J1的第五列,和J2相关作为J2的第四列,和J3相关作为J3的第三列,和J4相关作为J4的第二列。和J5相关作为J5的第一列。
一次把所有的相关结果都计算出来,在寄存器中保留相关的结果,累加到相应寄存器中。
(1)P5=∑D(x,j+2)×(x,j+2)(x=l-2..i+2)
(2)P4=∑D(x,j+1)×(x,j+1)(x=l-2..i+2)
(3)P3=∑D(x,j)×(x,j)(x=l-2..i+2)
(4)P2=∑D(x,j-1)×(x,j-1)(x=l-2..i+2)
(5)P1=∑D(x,j-2)×(x,j-2)(x=l-2..i+2)
如图4数据是从右到左,一列一列进入进行运算,其运算过程如下:
1)第j-2列数据做为第一列进入5×5矩阵,同时做P1,P2,P3,P4,P5运算,保存P1的值进入相关累加器。
2)第j-1列数据做为第二列进入5×5矩阵,同时做P1,P2,P3,P4,P5运算,保存P1和P2的值进入相关累加器。
3)第j列数据做为第三列进入5×5矩阵,同时做P1,P2,P3,P4,P5运算,保存P1,P2和P3的值进入相关累加器。
4)第j+1列数据做为第四列进5×5矩阵,同时做P1,P2,P3,P4,P5算,保存P1,P2,P3和P4的值进入相关累加器。
5)第j+2列数据做为第五列进入5×5矩阵,同时做P1,P2,P3,P4,P5运算,保存P1,P2,P3,P4和P5的值进入相关累加器。此时矩阵J1的数据准备好,可以计算J1。
6)第j+3列数据做为第六列进入5×5矩阵,同时做P1,P2,P3,P4,P5运算,保存P1,P2,P3,P4和P5的值进入相关累加器。计算完J1,输出J1。此时矩阵J1的数据准备好,可以计算J2。
7)。。。
8)计算完所有的Jn值。
总共需要25个乘法器和30个加法器。
实例(行列对称)
请参阅图2,它是本发明基于矩阵运算的图象数据处理方法中的矩阵图。
以下将结合本发明方法和5×5矩阵的特点,描述矩阵运算过程:
首先,设定:
P1=D2*(X15+X55)+D9*(X25+X45)+D3*X35
P2=D6*(X15+X55)+D5*(X25+X45)+D7*X35
P3=D4*(X15+X55)+D8*(X25+X45)+D1*X35
P4=D6*(X15+X55)+D5*(X25+X45)+D7*X35
P5=D2*(X15+X55)+D9*(X25+X45)+D3*X35
其次,化简:
S1=X15+X55
S2=X25+X45
S3=X35
M1=D2*S1+D9*S2+D3*S3
M2=D6*S1+D5*S2+D7*S3
M3=D4*S1+D8*S2+D1*S3
最后,得到
P1=M1
P2=M2
P3=M3
P4=M2
P5=M1
上述运算过程中,只需要12个加法器和9个乘法器。它与原有运算方法的效果对比见下表:
----------------------------
方法    加法运算    乘法运算
----------------------------
传统ASIC实现结构       24    9
----------------------------------
Pipeline ASIC实现结构  12    9
----------------------------------
基于Pipeline ASIC结构来实现的本发明方法之所以能有上述的优异技术效果,主要是由于:
1、本发明方法的实列中运算矩阵,由于行对称,只需用2个加法器将一个颗粒中的5点,合并同系数项,得到3个值。
2、本发明方法的实列中运算矩阵,其第5列相对于P1、P2、P3、P4、P5点的运算有不同的系数须运算,而由于列对称(对于P1和P5第5列系数相同,对于P2和P4第5列系数相同),因此需要3*3=9个乘法器,得到9个值。
3、本发明方法中,只要计算5个点(P1、P2、P3、P4、P5)的3个值(M1、M2、M3),只需用6个加法器。
4、本发明方法的最后,将5个点(P1、P2、P3、P4、P5)的粒度值累加到Pipeline寄存器中,需要4个加法器,P5不需累加直接保存就可。
同传统的方法相比pipeline结构运算快,而节省加法器是和具体实列相关的。我们回到公式(1)(2)(3)(4)(5)可以发现如果矩阵具有行或/和列对称性,则可以大大减少乘法器和加法器。矩阵的对称性越强,越节省乘法器和加法器。因此,通过本发明方法(Pipeline ASIC结构)可以减少加法器的数量,并很大地提高数据处理矩阵的运算效率。
综上所述仅为本发明的较佳实施例而已,并非用来限定本发明的实施范围。即凡依本发明申请专利范围的内容所作的等效变化与修饰,都应为本发明的技术范畴。

Claims (1)

1.一种基于矩阵运算的高效ASIC数据处理方法,其特征在于:在矩阵运算中,首先将矩阵按列分细粒度,一列为一个颗粒,一次仅做一个颗粒的运算,然后将每个粒度值累加到Pipeline寄存器中。
CNA2006100300035A 2006-08-11 2006-08-11 一种基于矩阵运算的高效asic数据处理方法 Pending CN101122896A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNA2006100300035A CN101122896A (zh) 2006-08-11 2006-08-11 一种基于矩阵运算的高效asic数据处理方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNA2006100300035A CN101122896A (zh) 2006-08-11 2006-08-11 一种基于矩阵运算的高效asic数据处理方法

Publications (1)

Publication Number Publication Date
CN101122896A true CN101122896A (zh) 2008-02-13

Family

ID=39085233

Family Applications (1)

Application Number Title Priority Date Filing Date
CNA2006100300035A Pending CN101122896A (zh) 2006-08-11 2006-08-11 一种基于矩阵运算的高效asic数据处理方法

Country Status (1)

Country Link
CN (1) CN101122896A (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102541749A (zh) * 2011-12-31 2012-07-04 中国科学院自动化研究所 多粒度并行存储系统
WO2017185396A1 (zh) * 2016-04-26 2017-11-02 北京中科寒武纪科技有限公司 一种用于执行矩阵加/减运算的装置和方法

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102541749A (zh) * 2011-12-31 2012-07-04 中国科学院自动化研究所 多粒度并行存储系统
CN102541749B (zh) * 2011-12-31 2014-09-17 中国科学院自动化研究所 多粒度并行存储系统
WO2017185396A1 (zh) * 2016-04-26 2017-11-02 北京中科寒武纪科技有限公司 一种用于执行矩阵加/减运算的装置和方法

Similar Documents

Publication Publication Date Title
JP5408913B2 (ja) 高速かつ効率的な行列乗算ハードウェアモジュール
CN103221916B (zh) 执行乘乘累加指令
CN101794212B (zh) 控制移位分组数据的位校正的装置
CN103294446B (zh) 一种定点乘累加器
Abdelgawad et al. High speed and area-efficient multiply accumulate (MAC) unit for digital signal prossing applications
CN103761068B (zh) 优化的蒙哥马利模乘硬件
JPH07506444A (ja) 小型乗算器
JP2018523237A (ja) Simd乗算および水平集約演算
US6535901B1 (en) Method and apparatus for generating a fast multiply accumulator
Mukherjee et al. Counter based low power, low latency Wallace tree multiplier using GDI technique for on-chip digital filter applications
Tai et al. Accelerating matrix operations with improved deeply pipelined vector reduction
CN101840324A (zh) 支持复数运算和子字并行的64位定浮点乘法器
CN101122896A (zh) 一种基于矩阵运算的高效asic数据处理方法
US20030163504A1 (en) Addition circuit for accumulating redundant binary numbers
CN108255463B (zh) 一种数字逻辑运算方法、电路和fpga芯片
Jadhav et al. A novel high speed FPGA architecture for FIR filter design
Jha et al. Performance analysis of single-precision floating-point MAC for deep learning
Samanth et al. A Novel Approach to Develop Low Power MACs for 2D Image Filtering
Srinivas et al. High efficient accurate DL-PO logic multiplier design for low power applications
Parandeh-Afshar et al. A novel merged multiplier-accumulator embedded in DSP coprocessor
Priya et al. Review on optimization techniques of wallace tree multiplier
SUREKHA et al. Pre Encoded Multipliers Based on Non Redundant Radix-4 Design Using Modified Wallace Scheme
Kumar et al. Efficient Design and Implementation of Matrix Multiplication
Ramana Modified CNN accelerator using double MAC design
Xu Efficient polynomial evaluation algorithm and implementation on FPGA

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Open date: 20080213