Method for calculating narrow bit width linear algebraic operation
By expanding the bit width of narrow bit-width elements and utilizing the binary partitioning principle, the problem of low linear algebra operation efficiency of narrow bit-width elements is solved, efficient calculation is achieved and storage usage is reduced, which is suitable for the high-performance requirements of edge processors.
Patent Information
- Application Number
- CN202280092709.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-02-28
- Filing Date
- 2022-12-28
- Publication Date
- 2024-10-11
AI Technical Summary
It is difficult for the existing technology to efficiently calculate linear algebra operations on narrow bit width elements, resulting in low computational efficiency and large memory usage of edge processors under resource constraints.
By extending the bit width of the narrow bit width element to the clustering bit width and feeding it to the arithmetic logic unit for operation, the binary partitioning principle is used to reduce computational complexity and storage occupation, and realize linear convolution, inner product and vector reduction. Wait for operations.
It significantly reduces the arithmetic complexity and processing overhead of narrow bit-width element linear algebra operations, improves computational efficiency, and maintains accuracy, making it suitable for high-performance requirements in edge computing.
Smart Images

Figure CN118765393A_ABST
Abstract
Description
[0001] Purpose of the Invention
[0002] The present invention relates to a method for calculating linear algebraic operations of two operands or arrays with digital circuits, the two operands or arrays including one or more narrow bit width elements. The method uses the principle of binary segmentation to reduce the computational overhead of linear algebraic operations, such as linear convolution and inner products of operands such as vectors with narrow bit width components. The present invention also relates to digital circuits configured to perform the method. Background Art
[0003] Contemporary Internet of Things (IoT), edge, and mobile computing applications demand high performance. This demand has driven a large research effort on low-power, high-performance embedded processors. Such devices, primarily constrained by power and cost, must meet the performance and memory requirements of a number of important application areas, such as deep learning, robotics, graphics processing, and cryptography. Most of these application categories represent data as matrices and vectors and express their computations through a set of linear algebra kernels. When targeting edge platforms, a popular approach to reduce energy requirements and memory footprint requirements is to compress the data layout by using smaller data formats while maintaining the accuracy of the application.
[0004] On the one hand, expressing and computing data using low-precision floating-point formats are gaining more and more attention in the field of high-performance edge computing (HPEC) because they represent a good balance between data size and accuracy. On the other hand, narrow fixed-point data and integer data representations (i.e., bytes and subbytes) offer better alternatives in terms of performance per watt (although their digital representations are smaller). One of the main applications of edge computing that utilizes these compressed data formats is quantized convolutional neural network (QCNN) inference, which uses quantization to represent data and weights, where the data size is typically between 8 bits and 1 bit and the accuracy loss can be tolerated.
[0005] Other applications that fall into the important application categories for edge computing (e.g., graph computing and cryptography) rely extensively on Boolean matrix and vector calculations to traverse graphs or encrypt / decrypt messages. These applications will greatly benefit from hardware and software solutions that can efficiently compute narrow integer linear algebra kernels.
[0006] Moving computation for these applications from the cloud to edge devices and mobile devices will achieve significant improvements in security, safety, and energy efficiency. However, despite the low memory and energy requirements of these applications, their inherent high computational intensity makes computation of these workloads challenging on highly resource-constrained devices.
[0007] Therefore, there is a need for a lightweight and high-performance approach and architecture aimed at improving the efficiency of linear algebra and narrow integer computations on edge processors. Summary of the invention
[0008] In a first inventive aspect, the present invention provides a method for calculating a linear algebraic operation of two operands u, v by a digital circuit operatively connected to an arithmetic logic unit, wherein the method comprises the following steps by the digital circuit:
[0009] Accepts two operands u and v consisting of m and n narrow bit-width elements respectively, such that u=[u0,…,u m-1 ],v=[v0,…,v n-1 ], the elements have a bit width b u 、b v ;
[0010] Extend the bit width of each element of the operand to the cluster bit width c by appending zeros to the left of the most significant bit of the element w , and concatenate the elements of each operand to obtain the bit width c respectively w m and c w ·The value of n is U, V, where
[0011] The cluster bit width meets the following conditions:
[0012] c w ≥max(b u ,b v );
[0013] Feeding the values U, V to the arithmetic logic unit;
[0014] Receive the result value W with bit width p from the arithmetic logic unit, W=[W0,…,W p-1 ];
[0015] The operation result w is extracted from the result value W, wherein the operation result w includes one or more bits of W.
[0016] The proposed invention relies on the principle of a mathematical technique known as binary segmentation, which significantly reduces the arithmetic complexity of linear algebraic calculations on operands with narrow bit-width elements, while reducing the processing overhead and memory footprint of the calculations.
[0017] Throughout the content of this article, it is understood that the method is intended to perform linear algebraic operations on two operands with narrow bit-width elements, preferably vector linear convolution, inner product, vector reduction, scalar vector product or vector addition or subtraction; operands with narrow bit-width elements should be understood as element arrays, where each element is a narrow bit-width binary integer; narrow bit-width should be understood as a bit-width smaller than the word length of the arithmetic logic unit structure.
[0018] According to the method, the digital circuit performs a series of transformations on the source operands u, v, transforms them into values U, V, and feeds them to an arithmetic logic unit, which performs an operation (preferably a multiplication or addition) on the values U, V to produce a result value W. The result value W is further transformed to extract the operation result w. Preferably, the extraction includes outputting a set of bits of the result value W, for example by a masking operation. As described below, each operation requires a specific pre-processing of the operand and a specific extraction process.
[0019] Digital circuits should be understood as any hardware element capable of performing the transformation of operands and values required by the method. Preferably, the digital circuit is configured to be connected to a known computing system. Specifically, the digital circuit is preferably configured to receive and output operands or values from any data storage device, which in a preferred example is a register of a computer processing unit. Also preferably, the digital circuit is directly or through other elements connected to an arithmetic logic unit of a computer processing unit. In other embodiments, the digital circuit is configured to be connected to a digital circuit capable of storing data and a digital circuit capable of multiplying and / or adding two binary operands.
[0020] In a particular embodiment, the value W from the arithmetic logic unit is obtained by multiplying or adding the values U and V.
[0021] The most common linear algebra operations can be simplified to two basic calculations, multiplication and addition. Advantageously, binary segmentation allows linear algebra operations on arrays of elements (which typically require several calculation cycles for each element of the array) to be reduced to the multiplication or addition of just two values, thereby reducing the number of cycles required to complete the calculation.
[0022] In addition, this method allows three very important operations on vectors, namely linear convolution, inner product and vector reduction. Usually, the linear convolution of two vectors is calculated as follows:
[0023]
[0024] The inner product is calculated as follows:
[0025]
[0026] Finally, vector reduction returns a scalar value that holds the sum of all elements of u; in a sense, vector reduction is the sum of the vector to be reduced and the vector v = [v0,…,v n-1 ]=[1,…,1], as follows:
[0027]
[0028] However, in conventional computing, array operations are computationally intensive and require a large number of processing cycles and use of memory to store intermediate results. This is avoided by the binary segmentation implemented by the present method, which requires expanding each element of the array (e.g., each component of a vector) to a certain size (i.e., the cluster width c w ). This extension is performed by adding zeros to the left of the most significant bit, so the integer value does not change, and c w The subsequent concatenation of normalized elements produces a value U or V that can be processed by the arithmetic logic unit without loss of information.
[0029] In a particular embodiment, the cluster width satisfies the condition:
[0030] c w ≥ b u +b v +log2(max(m,n)).
[0031] According to the bit width b of the elements of the operand u 、b v and the number of elements of each operand m, n to obtain the cluster width for the computation of linear convolution, inner product, and vector reduction. This process provides a cluster width that is defined as greater than the input element b u 、b v The actual bit width of the cluster is smaller than the actual bit width of the cluster because it includes additional guard-band bits to avoid overflow in the segmented data due to carry propagation. This allows the summation or multiplication of n narrow integers to be performed with only one summation or multiplication of two long integers, instead of n summations or multiplications of short integers. It is worth noting that binary segmentation is not an approximate computing technique because it guarantees exact computation because the cluster width dimension already takes into account the number of bits required to represent the computation output without incurring precision loss.
[0032] In a specific embodiment of the inner product calculation, after receiving two operands u, v, the method includes inverting the operand v = [v0, ..., v n-1 ] to obtain the operand v′=[v n-1 ,…,v0]. This step is also advantageously applied to the calculation of linear convolution of convolutional neural network (CNN).
[0033] The calculation of the inner product or dot product of two vectors involves the reversal of the order of the elements of one operand (u or v). The reversed operand v' is transformed according to the general case of the method, that is, zeros are added to the left of the most significant bits, and the inner product is obtained from the multiplication of the resulting values U, V.
[0034] In a specific embodiment of vector reduction, each element of operand v is equal to 1:
[0035] v0=…=v n-1 =1.
[0036] As described above, vector reduction is treated as a special case of the inner product by binary splitting between u and v, where v is a unit vector consisting only of elements equal to 1. The result is that the vector u consisting of n elements is reduced to a scalar value that holds the sum of all elements of u.
[0037] In a specific embodiment of the linear convolution, the operation result w includes one or more elements, w=[w0, w1, ...], and wherein, according to where i∈{0,…,m+n-1}, each element w i Includes one or more bits of W.
[0038] In the method of the present invention, once the values U and V are multiplied, the product W must be transformed to obtain the result of the operation. For linear convolution, the result of the operation is an array of elements, each element comprising a set of bits of W. In particular, for linear convolution, each element w i A group of c including W w consecutive bits, or conversely, if W is evenly divided into multiple c w Continuous bit group, then w i Include one of these groups, for example, for w0:
[0039]
[0040] It corresponds to the rightmost c of W w The next element w1 will contain bits W cw To W 2·cw-1 , and so on. These elements are also called slices.
[0041] However, for operations other than linear convolution, the extraction of the result w is slightly different. In a specific embodiment of the computation of inner products and vector reductions, according to The operation result w includes one or more bits of W.
[0042] For inner products and vector reduction, the extraction of the result consists of extracting a set of c from the value W starting from the (m-1)·cwth bit of W, starting from the least significant bit.w Continuous bits, or in other words, extract the center slice of W.
[0043] Furthermore, the method considers a specific embodiment of the computation of the product between a vector and a scalar, where n=1 and v=[v0]=[k].
[0044] For vector and scalar computations, the operands are interpreted as multi-element arrays and single-element arrays, respectively, whose values correspond to the scalar operands, or in other words, m ≥ 2, n = 1.
[0045] The cluster width needs to be adjusted accordingly, and in this particular embodiment, the cluster width satisfies the following conditions:
[0046] c w ≥ b u +log2(m).
[0047] It has been pointed out that this method also applies to the calculation of array addition and subtraction. For addition or subtraction based on binary partitioning, the cluster width satisfies the condition:
[0048] c w ≥max(b u ,b v )+1.
[0049] While the addition of two binary operands is simple and can be computed by an adder, the subtraction of two operands implies the computation of the two's complement of the operands being subtracted. In an embodiment corresponding to a subtraction operation, the method comprises computing the elements v0, ..., v n-1 The two's complement steps.
[0050] Two's complement operation is an operation known in the art on a binary number that is calculated by reversing the bits and adding 1 to the original binary number and is equivalent to calculating the negative of the original number. Thus, the subtraction of two operands is calculated as the addition of the first value and the negative of the second value.
[0051] For addition and subtraction and scalar-vector product, the result w consists of one or more elements w = [w0, w1, ...], and where, according to where i∈{0,…,m-1}, each element w i Includes one or more bits of W.
[0052] The extraction process is similar to that of linear convolution results, the only difference being the number of elements in the result w.
[0053] In a second invention aspect, the present invention provides a digital circuit configured to perform the method according to the first invention aspect, wherein the digital circuit comprises:
[0054] a pre-processing unit configured to receive and expand operands u, v and feed the values U, V to the arithmetic logic unit; and
[0055] A post-processing unit is configured to receive the result value W from the arithmetic logic unit and extract the operation result w.
[0056] As mentioned above, the method is intended to be performed by any digital circuit capable of performing the described transformation of operands, which digital circuit may be realized by an assembly of interconnected conventional logic gates, or by a purposefully constructed printed circuit board or integrated circuit. In all cases, the digital circuit may optionally be provided with arithmetic logic means and / or input and output connection means and / or data storage means to feed, store and multiply or add these values, thereby creating an integer binary division calculation unit configured to receive operands and output the results of the operation.
[0057] The digital circuit includes two oriented processing units (pre-processing unit and post-processing unit), each unit is configured to perform transformations before and after addition or multiplication, respectively. Depending on the specific architecture of the digital circuit, some elements of the circuit can be shared between the pre-processing unit and the post-processing unit, or can be used in conjunction with other elements to perform one or more steps of the method.
[0058] In one embodiment of the digital circuit, the pre-processing unit includes an expansion unit and a packing unit, the expansion unit is configured to expand the bit width of the elements of the operand to the cluster width, and the packing unit is configured to compress its input data to their actual data size by converting the elements of the operand to the target output bit width, and forward them to the mask unit to merge them. The mask unit is an element of the post-processing unit, and it is also configured to extract the relevant operation result w from the result value W. The digital circuit may also include a control unit having a control register, the control unit is configured to determine the cluster width and other key parameters according to the input operand bit width and the operation type.
[0059] In a particular embodiment, the circuit is further configured to be operably connected to an arithmetic logic unit of a computer and further configured to feed values U, V, W to or receive values U, V, W from the arithmetic logic unit via a register file, bypass logic and / or a memory hierarchy.
[0060] In this embodiment, the digital circuit is configured as an additional or connectable device that is configured to connect to a pre-existing processing unit or similar computing element, so that the digital circuit can be advantageously modified on any computer. In this embodiment, when connected to a computer, the digital circuit loads the values U, V generated by the transformation of the input operands u, v into the registers of the arithmetic logic unit (which may be loaded together with the instructions related to the operation), and receives the calculation results W. The digital circuit can be fed and received through a direct bus to the arithmetic logic unit, or it can be fed and received through other elements (for example, register files, bypass logic, or any type of data storage device (including any level of memory hierarchy)). In some processor architectures (for example, CPUs and GPUs), the behavior of the digital circuit is managed by instructions specific to these architectures.
[0061] In a specific embodiment, the pre-processing unit and the post-processing unit are implemented on a configurable logic block CLB, wherein the CLB includes a register and a lookup table LUT.
[0062] A particularly advantageous application of the digital circuit is a data flow computer architecture. An example of a data flow architecture to which the digital circuit can be applied is an architecture implemented by a field programmable gate array (FPGA), which includes a plurality of programmable logic units or configurable logic blocks (CLBs) interconnected by an interconnect matrix. In those embodiments, the digital circuit can be constructed with one or more CLBs and a digital signal processing unit DSP, and the pre-processing unit and the post-processing unit are implemented by a lookup table (LUT). BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The foregoing and other advantages and features will be more fully understood from the following detailed description of exemplary embodiments with reference to the accompanying drawings, which are to be regarded as illustrative rather than restrictive, wherein:
[0064] Figure 1a , Figure 1b , Figure 1c A flow chart showing three embodiments of the method is shown.
[0065] Figure 2 A schematic diagram showing a preferred example of a digital circuit.
[0066] Figure 3 A schematic diagram showing another preferred example of a digital circuit implemented in an FGPA architecture.
[0067] Preferred embodiments of the present invention
[0068] Throughout the content of this document, it can be understood that various parts of one embodiment of the present invention can be freely combined with parts described in other embodiments (even if the combination is not explicitly described), as long as such combination does not damage the present invention.
[0069] The method of the present invention aims to realize the binary segmentation calculation process of two array operands composed of narrow bit width operands by digital circuit. The method can at least calculate vector linear convolution, inner product, vector reduction, scalar vector product or vector addition or subtraction. All these linear algebra operations are calculated by a set of common steps (10, 20, 30, 40, 50), which are different from another type of operation in terms of the clustering bit width of the elements of the operands, the result extraction process and the specific calculation (addition or multiplication) of the arithmetic logic unit (ALU).
[0070] Figure 1a , Figure 1b and Figure 1c Three flow charts corresponding to three embodiments of the method are shown. Generally, the method can be divided into three stages:
[0071] - A preprocessing stage, comprising the steps of receiving (10) two operands u, v consisting of m, n narrow bit width elements, extending (20) the bit width of each element of the operands to the clustered bit width, and feeding (30) the values U, V to the arithmetic logic unit.
[0072] -The calculation stage performed by the ALU, in which the values U and V are added or multiplied and output to the digital circuit.
[0073] - A post-processing phase, comprising the steps of receiving (40) a result value W and extracting (50) the operation result w.
[0074] Figure 1a shows the general case that is valid for any operation, Figure 1b shows a specific case of inner product computation, while Figure 1c A specific case of a subtraction calculation is shown.
[0075] In a first step, the digital circuit receives (10) two operands u, v (e.g. two vectors) having m and n elements or components respectively:
[0076] u=[u0,…,u m-1 ],v=[v0,…,v n-1 ]
[0077] If the chosen operation is the inner product, the digital circuit needs to reverse the order of the elements of the (11) second vector as follows:
[0078] v′=[v n-1 ,…,v0]
[0079] Convolutional neural networks (CNNs) use a linear convolution that can also be calculated using the method of the present invention. The operation is calculated in the same way as the general case of linear convolution, but with the difference that the order of the elements of one of the vectors is reversed (11), which is the same as the case of calculating the inner product.
[0080] The next step requires the digital circuit to expand the bit width of each element of the two vectors (20) to the cluster width c w The target cluster width is achieved by adding zeros to the left of the most significant bits, and the cluster width is defined to keep the elements in the union value (U or V) a certain amount of space and avoid overflow in the calculation. The cluster width c w is an integer that satisfies the following conditions:
[0081] c w ≥max(b u ,b v )
[0082] Among them, b u 、b v are the bit widths of the elements of u and v, respectively. To better exploit the advantages of binary segmentation, the cluster width needs to be the smallest possible integer that provides sufficient separation between the components of the vector, which in turn depends on the operation. In summary, for each operation, the cluster width is the smallest integer that satisfies the following conditions:
[0083] -For linear convolution, inner product, and vector reduction:
[0084] c w ≥ b u +b v +log2(max(m,n))
[0085] -For the vector-scalar product:
[0086] c w ≥ b u +log2(m)
[0087] -For addition or subtraction:
[0088] c w ≥max(b u ,b v )+1
[0089] Obviously, some operations require that both operands or vectors have the same number of elements, in which case m = n. Furthermore, in the case of a scalar-vector product, the scalar operand is treated as an array with a single element having the value of the scalar k, and the rest of the process remains unchanged.
[0090] Furthermore, if the selected operation is subtraction, the digital circuit computes (21) the two's complement of the elements of the subtracted vector (in this case, v), after expansion (20) to the cluster width.
[0091] After expanding the elements to the normalized cluster width, the digital circuit connects the elements to obtain bit width c w m and c w Two values U, V of n. When the operation is a subtraction or an inner product, the second vector v is transformed as described above and then expanded and concatenated as in the general case.
[0092] The two values U, V are then fed 30 to the ALU (possibly together with a signal indicating the type of operation (i.e., multiplication or addition)) and then returned to the digital circuit which receives 40 the resulting value W. The type of operation is multiplication, except for subtraction and addition, in which case the values U, V are added.
[0093] The result value W is a p-bit binary integer, where the size of p depends on whether U and V are added or multiplied, and the bit widths of U and V. If W is written as a bit array:
[0094] W=[W0,…,W p-1 ]
[0095] The extraction (50) step requires the digital circuit to separate or somehow output a subset of the bits of W. The specific set of bits will depend on the type of operation, but can be summarized as follows:
[0096] For linear convolution, the result w is an array or vector, and each element w of the array or slice i is defined as:
[0097] Where i∈{0,…,m+n-1}
[0098] A similar principle applies to scalar-vector multiplication, addition, and subtraction, the difference being the number of components of w:
[0099] Where i∈{0,…,m-1}
[0100] Finally, for inner products and vector reductions, the result of the operation consists of a single slice of the result value W:
[0101]
[0102] The following numerical examples show two implementations of this method with specific numerical values:
[0103] Example 1: Inner Product
[0104] Operands: u = (7, 5); v = (4, 2)
[0105] Cluster width: c w =7
[0106] 7 10 =1112;5 10 =1012→u=(u0,u1)=(111,101)
[0107] 4 10 =1002;2 10 =0102→v=(v0,v1)=(100,010)→v'=(v1,v0)=(010,100)
[0108] u cw =(0000111,0000101) → U = [00001110000101]
[0109] v cw =(0000111,0000101) → V = [00001110000101]
[0110] W=U·V=[000111001001100010100]
[0111] w=[W (2 ·cw)-1,…,W 1·cw ]=[W 13 ,…,W7]=[0100110]
[0112] →w=01001102=38 10
[0113] Example 2: Linear Convolution
[0114] Operands: u = (3, 1, 2); v = (1, 2)
[0115] Cluster width: c w =5
[0116] 3 10 =0112;1 10 =0012;2 10 =0102→u=(u0,u1,u2)=(011,001,010)
[0117] 1 10 =0012;2 10 =0102→v=(v0,v1)=(001,010)
[0118] u cw =(00011,00001,00010) → U = [000110000100010]
[0119] v cw =(00001,00010) → V = [0000100010]
[0120] W=U·V=[00011001110010000100]
[0121] w=(w0,…,w i ,…w3)=[W (i·cw)+(cw-1) ,…,W i·cw ]=(00011,00111,00100,00100)
[0122] →w=(00011,00111,00100,00100)2=(3,7,4,4) 10
[0123] Regarding digital circuits, Figure 2 In the preferred example shown, for a traditional central processing unit (CPU), the digital circuit is implemented as a RISC (reduced instruction set computer) instruction set architecture integrated on a system on chip (SoC). For example, RISC-V vector extension v1.0 does not support narrow single instruction multiple data (SIMD) calculations, and its initial specification only considers 8-bit, 4-bit, 2-bit and 1-bit data types. In contrast to standard SIMD units, digital circuits allow many data sizes to remain compressed in memory and be calculated in a SIMD manner without causing area overhead associated with data operations. The digital circuit also supports mixed precision calculations in design because the cluster width has taken into account the different data sizes between data sources. Therefore, the digital circuit is able to calculate compressed data and perform flexible SIMD-style calculations (whose width is proportional to the data size of each operand) without generating related overhead. In addition, the implementation of the digital circuit (whose key novelty relies on hardware reuse) does not require any additional data paths or separate register files or functional units, so its area and power consumption overhead can be ignored.
[0124] Digital circuits rely on standard arithmetic logic units (e.g., integer multipliers), whose data paths and implementations have been implemented in processors that support integer calculations. Therefore, the main purpose of digital circuits is to effectively group data before multiplication operations and optimize data extraction at the output of the multiplier. Digital circuits solve these problems through two units called preprocessing and postprocessing. The function of the preprocessing unit is twofold. The expansion unit converts the elements belonging to the operands into input values U, V and forwards them to the processor multiplier through the output bus to perform the actual calculation. The number of elements to be clustered and the bit width are specified in the control register. Then, the multiplication or addition results are processed by the mask unit, which composes the final result according to the type of operation. Specifically, the mask unit extracts a group of bits w with a value of W according to the position defined by the binary segmentation technique.
[0125] To speed up the data compression phase, the pre-processing unit includes a packing unit that compresses its input data into their actual data size. The packing unit converts the operand elements to the target output bit width and forwards them to the mask unit for merging. Therefore, the post-processing unit either acts as a filter to extract meaningful data fragments from the arithmetic logic unit output or is used to compress data, where the behavior of the post-processing unit depends on the type of operation and the value set in the control register.
[0126] In other embodiments, the digital circuits are implemented in a dataflow computer architecture. Figure 3 In the example shown, the digital circuit is implemented on an FPGA architecture. The FPGA consists of data flow blocks called CLBs, each of which includes logic circuits (e.g., ALUs, storage cells, and / or LUTs), which are hardware components that specifically implement logic units (such as shifts, Boolean operations, etc.). The CLBs are interconnected through an interconnect matrix and are able to receive data and send data to adjacent blocks.
[0127] In such an example, three CLBs are connected into a chain, and the first CLB of the chain (CLB0) includes two storage units that output two new element vectors in each clock cycle. The central block of the chain (CLB1) uses the internal ALU as a multiplier and its LUT as a logic circuit to implement the pre-processing unit and the post-processing unit of the digital circuit. In other examples, the ALU is externally implemented by a DSP. Therefore, the two source vectors from CLB0 are processed by the expansion unit of the pre-processing unit to obtain the input cluster, multiplied by the ALU to obtain W, and processed by the masking unit of the post-processing unit to extract one operation result in each cycle. Then, each result is stored in the storage buffer of the third block (CLB2).
Claims
1. A method for computing a linear algebraic operation of two operands u, v by means of a digital circuit operatively connected to an arithmetic logic unit, wherein: The method comprises the following steps via a digital circuit: Receive (10) two operands u and v consisting of m and n narrow bit width elements respectively, such that u=[u0,…,u m-1 ],v=[v0,…,v n-1 ], the elements have a bit width b u , b v ; The bit width of each element of the operand is extended (20) to the cluster bit width c by adding zeros to the left of the most significant bit of the element. w , and concatenate the elements of each operand to obtain the bit width c respectively w m and c w The values of n are U, V, where the cluster width satisfies the condition: c w ≥max(b u ,b v ); feeding (30) the values U, V to the arithmetic logic unit; A result value W with a bit width p is received (40) from the arithmetic logic unit, where W=[W0, ..., W p-1 ]; Extract (50) an operation result w from the result value W, wherein the operation result w includes one or more bits of W.
2. The method according to the preceding claim, wherein: The value W from the arithmetic logic unit is obtained by multiplying or adding the values U and V.
3. A method according to any one of the preceding claims, wherein: The cluster bit width meets the following conditions: c w ≥b u +b v +log2(max(m,n))。 4. A method according to the preceding claim, wherein: After receiving (10) two operands u, v, the method comprises inverting (11) the operand v=[v0, ..., v n-1 ] to obtain the operand v′=[v n-1 ,…,v0] steps.
5. The method according to claim 3, wherein: Each element of operand v is equal to 1: v0=…=v n-1 =1。 6. A method according to any one of the preceding claims, wherein: The operation result w includes one or more elements w=[w0, w1, ...], and wherein, according to Among them, i∈{0,…,m+n-1}, each element w i Includes one or more bits of W.
7. The method according to any one of claims 4 to 5, wherein: according to The operation result w includes one or more bits of W.
8. The method according to any one of claims 1 to 2, wherein: The cluster width satisfies the following conditions: c w ≥b u +log2(m)。 9. The method according to the preceding claim, wherein: n=1 and v=[v0]=[k].
10. The method according to any one of the preceding claims 1 to 2, wherein: The cluster width satisfies the following conditions: c w ≥max(b u ,b v )+1。 11. The method according to the preceding claim, wherein: After the step of extending (20) the bit width of each element, the method comprises calculating (21) the elements v0, ..., v of the operand v n-1 The two's complement steps.
12. The method according to any one of claims 10 to 11, wherein: The operation result w includes one or more elements w = [w0, w1, ...], and according to Among them, i∈{0,…,m-1}, each element w i Includes one or more bits of W.
13. A digital circuit configured to perform the method according to any one of claims 1 to 12, wherein: The digital circuit comprises: a pre-processing unit configured to receive (10) and expand (20) operands u, v and feed (30) values U, V to the arithmetic logic unit; and A post-processing unit is configured to receive (40) a result value W from the arithmetic logic unit and extract (50) an operation result w.
14. A digital circuit according to the preceding claim, further configured to be operably connected to an arithmetic logic unit of a computer and further configured to feed (30) values U, V, W to or receive (40) values U, V, W from the arithmetic logic unit via a register file, bypass logic and / or a memory hierarchy.
15. The digital circuit according to claim 13, wherein: The pre-processing unit and the post-processing unit are implemented on a configurable logic block CLB, wherein the CLB includes a register and a lookup table LUT.
