CN118519613A - Multiply-accumulator operation cluster and data processing method - Google Patents

Multiply-accumulator operation cluster and data processing method Download PDF

Info

Publication number
CN118519613A
CN118519613A CN202410985037.8A CN202410985037A CN118519613A CN 118519613 A CN118519613 A CN 118519613A CN 202410985037 A CN202410985037 A CN 202410985037A CN 118519613 A CN118519613 A CN 118519613A
Authority
CN
China
Prior art keywords
multiply
accumulator
data
multiplication
processed
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.)
Granted
Application number
CN202410985037.8A
Other languages
Chinese (zh)
Other versions
CN118519613B (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.)
Zhuhai Haoze Technology Co ltd
Original Assignee
Zhuhai Haoze Technology 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 Zhuhai Haoze Technology Co ltd filed Critical Zhuhai Haoze Technology Co ltd
Priority to CN202410985037.8A priority Critical patent/CN118519613B/en
Publication of CN118519613A publication Critical patent/CN118519613A/en
Application granted granted Critical
Publication of CN118519613B publication Critical patent/CN118519613B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods 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/544Methods 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 for evaluating functions by calculation
    • G06F7/5443Sum of products
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Mathematical Physics (AREA)
  • Computational Mathematics (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Algebra (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Complex Calculations (AREA)

Abstract

The application discloses a multiply accumulator operation cluster and a data processing method. The multiply-accumulator operation cluster comprises a plurality of multiply-accumulator units, each multiply-accumulator unit is used for completing multiply-accumulator operation of at least one group of data to be processed, and when the calculated dimension of the data to be processed is smaller than the total dimension of the multiply-accumulator units, at least one multiply-accumulator subunit in the multiply-accumulator units is used for completing multiply-accumulator operation of each group of data to be processed, and outputting multiply-accumulate operation results of the data to be processed; and/or when the data to be processed comprises a plurality of data blocks which are sequentially arranged, respectively completing multiply-accumulate operation of one data block through a plurality of multiply-accumulator diversity groups in the multiply-accumulator operation cluster, and outputting the multiply-accumulate operation result of the data block to the next multiply-accumulator diversity group which is sequentially arranged until the multiply-accumulate operation of all the data blocks is completed, and outputting the multiply-accumulate operation result of the data to be processed. The multiply-accumulator operation cluster improves the utilization rate of the multiply-accumulator operation unit.

Description

乘累加器运算集群及数据处理方法Multiply-accumulate operation cluster and data processing method

技术领域Technical Field

本申请属于数字电路技术领域,具体涉及一种乘累加器运算集群及数据处理方法。The present application belongs to the field of digital circuit technology, and specifically relates to a multiplier-accumulator operation cluster and a data processing method.

背景技术Background Art

乘累加器(Multiply and Accumulate,简称 MAC)用于完成向量相乘、矩阵相乘和向量矩阵互乘等乘累加运算,是协处理器、数字信号处理器、中央处理器(CentralProcessing Unit,简 称 CPU)等处理器中极其重要的运算子系统,尤其是人工智能(AI)加速器中的最基本的运算单元。The Multiply and Accumulate (MAC) is used to perform multiplication and accumulation operations such as vector multiplication, matrix multiplication, and vector-matrix multiplication. It is an extremely important computing subsystem in processors such as coprocessors, digital signal processors, and central processing units (CPUs), especially the most basic computing unit in artificial intelligence (AI) accelerators.

AI加速器中的MAC一般可实现X组M维向量的点积,例如两组M维向量(A向量和B向量)的乘加运算,先完成A1 •B1,A2 •B2 ...AX •BX 运算,然后再将乘积相加求和,其中每个向量(A或B)的处理维数以M表示。每个数据可能是不同位宽的整数或浮点数,以输入为8bits整数为例,则MAC的每个时钟周期的算力为M乘以X乘以2 (2理解为一个乘法和一个加法的两次运算操作) 的8bits整数运算。但是实际的应用过程中,由于一些原因会导致MAC运算单元利用率低。例如,当A向量或B向量的处理维数小于乘累加器的维度M时(乘累加器的维度代表包含的乘法器的数量),进行处理数据时会有一些乘法器处于空闲状态,只有当这次处理结束后,空闲状态的乘法器才可以进行下一次的使用,造成了乘累加器中的乘法器使用率低的情况。例如,乘累加器的输入数据没有及时准备好或者乘累加器的输出数据没有及时输出,造成线路阻塞,乘累加器不能进入下一次的使用,也会导致乘累加器运算单元利用率低。The MAC in an AI accelerator can generally implement the dot product of X groups of M-dimensional vectors. For example, the multiplication and addition operations of two groups of M-dimensional vectors (vector A and vector B) are completed by first completing the A1 •B1, A2 •B2 ...AX •BX operations, and then adding the products together. The processing dimension of each vector (A or B) is represented by M. Each data may be an integer or floating point number of different bit widths. Taking the input as an 8-bit integer as an example, the computing power of each clock cycle of the MAC is M times X times 2 (2 is understood as two operations of a multiplication and an addition) of 8-bit integer operations. However, in actual applications, the utilization rate of the MAC operation unit is low due to some reasons. For example, when the processing dimension of vector A or vector B is less than the dimension M of the multiplication accumulator (the dimension of the multiplication accumulator represents the number of multipliers contained), some multipliers will be idle when processing data. Only when this processing is completed can the idle multipliers be used for the next time, resulting in low utilization of the multipliers in the multiplication accumulator. For example, if the input data of the multiplier-accumulator is not prepared in time or the output data of the multiplier-accumulator is not output in time, the line will be blocked and the multiplier-accumulator cannot be used next time, which will also lead to low utilization of the multiplier-accumulator operation unit.

目前没有好的电路结构能解决乘累加器运算单元利用率低的问题。Currently, there is no good circuit structure that can solve the problem of low utilization of the multiplication and accumulation unit.

发明内容Summary of the invention

有鉴于此,本申请提供了一种乘累加器运算集群及数据处理方法,主要目的在于解决现有的乘累加器运的算单元利用率低的的问题。In view of this, the present application provides a multiplier-accumulator operation cluster and a data processing method, the main purpose of which is to solve the problem of low utilization rate of the existing multiplier-accumulator operation units.

为解决上述问题,本申请提供一种乘累加器运算集群,所述乘累加器运算集群包括多个乘累加器单元,每个所述乘累加器单元用于完成至少一组待处理数据的乘累加运算,每组所述待处理数据包括两个多维度数据,每个所述乘累加器单元均包括多个乘累加器子单元,每个乘累加器子单元用于完成一次乘累加运算,并输出乘累加运算结果,其中,To solve the above problems, the present application provides a multiplication-accumulation operation cluster, the multiplication-accumulation operation cluster includes a plurality of multiplication-accumulation units, each of the multiplication-accumulation units is used to complete a multiplication-accumulation operation of at least one group of data to be processed, each group of the data to be processed includes two multi-dimensional data, each of the multiplication-accumulation units includes a plurality of multiplication-accumulation sub-units, each of the multiplication-accumulation sub-units is used to complete a multiplication-accumulation operation and output a multiplication-accumulation operation result, wherein,

在所述待处理数据中的两个所述多维度数据的计算维度小于所述乘累加器单元的总维度时,通过所述乘累加器单元中的至少一个乘累加器子单元完成每组所述待处理数据的乘累加运算,并输出所述待处理数据的乘累加运算结果;和/或,在所述待处理数据包括多个顺序排列的数据块时,通过所述乘累加器运算集群中的多个乘累加器分集群分别完成一个数据块的乘累加运算,并将所述数据块的乘累加运算结果输出到顺序排列的下一个所述乘累加器分集群中,直至完成所有所述数据块的乘累加运算,输出所述待处理数据的乘累加运算结果。When the calculation dimension of two of the multi-dimensional data in the data to be processed is smaller than the total dimension of the multiplication-accumulation unit, the multiplication-accumulation operation of each group of the data to be processed is completed by at least one multiplication-accumulation sub-unit in the multiplication-accumulation unit, and the multiplication-accumulation operation result of the data to be processed is output; and/or, when the data to be processed includes a plurality of sequentially arranged data blocks, the multiplication-accumulation operation of one data block is completed respectively by a plurality of multiplication-accumulation sub-clusters in the multiplication-accumulation operation cluster, and the multiplication-accumulation operation result of the data block is output to the next sequentially arranged multiplication-accumulation sub-cluster, until the multiplication-accumulation operation of all the data blocks is completed, and the multiplication-accumulation operation result of the data to be processed is output.

在本申请的一个实施例中,可选地,同一个乘累加器单元中的乘累加器子单元的维度相同,每个所述乘累加器单元中的所有乘累加器子单元的维度的总和与所述乘累加器单元的总维度相同,且多个不同的乘累加器单元中的乘累加器子单元的维度彼此相同或不同。In one embodiment of the present application, optionally, the dimensions of the multiplication accumulator sub-units in the same multiplication accumulator unit are the same, the sum of the dimensions of all the multiplication accumulator sub-units in each of the multiplication accumulator units is the same as the total dimension of the multiplication accumulator unit, and the dimensions of the multiplication accumulator sub-units in multiple different multiplication accumulator units are the same as or different from each other.

在本申请的一个实施例中,可选地,当一组待处理数据的计算维度小于或等于至少一个乘累加器单元中乘累加器子单元的维度时,根据待处理数据的计算维度和所述乘累加器单元中乘累加器子单元的维度,确定运算所述待处理数据的目标乘累加器单元,通过所述目标乘累加器单元中的乘累加器子单元对所述待处理数据进行乘累加运算。In one embodiment of the present application, optionally, when the computational dimension of a group of data to be processed is less than or equal to the dimension of a multiplication accumulator sub-unit in at least one multiplication accumulator unit, a target multiplication accumulator unit for operating the data to be processed is determined according to the computational dimension of the data to be processed and the dimension of the multiplication accumulator sub-unit in the multiplication accumulator unit, and multiplication and accumulation operations are performed on the data to be processed through the multiplication accumulator sub-unit in the target multiplication accumulator unit.

在本申请的一个实施例中,可选地,当一组待处理数据的计算维度大于所有乘累加器单元中乘累加器子单元的维度且小于每个所述乘累加器单元的总维度时,通过所述乘累加器单元中的多个乘累加器子单元完成所述待处理数据的乘累加运算。In one embodiment of the present application, optionally, when the calculation dimension of a group of data to be processed is greater than the dimension of the multiplication and accumulation sub-units in all the multiplication and accumulation units and less than the total dimension of each of the multiplication and accumulation units, the multiplication and accumulation operations of the data to be processed are completed by multiple multiplication and accumulation sub-units in the multiplication and accumulation units.

在本申请的一个实施例中,可选地,在所述待处理数据的计算维度大于所有乘累加器单元中乘累加器子单元的维度且小于每个所述乘累加器单元的总维度时,根据待处理数据的计算维度和每个乘累加器单元中乘累加器子单元的维度,确定运算所述待处理数据的目标乘累加器以及所述目标乘累加器中乘累加器子单元的目标数量,通过所述目标乘累加器中目标数量的乘累加器子单元对所述待处理数据进行乘累积运算。In one embodiment of the present application, optionally, when the computational dimension of the data to be processed is greater than the dimension of the multiplication accumulator subunits in all the multiplication accumulator units and less than the total dimension of each of the multiplication accumulator units, a target multiplication accumulator for operating the data to be processed and a target number of multiplication accumulator subunits in the target multiplication accumulator are determined according to the computational dimension of the data to be processed and the dimension of the multiplication accumulator subunits in each multiplication accumulator unit, and multiplication and accumulation operations are performed on the data to be processed through the target number of multiplication accumulator subunits in the target multiplication accumulator.

在本申请的一个实施例中,可选地,所述乘累加器运算集群中的至少一个乘累加器子单元作为一个乘累加器分集群。In one embodiment of the present application, optionally, at least one multiplier accumulator sub-unit in the multiplier accumulator operation cluster serves as a multiplier accumulator sub-cluster.

在本申请的一个实施例中,可选地,当所述待处理数据中所有数据块的计算维度均小于或等于任一乘累加器单元中乘累加器子单元的维度时,将所述乘累加器单元中的每个乘累加器子单元作为一个乘累加器分集群,通过所述乘累加器单元中的多个乘累加器子单元分别完成一个数据块的乘累加运算,并将所述数据块的乘累加运算结果输出到顺序排列的下一个所述乘累加器子单元,直至完成所有所述数据块的乘累加运算,输出所述待处理数据的乘累加运算结果。In one embodiment of the present application, optionally, when the computational dimensions of all data blocks in the data to be processed are less than or equal to the dimension of the multiplication and accumulation sub-unit in any multiplication and accumulation unit, each multiplication and accumulation sub-unit in the multiplication and accumulation unit is used as a multiplication and accumulation cluster, and the multiplication and accumulation operation of one data block is completed respectively by multiple multiplication and accumulation sub-units in the multiplication and accumulation unit, and the multiplication and accumulation operation result of the data block is output to the next multiplication and accumulation sub-unit arranged in sequence, until the multiplication and accumulation operation of all the data blocks is completed, and the multiplication and accumulation operation result of the data to be processed is output.

在本申请的一个实施例中,可选地,所述乘累加器单元包括多个数据输入模块、多个乘运算模块、多个多级加运算模块和多个数据输出模块,其中,一个乘运算模块、一个多级加运算模块和多个数据输出模块构成一个乘累加器子单元,每个所述乘运算模块包括多个乘法器,每个所述多级加运算模块包括多个加法器;In one embodiment of the present application, optionally, the multiplication and accumulation unit includes a plurality of data input modules, a plurality of multiplication operation modules, a plurality of multi-stage addition operation modules and a plurality of data output modules, wherein one multiplication operation module, one multi-stage addition operation module and a plurality of data output modules constitute a multiplication and accumulation sub-unit, each of the multiplication operation modules includes a plurality of multipliers, and each of the multi-stage addition operation modules includes a plurality of adders;

每个所述数据输入模块的输入端分别与数据提供模块电连接,每个所述数据输入模块的输出端分别与一个所述乘运算模块的输入端电连接,每个所述乘运算模块的输出端与一个多级加运算模块的输入端电连接,每个所述多级加运算模块的输出端分别与多个数据输出模块电连接。The input end of each of the data input modules is electrically connected to the data providing module, the output end of each of the data input modules is electrically connected to the input end of a multiplication operation module, the output end of each of the multiplication operation modules is electrically connected to the input end of a multi-stage addition operation module, and the output end of each of the multi-stage addition operation modules is electrically connected to multiple data output modules.

本申请还提供一种数据处理方法,应用于上述所述的乘累加器运算集群,所述数据处理方法,包括:The present application also provides a data processing method, which is applied to the multiplication and accumulation operation cluster described above, and the data processing method includes:

获取待处理数据,根据所述待处理数据的计算维度和每个乘累加器单元中的乘累加器子单元的维度,确定所述待处理数据对应的目标乘累加器单元;Acquire data to be processed, and determine a target multiplication and accumulation unit corresponding to the data to be processed according to the calculation dimension of the data to be processed and the dimension of the multiplication and accumulation subunit in each multiplication and accumulation unit;

将所述待处理数据输入至所述目标乘累加器中处于空闲状态的乘累加器子单元中,通过所述目标乘累加器对所述待处理数据进行乘累加运算,得到所述待处理数据的乘累加运算结果。The data to be processed are input into a multiplication-accumulation subunit in an idle state in the target multiplication-accumulation unit, and a multiplication-accumulation operation is performed on the data to be processed by the target multiplication-accumulation unit to obtain a multiplication-accumulation operation result of the data to be processed.

在本申请的一个实施例中,可选地,所述获取待处理数据,根据所述待处理数据的计算维度和每个乘累加器单元中的乘累加器子单元的子维度,确定所述待处理数据对应的目标乘累加器单元,包括:In one embodiment of the present application, optionally, the acquiring the data to be processed, and determining the target multiplication and accumulation unit corresponding to the data to be processed according to the calculation dimension of the data to be processed and the sub-dimension of the multiplication and accumulation sub-unit in each multiplication and accumulation unit, includes:

将所述乘累加器单元中乘累加器子单元的维度大于或等于所述待处理数据的计算维度的乘累加器单元作为候选乘累加器单元;将处于空闲工作状态且乘累加器子单元的维度最大的候选乘累加器单元作为所述待处理数据对应的目标乘累加器单元。A multiplication accumulator unit in which the dimension of the multiplication accumulator sub-unit is greater than or equal to the calculation dimension of the data to be processed is taken as a candidate multiplication accumulator unit; a candidate multiplication accumulator unit that is in an idle working state and has the largest dimension of multiplication accumulator sub-unit is taken as a target multiplication accumulator unit corresponding to the data to be processed.

本申请中的有益效果:本申请提供的一种乘累加器运算集群及数据处理方法,乘累加器运算集群包括多个乘累加器单元,每个乘累加器单元均包括多个乘累加器子单元,当待处理数据中的两个多维度数据的计算维度小于乘累加器单元的总维度时,将多个待处理数据各自输入一个乘累加器子单元,在同一个时钟周期内,每个乘累加器单元中的多个乘累加器子单元能够同时对各自输入的待处理数据进行乘累加运算,提高乘累加器运算单元的利用率,还增大了乘累加器的输出带宽;当待处理数据包括多个顺序排列的数据块时,一个乘累加器分集群完成一个数据块的一次乘累加运算,并将该数据块的乘累加运算结果输出到顺序排列的下一个乘累加器分集群中,实现待处理数据的流水线工作方式的处理,在同一个时钟周期内,多个乘累加器分集群同时对各自输入的数据进行处理,且乘累加器的输入数据及时准备好,输出端及时输出运算结果,避免存在堵塞线路的问题,提高了乘累加器运算单元的利用率。Beneficial effects of the present application: The present application provides a multiplication-accumulator operation cluster and a data processing method, wherein the multiplication-accumulator operation cluster includes a plurality of multiplication-accumulator units, each of which includes a plurality of multiplication-accumulator sub-units. When the calculation dimension of two multi-dimensional data in the to-be-processed data is smaller than the total dimension of the multiplication-accumulator unit, the plurality of to-be-processed data are respectively input into a multiplication-accumulator sub-unit. Within the same clock cycle, the plurality of multiplication-accumulator sub-units in each multiplication-accumulator unit can simultaneously perform multiplication-accumulation operations on the to-be-processed data inputted by them, thereby improving the utilization rate of the multiplication-accumulator operation unit and increasing the The output bandwidth of the multiplier-accumulator is increased; when the data to be processed includes multiple sequentially arranged data blocks, one multiplier-accumulator sub-cluster completes a multiplication-accumulation operation of one data block, and outputs the multiplication-accumulation operation result of the data block to the next sequentially arranged multiplier-accumulator sub-cluster, thereby realizing the processing of the data to be processed in a pipeline working mode. In the same clock cycle, multiple multiplier-accumulator sub-clusters process their respective input data at the same time, and the input data of the multiplier-accumulator is prepared in time, and the output end outputs the operation result in time, thereby avoiding the problem of line blocking and improving the utilization rate of the multiplier-accumulator operation unit.

上述说明仅是本申请技术方案的概述,为了能够更清楚了解本申请的技术手段,而可依照说明书的内容予以实施,并且为了让本申请的上述和其它目的、特征和优点能够更明显易懂,以下特举本申请的具体实施方式。The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本申请的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

图1为一种传统的乘累加器单元的结构示意图;FIG1 is a schematic diagram of the structure of a traditional multiplier-accumulator unit;

图2为本申请示例性实施例的一种乘累加器运算集群的结构框图;FIG2 is a block diagram of a multiplier-accumulator operation cluster according to an exemplary embodiment of the present application;

图3为本申请示例性实施例的另一种乘累加器运算集群的结构框图;FIG3 is a structural block diagram of another multiplier-accumulator operation cluster of an exemplary embodiment of the present application;

图4为一种传统的乘累加器单元的运算示意图;FIG4 is a schematic diagram of the operation of a traditional multiply-accumulate unit;

图5为本申请示例性实施例的一种乘累加器单元的运算示意图;FIG5 is a schematic diagram of the operation of a multiplication and accumulation unit according to an exemplary embodiment of the present application;

图6为一种流水线处理方式的待处理数据使用传统的乘累加器单元的示意图;FIG6 is a schematic diagram of a pipeline processing method for processing data using a traditional multiplication and accumulation unit;

图7为本申请示例性实施例的一种流水线处理方式的待处理数据使用乘累加器单元的示意图;FIG7 is a schematic diagram of using a multiplication and accumulation unit for processing data in a pipeline processing manner according to an exemplary embodiment of the present application;

图8为本申请示例性实施例的又一种乘累加器运算集群的结构框图;FIG8 is a structural block diagram of another multiplier-accumulator operation cluster according to an exemplary embodiment of the present application;

图9为本申请示例性实施例的一种乘累加器运算集群的结构连接示意图;FIG9 is a schematic diagram of the structural connection of a multiplier-accumulator operation cluster according to an exemplary embodiment of the present application;

图10为本申请示例性实施例的一种乘累加器子单元的结构连接示意图;FIG10 is a schematic diagram of the structural connection of a multiplier-accumulator subunit of an exemplary embodiment of the present application;

图11为本申请示例性实施例的一种数据处理方法的流程图;FIG11 is a flow chart of a data processing method according to an exemplary embodiment of the present application;

其中,in,

图中的标号如下:1-乘累加器单元;11-乘累加器子单元;2-乘累加器分集群;12-数据输入模块;111-乘运算模块;112-多级加运算模块;113-数据输出模块。The numbers in the figure are as follows: 1-multiplication accumulator unit; 11-multiplication accumulator sub-unit; 2-multiplication accumulator sub-cluster; 12-data input module; 111-multiplication operation module; 112-multi-stage addition operation module; 113-data output module.

具体实施方式DETAILED DESCRIPTION

下文中将参考附图并结合实施例来详细说明本申请。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.

为更进一步阐述本申请为达成预定发明目的所采取的技术手段及功效,以下结合附图及较佳实施例,对依据本申请申请的具体实施方式、结构、特征及其功效,详细说明如后。在下述说明中,不同的“一实施例”或“实施例”指的不一定是同一实施例。此外,一或多个实施例中的特定特征、结构、或特点可由任何合适形式组合。In order to further explain the technical means and effects adopted by the present application to achieve the predetermined invention purpose, the specific implementation methods, structures, features and effects of the present application are described in detail below in conjunction with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures, or characteristics in one or more embodiments may be combined in any suitable form.

在现有技术中,通常使用的乘累加器单元只有一个数据输出端,如图1所示,图中D是数据输出端。如果某AI处理器中有8bits整数的MAC,其中M=32,X =16,M是乘法器的数量。在做通常的卷积运算时,例如做 3乘以3的depthwise(深度方向)卷积运算,进行3乘以3卷积运算时仅使用9个乘法器。通常架构下的MAC只有一个数据输出端,进行运算时用到的乘法器参与计算,用不到的乘法器处于空闲等待状态,如果计算这个3乘以3的卷积,使用的乘法器个数是X’=9,乘累加器单元中的乘法器是32个,会有很多乘法器处于空闲状态,只有等这次卷积计算结束,计算结果输出之后,整个MAC再等待下一次的运算,3乘以3的卷积运算时MAC的运算利用率仅为 9/32,运算利用率比较低。In the prior art, the commonly used multiplier-accumulator unit has only one data output terminal, as shown in FIG1 , where D is the data output terminal. If there is an 8-bit integer MAC in an AI processor, where M=32, X=16, and M is the number of multipliers. When performing a normal convolution operation, such as a 3x3 depthwise convolution operation, only 9 multipliers are used when performing a 3x3 convolution operation. The MAC under the usual architecture has only one data output terminal. The multipliers used in the operation participate in the calculation, and the unused multipliers are in an idle waiting state. If this 3x3 convolution is calculated, the number of multipliers used is X'=9, and there are 32 multipliers in the multiplier-accumulator unit. There will be many multipliers in an idle state. Only after the convolution calculation is completed and the calculation result is output, the entire MAC will wait for the next operation. The operation utilization rate of the MAC during the 3x3 convolution operation is only 9/32, which is relatively low.

本申请提出了一种乘累加器运算集群,如图2所示,乘累加器运算集群包括多个乘累加器单元1,每个乘累加器单元1用于完成至少一组待处理数据的乘累加运算,每组待处理数据包括两个多维度数据,每个乘累加器单元1均包括多个乘累加器子单元11,每个乘累加器子单元11用于完成一次乘累加运算,并输出乘累加运算结果,其中,在待处理数据中的两个多维度数据的计算维度小于乘累加器单元1的总维度时,通过乘累加器单元1中的至少一个乘累加器子单元11完成每组待处理数据的乘累加运算,并输出待处理数据的乘累加运算结果;和/或,如图3所示,在待处理数据包括多个顺序排列的数据块时,通过乘累加器运算集群中的多个乘累加器分集群2分别完成一个数据块的乘累加运算,并将数据块的乘累加运算结果输出到顺序排列的下一个乘累加器分集群2中,直至完成所有数据块的乘累加运算,输出待处理数据的乘累加运算结果。The present application proposes a multiplication-accumulation operation cluster, as shown in FIG2 , the multiplication-accumulation operation cluster includes a plurality of multiplication-accumulation units 1, each of which is used to complete a multiplication-accumulation operation of at least one group of data to be processed, each group of data to be processed includes two multi-dimensional data, each multiplication-accumulation unit 1 includes a plurality of multiplication-accumulation sub-units 11, each of which is used to complete a multiplication-accumulation operation and output a multiplication-accumulation operation result, wherein when the calculation dimension of the two multi-dimensional data in the data to be processed is smaller than the total dimension of the multiplication-accumulation unit 1, the multiplication-accumulation sub-unit 11 is multiplied by the multiplication-accumulation unit 11. At least one multiplication-accumulation sub-unit 11 in the accumulator unit 1 completes the multiplication-accumulation operation of each group of data to be processed, and outputs the multiplication-accumulation operation result of the data to be processed; and/or, as shown in Figure 3, when the data to be processed includes multiple sequentially arranged data blocks, the multiplication-accumulation operation of one data block is completed respectively by multiple multiplication-accumulation sub-clusters 2 in the multiplication-accumulation operation cluster, and the multiplication-accumulation operation result of the data block is output to the next sequentially arranged multiplication-accumulation sub-cluster 2, until the multiplication-accumulation operation of all data blocks is completed, and the multiplication-accumulation operation result of the data to be processed is output.

具体的,乘累加器运算集群包括多个乘累加器单元,每个乘累加器单元包括至少一个乘累加器子单元,每个乘累加器子单元能够对待处理数据进行独立的处理,在同一个时钟周期内,当多组待处理数据分别送入同一个乘累加器单元中的多个乘累加器子单元时,多个乘累加器子单元分别对各自输入的待处理数据进行乘累加运算,各自输出运算结果,实现在同一时钟周期内,同一个乘累加器单元对多个待处理数据进行运算处理,提高了乘累加器单元的运算利用率。Specifically, the multiplication and accumulation operation cluster includes multiple multiplication and accumulation units, each of which includes at least one multiplication and accumulation sub-unit, and each multiplication and accumulation sub-unit can independently process the data to be processed. In the same clock cycle, when multiple groups of data to be processed are respectively sent to multiple multiplication and accumulation sub-units in the same multiplication and accumulation unit, the multiple multiplication and accumulation sub-units respectively perform multiplication and accumulation operations on their respective input data to be processed, and each outputs an operation result, so that in the same clock cycle, the same multiplication and accumulation unit can perform operation processing on multiple data to be processed, thereby improving the operation utilization rate of the multiplication and accumulation unit.

待处理数据的计算维度小于乘累加器单元的维度时,待处理数据使用传统的乘累加器时只能有效利用到很少的MAC算力,如图4,当有乘累加器1/4维度的待处理数据输入时,传统乘累加器单元中只有1/4的乘法器使用,其余乘法器空闲,运算利用率很低。当乘累加器单元被划分为多个乘累加器子单元时,例如如图5所示,乘累加器单元被划分为4个乘累加器子单元时,乘累加器单元的输入总维度不变,每个乘累加器子单元的输入维度为总维度的1/4,在一个时钟周期内,有4组1/4维度的待处理数据各自输入一个乘累加器子单元,每个乘累加器子单元各自进行数据处理,乘累加器单元中每个乘法器都得到了使用,利用到了所有的运算能力,因此提高了运算利用率。When the computational dimension of the data to be processed is smaller than the dimension of the multiplication and accumulation unit, only a small amount of MAC computing power can be effectively utilized when the data to be processed uses the traditional multiplication and accumulation unit. As shown in FIG4, when there is data to be processed with a 1/4 dimension of the multiplication and accumulation unit input, only 1/4 of the multipliers in the traditional multiplication and accumulation unit are used, and the remaining multipliers are idle, and the computing utilization rate is very low. When the multiplication and accumulation unit is divided into multiple multiplication and accumulation sub-units, for example, as shown in FIG5, when the multiplication and accumulation unit is divided into 4 multiplication and accumulation sub-units, the total input dimension of the multiplication and accumulation unit remains unchanged, and the input dimension of each multiplication and accumulation sub-unit is 1/4 of the total dimension. In one clock cycle, there are 4 groups of 1/4 dimension data to be processed, each of which is input into a multiplication and accumulation sub-unit, and each multiplication and accumulation sub-unit performs data processing separately. Each multiplier in the multiplication and accumulation unit is used, and all computing power is utilized, thereby improving the computing utilization rate.

例如,一个乘累加器单元包括4个乘累加器子单元,每个乘累加器子单元包括的乘法器数量都是9,也就是说乘累加器子单元的维度是9,这个乘累加器单元的总维度是36。如果有两组待输入数据,两组待处理数据的计算维度分别是8和9,在同一个时钟周期内,通过该乘累加器单元中的两个乘累加器子单元对这两组待处理数据分别进行乘累加运算,各自得到输出结果,此时乘累加器单元的运算利用率是8+9/36,如果这两个待处理数据通过传统的乘累加器单元进行运算处理,需要两个时钟周期,每个时钟周期处理一组待处理数据,两个时钟周期内的乘累加器单元的运算利用率分别是8/36和9/36,而通过本申请的乘累加器运算集群在同一个时钟周期即可完成,且乘累加器单元的运算利用率高。For example, a multiplication-accumulator unit includes four multiplication-accumulator sub-units, and the number of multipliers included in each multiplication-accumulator sub-unit is 9, that is, the dimension of the multiplication-accumulator sub-unit is 9, and the total dimension of the multiplication-accumulator unit is 36. If there are two groups of data to be input, the calculation dimensions of the two groups of data to be processed are 8 and 9 respectively. In the same clock cycle, the two multiplication-accumulator sub-units in the multiplication-accumulator unit perform multiplication-accumulation operations on the two groups of data to be processed respectively, and each obtains an output result. At this time, the operation utilization rate of the multiplication-accumulator unit is 8+9/36. If the two data to be processed are processed by the traditional multiplication-accumulator unit, two clock cycles are required, and each clock cycle processes a group of data to be processed. The operation utilization rates of the multiplication-accumulator unit in the two clock cycles are 8/36 and 9/36 respectively. However, the multiplication-accumulator operation cluster of the present application can be completed in the same clock cycle, and the operation utilization rate of the multiplication-accumulator unit is high.

当乘累加器运算集群的输入数据没有及时准备好或者乘累加器运算集群的输出数据没有及时输出,造成线路阻塞,导致乘累加器运算集群不能进入下一次的使用,也会导致乘累加器运算单元利用率低。When the input data of the multiplier-accumulator operation cluster is not prepared in time or the output data of the multiplier-accumulator operation cluster is not output in time, the line is blocked, resulting in the multiplier-accumulator operation cluster being unable to enter the next use, which also leads to low utilization of the multiplier-accumulator operation unit.

当待处理数据是按流水作业处理方式进行处理的数据时,如果使用传统的乘累计器,待处理数据通过乘累加器进行第一次乘累加运算后,运算结果再输入这个乘累加器,进行第二次乘累加运算,运算结果再输入这个乘累加器单元,直至待处理数据的运算结束为止,乘累加器的运算利用率比较低。When the data to be processed is data to be processed in an assembly line processing manner, if a traditional multiplier-accumulator is used, after the data to be processed passes through the multiplier-accumulator for the first multiplication-accumulation operation, the operation result is input into the multiplication-accumulator again for the second multiplication-accumulation operation, and the operation result is input into the multiplication-accumulator unit again until the operation of the data to be processed is completed. The operation utilization rate of the multiplication-accumulator is relatively low.

因此针对按流水作业处理方式进行处理的数据,将乘累加器运算集群分成多个乘累加器分集群,多个乘累加器分集群按顺序排列,待处理数据包括多个顺次排列的数据块,每个时钟周期有一个数据块输入至第一排列次序的累加器分集群,在第一个时钟周期内,第一排列次序的乘累加器分集群对输入的数据进行处理,处理结果被传输至第二排列次序的乘累加器分集群的数据输入端,在第二个时钟周期内,第一排列次序的乘累加器分集群有新的数据块进入,第一排列次序的乘累加器分集群和第二排列次序的乘累加器分集群各自对输入的数据进行处理,第二排列次序的乘累加器分集群的处理结果被传输至第三排列次序的乘累加器分集群的数据输入端,第一排列次序的乘累加器分集群的处理结果被传输至第二排列次序的乘累加器分集群的数据输入端,在第三个时钟周期,新的数据块被送入第一排列次序的乘累加器分集群的输入端,重复上述过程,将前一排列次序的乘累加器分集群的输出数据输入至相邻的后一排列次序的乘累加器分集群的数据输入端,使得在同一个时钟周期内,多个乘累加器分集群同时对各自输入的数据进行处理,且使得每个乘累加器分集群的数据输入端及时准备好数据,数据输出端及时将数据取走,提高了乘累加器的运算利用率。Therefore, for data processed in a pipeline processing manner, the multiplication and accumulation unit operation cluster is divided into a plurality of multiplication and accumulation unit sub-clusters, and the plurality of multiplication and accumulation unit sub-clusters are arranged in sequence. The data to be processed includes a plurality of sequentially arranged data blocks. In each clock cycle, one data block is input to the accumulator sub-clusters in the first arrangement order. In the first clock cycle, the multiplication and accumulation unit sub-clusters in the first arrangement order process the input data, and the processing result is transmitted to the data input end of the multiplication and accumulation unit sub-clusters in the second arrangement order. In the second clock cycle, a new data block enters the multiplication and accumulation unit sub-clusters in the first arrangement order. The multiplication and accumulation unit sub-clusters in the first arrangement order and the multiplication and accumulation unit sub-clusters in the second arrangement order respectively process the input data, and the multiplication and accumulation unit sub-clusters in the second arrangement order are transmitted to the data input end of the multiplication and accumulation unit sub-clusters in the second arrangement order. The processing results of the clusters are transmitted to the data input terminals of the multiplier-accumulator sub-clusters of the third arrangement order, and the processing results of the multiplier-accumulator sub-clusters of the first arrangement order are transmitted to the data input terminals of the multiplier-accumulator sub-clusters of the second arrangement order. In the third clock cycle, a new data block is sent to the input terminals of the multiplier-accumulator sub-clusters of the first arrangement order, and the above process is repeated to input the output data of the multiplier-accumulator sub-clusters of the previous arrangement order to the data input terminals of the adjacent multiplier-accumulator sub-clusters of the next arrangement order, so that in the same clock cycle, multiple multiplier-accumulator sub-clusters process their respective input data at the same time, and the data input terminals of each multiplier-accumulator sub-cluster prepare data in time, and the data output terminals take away data in time, thereby improving the operational utilization of the multiplier-accumulators.

例如,神经网络模型的处理过程经常被定义为按先后顺序的若干个layer网络层的运算过程。通常情况下若干个layer网络层的计算过程是,layer1网络层调用整个 MAC来进行运算,其输入输出带宽皆为W,MAC运算结果是layer2网络层的输入数据,layer1网络层全部运算完毕后,layer2网络层继续调用整个 MAC来进行运算,直到完成整个计算为止,如图6所示,可以认为是AI加速器系统中对MAC的分时复用,也就是说每个layer网络层使用整个MAC,MAC的运算利用率比较低,此时的带宽可认为是每个layer网络层的带宽。For example, the processing of a neural network model is often defined as the operation process of several layer network layers in sequence. Usually, the calculation process of several layer network layers is that the layer1 network layer calls the entire MAC to perform calculations, and its input and output bandwidths are both W. The MAC calculation result is the input data of the layer2 network layer. After all the calculations of the layer1 network layer are completed, the layer2 network layer continues to call the entire MAC to perform calculations until the entire calculation is completed. As shown in Figure 6, it can be considered as the time-sharing multiplexing of MAC in the AI accelerator system, that is, each layer network layer uses the entire MAC, and the calculation utilization rate of MAC is relatively low. The bandwidth at this time can be considered as the bandwidth of each layer network layer.

本申请提出的乘累加器运算集群包括多个乘累加器分集群,例如乘累加器运算集群包括4个乘累加器分集群P1_MAC、P2_MAC、P3_MAC、P4_MAC。多个layer网络层之间采用流水作业的处理方式,将layer1网络层使用乘累加器分集群P1_MAC进行运算处理,layer2网络层使用乘累加器分集群P2_MAC进行运算处理,layer3网络层使用乘累加器分集群P3_MAC进行运算处理,layer4网络层使用乘累加器分集群P4_MAC进行运算处理。在第一个时钟周期,待处理数据输入至乘累加器分集群P1_MAC的输入端,乘累加器分集群P1_MAC运算处理结束之后,将乘累加器分集群P1_MAC的运算处理结果作为乘累加器分集群P2_MAC的输入数据,在第二个时钟周期,新的待处理数据输入至乘累加器分集群P1_MAC的输入端,乘累加器分集群P1_MAC和乘累加器分集群P2_MAC同时对各自输入的数据进行运算处理,运算结束之后,将乘累加器分集群P1_MAC的运算处理结果作为乘累加器分集群P2_MAC的输入数据,乘累加器分集群P2_MAC的运算处理结果作为乘累加器分集群P3_MAC的输入数据,类似地,将前一排列次序的乘累加器分集群的处理结果作为下一排列次序的乘累加器分集群的输入数据,如图7所示,P1_MAC有待处理数据依次输入,相应的P2_MAC~P4_MAC也依次有待处理数据依次输入,在同一个时钟周期内,P1_MAC~P4_MAC各自对输入的数据进行运算处理,整个乘累加器分集群的总的算力得到提高,输出带宽变为每个layer网络层的带宽之和,可以认为输出带宽变为原来的4倍,满足了增大带宽的目的,但是每个乘累加器分集群的输出带宽不变。The multiplier-accumulator operation cluster proposed in the present application includes multiple multiplier-accumulator sub-clusters, for example, the multiplier-accumulator operation cluster includes four multiplier-accumulator sub-clusters P1_MAC, P2_MAC, P3_MAC, and P4_MAC. A pipeline operation is used between multiple layer network layers, where the layer1 network layer uses the multiplier-accumulator sub-cluster P1_MAC for operation processing, the layer2 network layer uses the multiplier-accumulator sub-cluster P2_MAC for operation processing, the layer3 network layer uses the multiplier-accumulator sub-cluster P3_MAC for operation processing, and the layer4 network layer uses the multiplier-accumulator sub-cluster P4_MAC for operation processing. In the first clock cycle, the data to be processed is input to the input end of the multiplication and accumulation sub-cluster P1_MAC. After the operation of the multiplication and accumulation sub-cluster P1_MAC is completed, the operation result of the multiplication and accumulation sub-cluster P1_MAC is used as the input data of the multiplication and accumulation sub-cluster P2_MAC. In the second clock cycle, new data to be processed is input to the input end of the multiplication and accumulation sub-cluster P1_MAC. The multiplication and accumulation sub-cluster P1_MAC and the multiplication and accumulation sub-cluster P2_MAC perform operation on their respective input data at the same time. After the operation is completed, the operation result of the multiplication and accumulation sub-cluster P1_MAC is used as the input data of the multiplication and accumulation sub-cluster P2_MAC. The result is used as the input data of the multiplier-accumulator sub-cluster P3_MAC. Similarly, the processing result of the multiplier-accumulator sub-cluster of the previous arrangement order is used as the input data of the multiplier-accumulator sub-cluster of the next arrangement order. As shown in Figure 7, P1_MAC has data to be processed input in sequence, and the corresponding P2_MAC~P4_MAC also have data to be processed input in sequence. In the same clock cycle, P1_MAC~P4_MAC each calculates and processes the input data, and the total computing power of the entire multiplier-accumulator sub-cluster is improved. The output bandwidth becomes the sum of the bandwidth of each layer network layer. It can be considered that the output bandwidth becomes 4 times the original, which meets the purpose of increasing the bandwidth, but the output bandwidth of each multiplier-accumulator sub-cluster remains unchanged.

乘累加器运算集群包括多个乘累加器单元,每个乘累加器单元包括至少一个乘累加器子单元,每个乘累加器子单元能够对待处理数据进行独立的处理,实现在同一时钟周期内,提高了乘累加器单元的运算利用率,但是乘累加器单元的输出带宽增加很多,增加的输出带宽可能会造成后续的处理模块不能及时进行处理,如果乘累加器单元输出的数据不能及时被取走,该乘累加器单元不能进行下一次的运算,造成线路堵塞,影响乘累加器单元的运算效率,因此,将乘累加器子单元与乘累加器分集群结合,至少一个乘累加器子单元构成乘累加器分集群,如图8所示,一个乘累加器子单元作为一个乘累加器分集群,按排列顺次,将前一乘累加器子单元的输出数据送入下一乘累加器子单元的数据输入端,使得乘累加器子单元的输出数据及时处理,不造成线路堵塞,提高了乘累加运算集群的运算利用率。The multiplication and accumulation operation cluster includes a plurality of multiplication and accumulation units, each of which includes at least one multiplication and accumulation sub-unit. Each multiplication and accumulation sub-unit can independently process the data to be processed within the same clock cycle, thereby improving the operation utilization rate of the multiplication and accumulation unit. However, the output bandwidth of the multiplication and accumulation unit increases a lot. The increased output bandwidth may cause the subsequent processing module to fail to process in time. If the data output by the multiplication and accumulation unit cannot be taken away in time, the multiplication and accumulation unit cannot perform the next operation, causing line congestion, and affecting the operation efficiency of the multiplication and accumulation unit. Therefore, the multiplication and accumulation sub-unit is combined with the multiplication and accumulation sub-cluster, and at least one multiplication and accumulation sub-unit constitutes the multiplication and accumulation sub-cluster. As shown in FIG8 , a multiplication and accumulation sub-unit is used as a multiplication and accumulation sub-cluster. The output data of the previous multiplication and accumulation sub-unit is sent to the data input end of the next multiplication and accumulation sub-unit in order of arrangement, so that the output data of the multiplication and accumulation sub-unit is processed in time without causing line congestion, thereby improving the operation utilization rate of the multiplication and accumulation operation cluster.

与现有技术相比,本申请提供的一种乘累加器运算集群,乘累加器运算集群包括多个乘累加器单元,每个乘累加器单元均包括多个乘累加器子单元,当待处理数据中的两个多维度数据的计算维度小于乘累加器单元的总维度时,在同一个时钟周期内,每个乘累加器单元中的多个乘累加器子单元能够同时对各自输入的待处理数据进行乘累加运算,提高乘累加器运算单元的利用率,还增大了乘累加器的输出带宽;当待处理数据包括多个顺序排列的数据块时,一个乘累加器分集群完成一个数据块的一次乘累加运算,并将该数据块的乘累加运算结果输出到顺序排列的下一个乘累加器分集群中,实现待处理数据的流水线工作方式的处理,在同一个时钟周期内,多个乘累加器分集群同时对各自输入的数据进行处理,且乘累加器的输入数据及时准备好,输出端及时输出运算结果,避免存在堵塞线路的问题,提高了乘累加器运算单元的利用率。Compared with the prior art, the present application provides a multiplication-accumulator operation cluster, which includes multiple multiplication-accumulator units, each of which includes multiple multiplication-accumulator sub-units. When the calculation dimension of two multi-dimensional data in the data to be processed is smaller than the total dimension of the multiplication-accumulator unit, within the same clock cycle, the multiple multiplication-accumulator sub-units in each multiplication-accumulator unit can simultaneously perform multiplication-accumulation operations on the data to be processed that are input by each of them, thereby improving the utilization rate of the multiplication-accumulator operation unit and increasing the output bandwidth of the multiplication-accumulator. When the data to be processed includes multiple sequentially arranged data blocks, a multiplication-accumulator sub-cluster completes a multiplication-accumulation operation of a data block, and outputs the multiplication-accumulation operation result of the data block to the next sequentially arranged multiplication-accumulator sub-cluster, thereby realizing the processing of the data to be processed in a pipeline working mode. Within the same clock cycle, multiple multiplication-accumulator sub-clusters simultaneously process the data input by each of them, and the input data of the multiplication-accumulator is prepared in time, and the output end outputs the operation result in time, thereby avoiding the problem of line blockage and improving the utilization rate of the multiplication-accumulator operation unit.

在一个实施例中,同一个乘累加器单元中的乘累加器子单元的维度相同,每个乘累加器单元中的所有乘累加器子单元的维度的总和与乘累加器单元的总维度相同,且多个不同的乘累加器单元中的乘累加器子单元的维度彼此相同或不同。In one embodiment, the dimensions of the multiplication accumulator sub-units in the same multiplication accumulator unit are the same, the sum of the dimensions of all the multiplication accumulator sub-units in each multiplication accumulator unit is the same as the total dimension of the multiplication accumulator unit, and the dimensions of the multiplication accumulator sub-units in multiple different multiplication accumulator units are the same as or different from each other.

具体的,乘累加器单元包含的乘法器的数量就是乘累加器单元的维度,同一乘累加器单元包括的乘累加器子单元中的乘法器数量相同,每个乘累加器中所有乘累加子单元的乘法器的总数量等于每个乘累加器单元的总维度。乘累加器运算集群中有多个乘累加器单元,多个乘累加器单元中必须存在乘法器数量不同的一些乘累加器单元,相同乘法器数量的乘累加单元的数量可以为多个。例如乘累加器运算集群包括多个乘累加器单元,其中,两个乘累加器单元中的乘累加器子单元包括的乘法器数量都是9,一个乘累加器单元中的乘累加器子单元包括的乘法器数量都是12,一个乘累加器单元中的乘累加器子单元包括的乘法器数量都是16等。Specifically, the number of multipliers included in the multiplication-accumulator unit is the dimension of the multiplication-accumulator unit. The number of multipliers in the multiplication-accumulator sub-units included in the same multiplication-accumulator unit is the same, and the total number of multipliers in all the multiplication-accumulation sub-units in each multiplication-accumulator is equal to the total dimension of each multiplication-accumulator unit. There are multiple multiplication-accumulator units in the multiplication-accumulator operation cluster, and there must be some multiplication-accumulator units with different numbers of multipliers in the multiple multiplication-accumulator units. The number of multiplication-accumulator units with the same number of multipliers can be multiple. For example, the multiplication-accumulator operation cluster includes multiple multiplication-accumulator units, wherein the number of multipliers included in the multiplication-accumulator sub-units in two multiplication-accumulator units is 9, the number of multipliers included in the multiplication-accumulator sub-unit in one multiplication-accumulator unit is 12, the number of multipliers included in the multiplication-accumulator sub-unit in one multiplication-accumulator unit is 16, and so on.

在一个实施例中,当一组待处理数据的计算维度小于或等于至少一个乘累加器单元中乘累加器子单元的维度时,根据待处理数据的计算维度和乘累加器单元中乘累加器子单元的维度,确定运算待处理数据的目标乘累加器单元,通过目标乘累加器单元中的乘累加器子单元对待处理数据进行乘累加运算。In one embodiment, when the computational dimension of a group of data to be processed is less than or equal to the dimension of a multiplication-accumulator sub-unit in at least one multiplication-accumulator unit, a target multiplication-accumulator unit for operating the data to be processed is determined based on the computational dimension of the data to be processed and the dimension of the multiplication-accumulator sub-unit in the multiplication-accumulator unit, and multiplication-accumulation operations are performed on the data to be processed through the multiplication-accumulator sub-unit in the target multiplication-accumulator unit.

具体的,当一组待处理数据的计算维度小于或等于至少一个乘累加器单元中乘累加器子单元的维度时,将该组处理数据的计算维度与这些乘累加器单元中乘累加器子单元的维度做比较,选择计算维度与乘累加器子单元的维度的差值最小的乘累加器单元作为目标乘累加器单元,通过目标乘累加器单元中处于空闲状态的乘累加器子单元进行乘加运算。例如,多个乘累加器单元中的乘累加子单元的维度分为是6、9、12和16,待处理数据需要使用的乘法器数量是8个时,将乘累加器子单元的维度大于8的乘累加器单元作为候选乘累加器单元,即乘累加器子单元的维度是9、12和16的乘累加器单元作为候选乘累加器单元,获取计算维度与每个候选乘累加器中乘累加器子单元的维度的差值,差值最小的是乘累加器子单元的维度是9的候选乘累加器单元,将这个候选乘累加器单元作为目标乘累加器单元。Specifically, when the computational dimension of a group of data to be processed is less than or equal to the dimension of a multiplication accumulator sub-unit in at least one multiplication accumulator unit, the computational dimension of the group of processed data is compared with the dimensions of the multiplication accumulator sub-units in these multiplication accumulator units, and the multiplication accumulator unit with the smallest difference between the computational dimension and the dimension of the multiplication accumulator sub-unit is selected as the target multiplication accumulator unit, and multiplication and addition operations are performed using the multiplication accumulator sub-units in the target multiplication accumulator unit that are in an idle state. For example, when the dimensions of the multiplication and accumulation sub-units in multiple multiplication and accumulation units are 6, 9, 12 and 16, and the number of multipliers required for processing data is 8, the multiplication and accumulation units whose dimensions are greater than 8 are taken as candidate multiplication and accumulation units, that is, the multiplication and accumulation units whose dimensions are 9, 12 and 16 are taken as candidate multiplication and accumulation units, and the difference between the calculation dimension and the dimension of the multiplication and accumulation sub-unit in each candidate multiplication and accumulation unit is obtained. The candidate multiplication and accumulation unit with the smallest difference is the candidate multiplication and accumulation unit with the dimension of the multiplication and accumulation sub-unit being 9, and this candidate multiplication and accumulation unit is taken as the target multiplication and accumulation unit.

在一个实施例中,当一组待处理数据的计算维度大于所有乘累加器单元中乘累加器子单元的维度且小于每个乘累加器单元的总维度时,通过乘累加器单元中的多个乘累加器子单元完成待处理数据的乘累加运算。In one embodiment, when the computational dimension of a set of data to be processed is greater than the dimension of the multiplication and accumulation sub-units in all the multiplication and accumulation units and less than the total dimension of each multiplication and accumulation unit, the multiplication and accumulation operation of the data to be processed is completed by multiple multiplication and accumulation sub-units in the multiplication and accumulation unit.

具体的,当一组待处理数据的计算维度大于所有乘累加器单元中乘累加器子单元的维度时,说明不能使用乘累加器单元中的一个乘累加器子单元进行运算处理,需要使用乘累加器单元中的多个乘累加器子单元合并处理该待处理数据,即通过乘累加器单元中的多个乘累加器子单元共同处理该待处理数据。Specifically, when the computational dimension of a group of data to be processed is larger than the dimension of the multiplication accumulator sub-units in all the multiplication accumulator units, it means that one multiplication accumulator sub-unit in the multiplication accumulator unit cannot be used for calculation and processing, and it is necessary to use multiple multiplication accumulator sub-units in the multiplication accumulator unit to combine and process the data to be processed, that is, the data to be processed is jointly processed by multiple multiplication accumulator sub-units in the multiplication accumulator unit.

在一个实施例中,在待处理数据的计算维度大于所有乘累加器单元中乘累加器子单元的维度且小于每个乘累加器单元的总维度时,根据待处理数据的计算维度和每个乘累加器单元中乘累加器子单元的维度,确定运算待处理数据的目标乘累加器以及目标乘累加器中乘累加器子单元的目标数量,通过目标乘累加器中目标数量的乘累加器子单元对待处理数据进行乘累积运算。In one embodiment, when the computational dimension of the data to be processed is greater than the dimension of the multiplication accumulator sub-units in all the multiplication accumulator units and less than the total dimension of each multiplication accumulator unit, a target multiplication accumulator for operating the data to be processed and a target number of multiplication accumulator sub-units in the target multiplication accumulator are determined according to the computational dimension of the data to be processed and the dimension of the multiplication accumulator sub-units in each multiplication accumulator unit, and multiplication and accumulation operations are performed on the data to be processed through the target number of multiplication accumulator sub-units in the target multiplication accumulator.

具体的,当一组待处理数据的计算维度大于所有乘累加器单元中乘累加器子单元的维度时,需要使用乘累加器单元中的多个乘累加器子单元沟通处理该待处理数据。将该待处理数据的计算维度与任一乘累加器单元中乘累加器子单元的维度的商加一作为目标数量,通过这个乘累加器单元中目标数量个乘累加器子单元对该待处理数据进行运算处理。Specifically, when the computational dimension of a group of data to be processed is greater than the dimension of the multiplication accumulator subunits in all the multiplication accumulator units, it is necessary to use multiple multiplication accumulator subunits in the multiplication accumulator unit to communicate and process the data to be processed. The quotient of the computational dimension of the data to be processed and the dimension of the multiplication accumulator subunit in any multiplication accumulator unit plus one is used as the target number, and the data to be processed is processed by the target number of multiplication accumulator subunits in this multiplication accumulator unit.

在一个实施例中,乘累加器运算集群中的至少一个乘累加器子单元作为一个乘累加器分集群。In one embodiment, at least one MACC sub-unit in a MACC operation cluster serves as a MACC sub-cluster.

具体的,当同一个乘累加器单元中的多个乘累加器子单元各自独立进行运算处理时,提高了乘累加器单元的运算利用率,但同时乘累加器单元的输出带宽变为原来的多倍,输出带宽的增加会导致处理线路阻塞。因此,将至少一个乘累加器子单元作为一个乘累加器分集群,通过乘累加器分集群对待处理数据进行流水作业方式处理,也就是将前一排列次序的乘累加器分集群输出的数据输入至后一排列次序的乘累加器分集群的数据输入端,这样虽然乘累加器单元的输出带宽增大,但是乘累加器子单元的输出数据及时被处理,不会产生堵塞现象,提高了乘累加器的运算利用率。Specifically, when multiple MACC subunits in the same MACC unit perform calculation processing independently, the calculation utilization rate of the MACC unit is improved, but at the same time, the output bandwidth of the MACC unit becomes multiple times of the original, and the increase in output bandwidth will cause processing line blockage. Therefore, at least one MACC subunit is used as a MACC sub-cluster, and the MACC sub-cluster processes the data to be processed in a pipeline operation manner, that is, the data output by the MACC sub-cluster of the previous arrangement order is input to the data input end of the MACC sub-cluster of the next arrangement order. In this way, although the output bandwidth of the MACC unit is increased, the output data of the MACC subunit is processed in time, and no blockage occurs, thereby improving the calculation utilization rate of the MACC.

在一个实施例中,当待处理数据中所有数据块的计算维度均小于或等于任一乘累加器单元中乘累加器子单元的维度时,将乘累加器单元中的每个乘累加器子单元作为一个乘累加器分集群,通过乘累加器单元中的多个乘累加器子单元分别完成一个数据块的乘累加运算,并将数据块的乘累加运算结果输出到顺序排列的下一个乘累加器子单元,直至完成所有数据块的乘累加运算,输出待处理数据的乘累加运算结果。In one embodiment, when the computational dimensions of all data blocks in the data to be processed are less than or equal to the dimensions of the multiplication-accumulator sub-unit in any multiplication-accumulator unit, each multiplication-accumulator sub-unit in the multiplication-accumulator unit is used as a multiplication-accumulator sub-cluster, and the multiplication-accumulation operation of one data block is completed respectively by multiple multiplication-accumulator sub-units in the multiplication-accumulator unit, and the multiplication-accumulation operation result of the data block is output to the next multiplication-accumulation sub-unit arranged in sequence, until the multiplication-accumulation operation of all data blocks is completed, and the multiplication-accumulation operation result of the data to be processed is output.

具体的,当待处理数据中所有数据块的计算维度均小于或等于任一乘累加器单元中乘累加器子单元的维度时,且这些数据块的第一次运算结果需要进行再一次的乘累加运算时,即按流水作业处理方式处理时,将乘累加器单元中的每个乘累加器子单元作为一个乘累加器分集群,通过乘累加器分集群对待处理数据进行流水作业方式处理,也就是将前一排列次序的乘累加器子单元输出的数据输入至后一排列次序的乘累加器子单元,这样虽然乘累加器单元的输出带宽增大,但是乘累加器子单元的输出带宽不变,不会产生堵塞现象,提高了乘累加器的运算利用率。Specifically, when the computational dimensions of all data blocks in the data to be processed are less than or equal to the dimensions of the multiplication and accumulation sub-units in any multiplication and accumulation unit, and the first operation results of these data blocks need to be subjected to another multiplication and accumulation operation, that is, when processed in an assembly line processing manner, each multiplication and accumulation sub-unit in the multiplication and accumulation unit is used as a multiplication and accumulation sub-cluster, and the data to be processed is processed in an assembly line manner through the multiplication and accumulation sub-clusters, that is, the data output by the multiplication and accumulation sub-unit of the previous arrangement order is input into the multiplication and accumulation sub-unit of the next arrangement order. In this way, although the output bandwidth of the multiplication and accumulation unit is increased, the output bandwidth of the multiplication and accumulation sub-unit remains unchanged, and no congestion will occur, thereby improving the computational utilization rate of the multiplication and accumulation unit.

在一个实施例中,如图9所示,乘累加器单元包括多个数据输入模块12、多个乘运算模块111、多个多级加运算模块112和多个数据输出模块113,其中,一个乘运算模块111、一个多级加运算模块112和多个数据输出模块113构成一个乘累加器子单元11,每个乘运算模块包括多个乘法器,每个多级加运算模块包括多个加法器;每个数据输入模块12的输入端分别与数据提供模块电连接,每个数据输入模块12的输出端分别与一个乘运算模块111的输入端电连接,每个乘运算模块111的输出端与一个多级加运算模块112的输入端电连接,每个多级加运算模块112的输出端分别与多个数据输出模块113电连接。In one embodiment, as shown in FIG9 , the multiplier-accumulator unit includes a plurality of data input modules 12, a plurality of multiplication operation modules 111, a plurality of multi-stage addition operation modules 112 and a plurality of data output modules 113, wherein one multiplication operation module 111, one multi-stage addition operation module 112 and a plurality of data output modules 113 constitute a multiplication-accumulator subunit 11, each multiplication operation module includes a plurality of multipliers, and each multi-stage addition operation module includes a plurality of adders; the input end of each data input module 12 is respectively electrically connected to the data providing module, the output end of each data input module 12 is respectively electrically connected to the input end of a multiplication operation module 111, the output end of each multiplication operation module 111 is respectively electrically connected to the input end of a multi-stage addition operation module 112, and the output end of each multi-stage addition operation module 112 is respectively electrically connected to the plurality of data output modules 113.

具体的,乘累加器单元包括多个数据输入模块、多个乘运算模块、多个多级加运算模块和多个数据输出模块,一个乘运算模块、一个多级加运算模块和多个数据输出模块构成一个乘累加器子单元。针对每个乘累加器子单元,数据提供模块将待处理数据输入至数据输入模块的输入端,数据输入模块的输出端将数据传输至乘运算模块的输入端,乘运算模块对输入的数据进行乘运算,然后将乘运算结果输出至多级加运算模块的输入端,多级加运算模块对输入的数据进行累加运算,得到多个累加运算结果,将每个累加运算结果输出至一个数据输出模块。Specifically, the multiplication and accumulation unit includes a plurality of data input modules, a plurality of multiplication operation modules, a plurality of multi-stage addition operation modules and a plurality of data output modules, and one multiplication operation module, one multi-stage addition operation module and a plurality of data output modules constitute a multiplication and accumulation sub-unit. For each multiplication and accumulation sub-unit, the data providing module inputs the data to be processed into the input end of the data input module, the output end of the data input module transmits the data to the input end of the multiplication operation module, the multiplication operation module performs multiplication operation on the input data, and then outputs the multiplication operation result to the input end of the multi-stage addition operation module, the multi-stage addition operation module performs accumulation operation on the input data to obtain a plurality of accumulation operation results, and outputs each accumulation operation result to a data output module.

如图10所示,多个乘法器组成乘运算模块,多个加法器组成多级加运算模块,多个数据输出端C1、C2、C3、C4和D,输入数据是A1...A16,输入数据是B1...A16。乘运算模块、多级加运算模块和多个数据输出端作为一个乘累加器子单元。As shown in Fig. 10, a plurality of multipliers form a multiplication operation module, a plurality of adders form a multi-stage addition operation module, a plurality of data output terminals C1, C2, C3, C4 and D, the input data is A1 ... A16, and the input data is B1 ... A16. The multiplication operation module, the multi-stage addition operation module and the plurality of data output terminals serve as a multiplication accumulator subunit.

本申请还提供一种数据处理方法,应用于上述的乘累加器运算集群,数据处理方法,如图11所示,包括:The present application also provides a data processing method, which is applied to the above-mentioned multiplication and accumulation operation cluster. The data processing method, as shown in FIG11, includes:

112:获取待处理数据,根据待处理数据的计算维度和每个乘累加器单元中的乘累加器子单元的维度,确定待处理数据对应的目标乘累加器单元;112: Obtain the data to be processed, and determine the target multiplication and accumulation unit corresponding to the data to be processed according to the calculation dimension of the data to be processed and the dimension of the multiplication and accumulation subunit in each multiplication and accumulation unit;

114:将待处理数据输入至目标乘累加器中处于空闲状态的乘累加器子单元中,通过目标乘累加器对待处理数据进行乘累加运算,得到待处理数据的乘累加运算结果。114: Input the data to be processed into the multiplication and accumulation subunit in the target multiplication and accumulation unit that is in an idle state, and perform multiplication and accumulation operations on the data to be processed through the target multiplication and accumulation unit to obtain the multiplication and accumulation operation results of the data to be processed.

具体的,根据待处理数据的计算维度和每个乘累加器单元中的乘累加器子单元的维度,确定待处理数据对应的目标乘累加器单元,通过目标乘累加器中处于空闲状态的乘累加器子单元对待处理数据进行乘累加运算,得到待处理数据的乘累加运算结果。Specifically, according to the calculation dimension of the data to be processed and the dimension of the multiplication and accumulation unit sub-unit in each multiplication and accumulation unit, the target multiplication and accumulation unit corresponding to the data to be processed is determined, and the multiplication and accumulation operation is performed on the data to be processed by the multiplication and accumulation sub-unit in the target multiplication and accumulation unit that is in an idle state to obtain the multiplication and accumulation operation result of the data to be processed.

例如,当待处理数据的计算维度是8,多个乘累加器单元中乘累加子单元的维度分别是6,9,12,16,选择乘累加器单元中每个乘累加器子单元的维度是9的乘累加器单元作为目标乘累加器单元,通过目标乘累加器单元中处于空闲状态的乘累加器子单元对待处理数据进行乘累加运算。For example, when the calculation dimension of the data to be processed is 8, and the dimensions of the multiplication and accumulation sub-units in multiple multiplication and accumulation units are 6, 9, 12, and 16 respectively, a multiplication and accumulation unit in which the dimension of each multiplication and accumulation sub-unit in the multiplication and accumulation unit is 9 is selected as the target multiplication and accumulation unit, and multiplication and accumulation operations are performed on the data to be processed through the multiplication and accumulation sub-units in the target multiplication and accumulation unit that are in an idle state.

当有多组待处理数据都需要进行处理时,分别确定每组待处理数据对应的目标乘累加器单元,将该组待处理数据输入至其对应的目标乘累加器单元,实现多个目标乘累加器单元对各自输入的数据进行同时处理,提高了乘累加器运算集群的数据处理效率。When there are multiple groups of data to be processed, the target multiplier-accumulator unit corresponding to each group of data to be processed is determined respectively, and the group of data to be processed is input into its corresponding target multiplier-accumulator unit, so that multiple target multiplier-accumulator units can simultaneously process their respective input data, thereby improving the data processing efficiency of the multiplier-accumulator operation cluster.

在一个实施例中,获取待处理数据,根据待处理数据的计算维度和每个乘累加器单元中的乘累加器子单元的子维度,确定待处理数据对应的目标乘累加器单元,包括:In one embodiment, obtaining data to be processed, and determining a target multiplication and accumulation unit corresponding to the data to be processed according to a calculation dimension of the data to be processed and a sub-dimension of a multiplication and accumulation unit in each multiplication and accumulation unit, comprises:

将乘累加器单元中乘累加器子单元的维度大于或等于待处理数据的计算维度的乘累加器单元作为候选乘累加器单元;将处于空闲工作状态且乘累加器子单元的维度最大的候选乘累加器单元作为待处理数据对应的目标乘累加器单元。A multiplication accumulator unit in which the dimension of the multiplication accumulator sub-unit is greater than or equal to the calculation dimension of the data to be processed is taken as a candidate multiplication accumulator unit; a candidate multiplication accumulator unit that is in an idle working state and has the largest dimension of the multiplication accumulator sub-unit is taken as a target multiplication accumulator unit corresponding to the data to be processed.

具体的,比较待处理数据的计算维度和每个乘累加器单元中乘累加器子单元的维度,将乘累加器子单元的维度大于或等于待处理数据的计算维度的乘累加器单元作为候选乘累加器单元,候选累加器单元有多个,从多个候选乘累加器单元中选出处于空闲状态且乘累加器子单元的维度最大的候选乘累加器单元作为目标乘累加器单元,使用目标乘累加器单元对待处理数据进行乘加运算。Specifically, the computational dimension of the data to be processed and the dimension of the multiplication accumulator sub-unit in each multiplication accumulator unit are compared, and the multiplication accumulator unit whose dimension of the multiplication accumulator sub-unit is greater than or equal to the computational dimension of the data to be processed is taken as a candidate multiplication accumulator unit. There are multiple candidate accumulator units, and a candidate multiplication accumulator unit that is in an idle state and has the largest dimension of its multiplication accumulator sub-unit is selected from the multiple candidate multiplication accumulator units as the target multiplication accumulator unit, and the target multiplication accumulator unit is used to perform multiplication and addition operations on the data to be processed.

与现有技术相比,本申请提供的一种数据处理方法,根据待处理数据的计算维度和每个乘累加器单元中乘累加器子单元包括的维度,确定待处理数据对应的目标乘累加器单元,将待处理数据输入至目标乘累加器单元中的乘累加器子单元的数据输入端,由于目标乘累加器单元中的多个乘累加器子单元能够独立工作,多个乘累加器子单元能够同时进行数据处理,提高了乘累加器模块的运算利用率和总输出带宽。Compared with the prior art, the present application provides a data processing method, which determines the target multiplication accumulator unit corresponding to the data to be processed according to the calculation dimension of the data to be processed and the dimension included in the multiplication accumulator sub-unit in each multiplication accumulator unit, and inputs the data to be processed into the data input end of the multiplication accumulator sub-unit in the target multiplication accumulator unit. Since the multiple multiplication accumulator sub-units in the target multiplication accumulator unit can work independently, the multiple multiplication accumulator sub-units can process data simultaneously, thereby improving the computational utilization and total output bandwidth of the multiplication accumulator module.

应理解的是,可以对此处申请的实施例做出各种修改。因此,上述说明书不应该视为限制,而仅是作为实施例的范例。本领域的技术人员将想到在本申请的范围和精神内的其他修改。It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of the embodiments. Other modifications within the scope and spirit of the present application will occur to those skilled in the art.

包含在说明书中并构成说明书的一部分的附图示出了本申请的实施例,并且与上面给出的对本申请的大致描述以及下面给出的对实施例的详细描述一起用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.

通过下面参照附图对给定为非限制性实例的实施例的优选形式的描述,本申请的这些和其它特性将会变得显而易见。These and other characteristics of the present application will become apparent from the following description of a preferred form of embodiment given as a non-limiting example with reference to the accompanying drawings.

还应当理解,尽管已经参照一些具体实例对本申请进行了描述,但本领域技术人员能够确定地实现本申请的很多其它等效形式。It should also be understood that although the present application has been described with reference to some specific examples, those skilled in the art will be able to readily implement many other equivalent forms of the present application.

当结合附图时,鉴于以下详细说明,本申请的上述和其他方面、特征和优势将变得更为显而易见。The above and other aspects, features and advantages of the present application will become more apparent in view of the following detailed description when taken in conjunction with the accompanying drawings.

此后参照附图描述本申请的具体实施例;然而,应当理解,所申请的实施例仅仅是本申请的实例,其可采用多种方式实施。熟知和/或重复的功能和结构并未详细描述以避免不必要或多余的细节使得本申请模糊不清。因此,本文所申请的具体的结构性和功能性细节并非意在限定,而是仅仅作为权利要求的基础和代表性基础用于教导本领域技术人员以实质上任意合适的详细结构多样地使用本申请。Specific embodiments of the present application are described hereinafter with reference to the accompanying drawings; however, it should be understood that the embodiments applied for are merely examples of the present application, which may be implemented in a variety of ways. Well-known and/or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that obscure the present application. Therefore, the specific structural and functional details applied for herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present application in a variety of ways with substantially any suitable detailed structure.

本说明书可使用词组“在一种实施例中”、“在另一个实施例中”、“在又一实施例中”或“在其他实施例中”,其均可指代根据本申请的相同或不同实施例中的一个或多个。This specification may use the phrases "in one embodiment," "in another embodiment," "in yet another embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present application.

以上实施例仅为本申请的示例性实施例,不用于限制本申请,本申请的保护范围由权利要求书限定。本领域技术人员可以在本申请的实质和保护范围内,对本申请做出各种修改或等同替换,这种修改或等同替换也应视为落在本申请的保护范围内。The above embodiments are only exemplary embodiments of the present application and are not intended to limit the present application. The protection scope of the present application is defined by the claims. Those skilled in the art may make various modifications or equivalent substitutions to the present application within the essence and protection scope of the present application, and such modifications or equivalent substitutions shall also be deemed to fall within the protection scope of the present application.

Claims (10)

1. A multiply-accumulator operation cluster, characterized in that it comprises a plurality of multiply-accumulator units, each of which is adapted to perform a multiply-accumulator operation of at least one set of data to be processed, each set of data to be processed comprising two multi-dimensional data, each of which comprises a plurality of multiply-accumulator subunits, each of which is adapted to perform a multiply-accumulator operation and to output a multiply-accumulate operation result, wherein,
When the calculated dimension of two pieces of multi-dimensional data in the data to be processed is smaller than the total dimension of the multiply-accumulate units, completing multiply-accumulate operation of each group of data to be processed through at least one multiply-accumulate subunit in the multiply-accumulate units, and outputting multiply-accumulate operation results of the data to be processed; and/or the number of the groups of groups,
When the data to be processed comprises a plurality of data blocks which are sequentially arranged, respectively completing multiply-accumulate operation of one data block through a plurality of multiply-accumulate diversity groups in the multiply-accumulate operation cluster, and outputting the multiply-accumulate operation result of the data block to the next multiply-accumulate diversity group which is sequentially arranged until the multiply-accumulate operation of all the data blocks is completed, and outputting the multiply-accumulate operation result of the data to be processed.
2. The multiply-accumulator operation cluster of claim 1, wherein the dimensions of the multiply-accumulator subunits in a same multiply-accumulator unit are identical, the sum of the dimensions of all multiply-accumulator subunits in each of the multiply-accumulator units is identical to the total dimension of the multiply-accumulator units, and the dimensions of the multiply-accumulator subunits in a plurality of different multiply-accumulator units are identical or different from each other.
3. The multiply-accumulator operation cluster of claim 2, wherein when a calculated dimension of a set of data to be processed is less than or equal to a dimension of a multiply-accumulator subunit in at least one multiply-accumulator unit, a target multiply-accumulator unit to operate on the data to be processed is determined from the calculated dimension of the data to be processed and the dimension of the multiply-accumulator subunit in the multiply-accumulator unit, and the multiply-accumulate operation is performed on the data to be processed by the multiply-accumulator subunit in the target multiply-accumulator unit.
4. The multiply-accumulator operation cluster of claim 2, wherein a multiply-accumulate operation of a set of data to be processed is completed by a plurality of multiply-accumulator subunits in the multiply-accumulator unit when a calculated dimension of the data to be processed is greater than a dimension of a multiply-accumulator subunit in all of the multiply-accumulator units and less than a total dimension of each of the multiply-accumulator units.
5. The multiply-accumulator operation cluster of claim 4, wherein when the calculated dimension of the data to be processed is greater than the dimension of the multiply-accumulator sub-units in all the multiply-accumulator units and less than the total dimension of each of the multiply-accumulator units, determining a target multiply-accumulator for operating the data to be processed and a target number of multiply-accumulator sub-units in the target multiply-accumulator based on the calculated dimension of the data to be processed and the dimension of the multiply-accumulator sub-units in each of the multiply-accumulator units, and performing a multiply-accumulate operation on the data to be processed by the target number of multiply-accumulator sub-units in the target multiply-accumulator.
6. The multiply-accumulator operational cluster of claim 1, wherein at least one multiply-accumulator subunit in the multiply-accumulator operational cluster is a multiply-accumulator sub-cluster.
7. The multiply-accumulator operation cluster according to claim 6, wherein when the calculation dimension of all the data blocks in the data to be processed is smaller than or equal to the dimension of the multiply-accumulator sub-units in any multiply-accumulator unit, each multiply-accumulator sub-unit in the multiply-accumulator unit is used as a multiply-accumulator sub-cluster, the multiply-accumulate operation of one data block is respectively completed through a plurality of multiply-accumulator sub-units in the multiply-accumulator unit, and the multiply-accumulate operation result of the data block is output to the next multiply-accumulator sub-unit in sequence until the multiply-accumulate operation of all the data blocks is completed, and the multiply-accumulate operation result of the data to be processed is output.
8. The multiply-accumulator operational cluster of any one of claims 1-7, wherein said multiply-accumulator unit comprises a plurality of data input modules, a plurality of multiply-operation modules, a plurality of multi-stage summation modules, and a plurality of data output modules, wherein one multiply-operation module, one multi-stage summation module, and a plurality of data output modules comprise a multiply-accumulator subunit, each of said multiply-operation modules comprising a plurality of multipliers, each of said multi-stage summation modules comprising a plurality of adders;
The input end of each data input module is electrically connected with the data providing module respectively, the output end of each data input module is electrically connected with the input end of one multiplication operation module respectively, the output end of each multiplication operation module is electrically connected with the input end of one multi-stage addition operation module, and the output end of each multi-stage addition operation module is electrically connected with a plurality of data output modules respectively.
9. A data processing method applied to the multiply-accumulator operation cluster according to any one of the preceding claims 1-8, characterized in that the data processing method comprises:
acquiring data to be processed, and determining a target multiply-accumulator unit corresponding to the data to be processed according to the calculated dimension of the data to be processed and the dimension of a multiply-accumulator subunit in each multiply-accumulator unit;
And inputting the data to be processed into a multiply-accumulate subunit in an idle state in the target multiply-accumulate device, and performing multiply-accumulate operation on the data to be processed through the target multiply-accumulate device to obtain a multiply-accumulate operation result of the data to be processed.
10. The method of claim 9, wherein the obtaining the data to be processed, determining the target multiply-accumulator unit corresponding to the data to be processed according to the calculated dimension of the data to be processed and the sub-dimension of the multiply-accumulator sub-unit in each multiply-accumulator unit, comprises:
taking a multiply accumulator unit, of which the dimension of a multiply accumulator subunit is greater than or equal to the calculated dimension of the data to be processed, as a candidate multiply accumulator unit;
And taking the candidate multiply accumulator unit which is in the idle working state and has the largest dimension of the multiply accumulator subunit as a target multiply accumulator unit corresponding to the data to be processed.
CN202410985037.8A 2024-07-23 2024-07-23 Multiply-accumulator operation cluster and data processing method Active CN118519613B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410985037.8A CN118519613B (en) 2024-07-23 2024-07-23 Multiply-accumulator operation cluster and data processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410985037.8A CN118519613B (en) 2024-07-23 2024-07-23 Multiply-accumulator operation cluster and data processing method

Publications (2)

Publication Number Publication Date
CN118519613A true CN118519613A (en) 2024-08-20
CN118519613B CN118519613B (en) 2024-12-17

Family

ID=92282189

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410985037.8A Active CN118519613B (en) 2024-07-23 2024-07-23 Multiply-accumulator operation cluster and data processing method

Country Status (1)

Country Link
CN (1) CN118519613B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104252331A (en) * 2013-06-29 2014-12-31 华为技术有限公司 Multiplying accumulator
CN110188869A (en) * 2019-05-05 2019-08-30 北京中科汇成科技有限公司 A kind of integrated circuit based on convolutional neural networks algorithm accelerates the method and system of calculating
US20200334322A1 (en) * 2017-12-29 2020-10-22 HUAWEI TECHNOLOGIES CO.,LTD., Shenzhen, CHINA Matrix multiplier
CN116450086A (en) * 2022-01-05 2023-07-18 腾讯科技(深圳)有限公司 Chip comprising multiply-accumulator, terminal and control method
CN117371498A (en) * 2022-06-28 2024-01-09 中国科学院深圳先进技术研究院 Data processing methods, multiply-accumulators, computing architecture, equipment and storage media

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104252331A (en) * 2013-06-29 2014-12-31 华为技术有限公司 Multiplying accumulator
US20200334322A1 (en) * 2017-12-29 2020-10-22 HUAWEI TECHNOLOGIES CO.,LTD., Shenzhen, CHINA Matrix multiplier
CN110188869A (en) * 2019-05-05 2019-08-30 北京中科汇成科技有限公司 A kind of integrated circuit based on convolutional neural networks algorithm accelerates the method and system of calculating
CN116450086A (en) * 2022-01-05 2023-07-18 腾讯科技(深圳)有限公司 Chip comprising multiply-accumulator, terminal and control method
CN117371498A (en) * 2022-06-28 2024-01-09 中国科学院深圳先进技术研究院 Data processing methods, multiply-accumulators, computing architecture, equipment and storage media

Also Published As

Publication number Publication date
CN118519613B (en) 2024-12-17

Similar Documents

Publication Publication Date Title
CN110059820B (en) System and method for computing
US11704125B2 (en) Computing device and method
US11106598B2 (en) Computing device and method
US11630666B2 (en) Computing device and method
CN109992743B (en) matrix multiplier
CN107832082A (en) A kind of apparatus and method for performing artificial neural network forward operation
CN109284824B (en) A device for accelerating convolution and pooling operations based on reconfigurable technology
CN113918120A (en) Computing device, neural network processing device, chip and method for processing data
TWI808259B (en) Digital circuit with compressed carry
CN110413561B (en) Data acceleration processing system
CN108122030A (en) A kind of operation method of convolutional neural networks, device and server
TWI890507B (en) Processors, computing chips and computing equipment
CN115310037A (en) Matrix multiplication computing unit, acceleration unit, computing system and related method
CN118353596A (en) Homomorphic matrix vector multiplication accelerator based on FPGA
EP4643236A1 (en) Multi-modal systolic array for matrix multiplication
WO2024114304A1 (en) Operation resource processing method and related device
CN1020170C (en) high speed digital processor
CN118519613A (en) Multiply-accumulator operation cluster and data processing method
CN118228774A (en) Residual network optimization method and device based on impulse neural network and electronic equipment
CN117290063A (en) A heterogeneous computing architecture that meets the needs of diverse computing tasks
CN111427537B (en) Pulse array parallel ordering method and device based on FPGA
CN114692853B (en) Computing unit architecture, computing unit cluster, and convolution operation execution method
CN112346704A (en) Full-streamline type multiply-add unit array circuit for convolutional neural network
CN120512411B (en) Communication distributors, processing chips, information transmission methods, devices and systems
CN115344525B (en) Method and device for accelerating point-stiffened part of elliptic curve

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant