Computing method of accelerator and accelerator
By employing a very long instruction word (VLIW) instruction set in the hardware accelerator to issue memory access, computation, and control operations in parallel, and combining it with a register control module and an address calculation unit, the problem of insufficient programmability and scalability of the hardware accelerator is solved, enabling flexible adaptation and efficient computation for various neural network models.
Patent Information
- Application Number
- CN202611496748.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-23
- Publication Date
- 2026-11-20
AI Technical Summary
Existing hardware accelerators are insufficient in terms of programmability and scalability, making it difficult to adapt to the rapid evolution of deep learning algorithms.
It adopts a very long instruction word instruction set, and issues memory access instruction slots, computation instruction slots and control instruction slots in parallel within the same clock cycle. Combined with the register control module and address calculation unit, it realizes the parallel execution of memory access, computation and control operations, and improves the parallel efficiency of the computation unit and the memory unit through instruction-level parallel issue mechanism and pipeline scheduling mechanism.
It achieves high programmability and scalability of hardware accelerators, can flexibly adapt to various neural network models, and improves computing resource utilization and computing efficiency.
Smart Images

Figure CN123138141A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of accelerator technology, and more specifically, to a computational method for an accelerator and an accelerator. Background Technology
[0002] In recent years, artificial intelligence (AI) technologies, represented by deep learning, have made significant progress in various fields. This has placed higher demands on the versatility and programmability of underlying hardware accelerators.
[0003] Therefore, a hardware accelerator with improved programmability and scalability is needed. Summary of the Invention
[0004] The purpose of this disclosure is to provide a computational method for an accelerator and an accelerator.
[0005] In one general aspect, a computation method for an accelerator is provided, the computation method being executed by an acceleration core of the accelerator, the computation method comprising: receiving an instruction set from a memory system external to the acceleration core, wherein the instruction set includes one or more instructions, wherein each of the one or more instructions is a Very Long Instruction Word (VLE) instruction, and includes a memory access instruction slot for allocating memory access instructions, a computation instruction slot for allocating computation instructions, and a control instruction slot for allocating control instructions, wherein the memory access instruction slot, computation instruction slot, and control instruction slot of each of the one or more instructions are issued in parallel within the same clock cycle; receiving input data and weight data from the memory system based on the memory access instructions in the instruction set; performing operations on the input data and weight data based on the computation instructions and control instructions in the instruction set to generate output data; and sending the output data to the memory system based on the memory access instructions in the instruction set.
[0006] Optionally, the acceleration core includes an instruction decoding module, a register control module, an address calculation unit, and a processing unit array. The calculation method further includes: decoding the instruction set received from the memory system through the instruction decoding module to obtain memory access instructions, calculation instructions, and control instructions. The register control module is configured to store loop variables, loop boundaries, and constants required for address calculation, and to update the loop variables based on the control instructions. The step of receiving input data and weight data from the memory system includes: calculating the storage address of the input data in the memory system and the storage address of the weight data in the memory system based on the memory access instructions and the loop variables provided by the register control module through the address calculation unit. The address, and the processing unit array receives input data and weight data from the storage system based on the storage address of the input data and the storage address of the weight data in the storage system. The step of performing operations on the input data and weight data includes: performing operations on the input data and weight data based on calculation instructions by the processing unit array to generate output data, and the step of sending the output data to the storage system includes: calculating the storage address of the output data in the storage system by the address calculation unit based on the memory access instructions and the loop variable provided from the register control module, and sending the output data and the storage address of the output data in the storage system to the storage system by the processing unit array.
[0007] Optionally, the correctness of control dependencies between control instructions, memory access instructions, and computation instructions is ensured through a delay slot mechanism.
[0008] Optionally, the register control module includes an inner state machine and an outer state machine, and is further configured to maintain a loop counter for recording the remaining number of instruction repetitions. The inner state machine is configured to control the updating of the inner loop variable and the loop counter based on control instructions. The inner loop variable includes the convolution kernel row index, convolution kernel column index, and input channel index associated with the input data. The outer state machine is configured to be triggered when it receives an inner loop completion signal from the inner state machine and to control the updating of the outer loop variable, which includes the output row index, output channel index, and output column index associated with the output data.
[0009] Optionally, the steps of calculating the storage address of the input data and the storage address of the weight data in the storage system include: using an address calculation unit, employing a polynomial address mapping strategy based on nested loops, and according to the mode selection signal corresponding to the memory access instruction, calculating the storage address of the input data and the storage address of the weight data in the storage system by polynomially combining the loop variable provided by the register control module with the pre-stored address calculation constant.
[0010] Optionally, the processing unit array includes at least one of a vector dot product unit, a scalar operation unit, and a nonlinear approximation unit. The vector dot product unit includes multiple parallel multipliers for performing dot product operations over multiple clock cycles and a multi-stage pipelined addition tree. The scalar operation unit includes independent adders, multipliers, and comparators for performing scalar multiplication-addition or maximum value comparison operations over a single clock cycle. The nonlinear approximation unit employs a four-stage pipelined architecture and performs approximate calculations of exponential, reciprocal, and square root reciprocal functions using a piecewise linear approximation method.
[0011] Optionally, the memory access instruction slot includes a first memory access instruction slot for allocating a first memory access instruction and a second memory access instruction slot for allocating a second memory access instruction. The first memory access instruction includes a first memory access opcode field for loading input data and a first memory access immediate number field for configuring the address calculation polynomial coefficients when loading input data. The second memory access instruction includes a second memory access opcode field for loading weight data and a second memory access immediate number field for configuring the address calculation polynomial coefficients when loading weight data. The calculation instruction slot includes a first calculation instruction slot for allocating a first calculation instruction and a second calculation instruction slot for allocating a second calculation instruction. The first calculation instruction includes a first calculation opcode field for vector dot product calculation or nonlinear approximation calculation and a first calculation immediate number field for selecting the data path and operation mode within the accelerator. The second calculation instruction includes a second calculation opcode field for scalar arithmetic calculation or summation calculation and a second calculation immediate number field for providing scalar calculation constants or specifying the address of the register participating in the operation. The control instruction includes an opcode for loop repetition or conditional jump and an immediate number field for providing the jump address offset or the number of hardware loops.
[0012] Optionally, one or more of the memory access instructions in the memory access instruction slot, the calculation instructions in the calculation instruction slot, and the control instructions in the control instruction slot are configured differently for different operators.
[0013] In one general aspect, an accelerator is provided, the accelerator comprising: a storage system configured to store input data, weight data, output data, and an instruction set; and an acceleration core configured to perform any of the computation methods described above.
[0014] In one general aspect, a computer-readable storage medium is provided that stores a computer program, which, when executed by a processor, implements any of the computational methods described above.
[0015] In the computation method of the accelerator according to some example embodiments, since the memory access instruction slot, computation instruction slot, and control instruction slot of each instruction in the Very Long Instruction Word (VLE) instruction set are issued in parallel within the same clock cycle, parallel execution of memory access, computation, and control operations can be achieved. Furthermore, based on the instruction set-driven design paradigm, by issuing memory access, computation, and control operations in parallel within the same clock cycle using VLE, various operators such as convolution, fully connected operations, matrix multiplication, sigmoid, softmax, and LayerNorm can be flexibly configured for execution without changing the hardware structure. This provides high programmability and scalability, enabling adaptation to the rapid evolution of deep learning algorithms.
[0016] In the computation method of the accelerator according to some example embodiments, by allocating instructions of different functional categories to five independent instruction slots (more specifically, two computation instruction slots, two cache instruction slots, and a control instruction slot), memory access operations, computation operations, and control operations can be statically orchestrated within a single Very Long Instruction Word and can be executed efficiently.
[0017] In the computation method of the accelerator according to some example embodiments, the computation process of different operators (such as, but not limited to, convolution, fully connected, matrix multiplication, etc.) is uniformly abstracted into a configurable instruction sequence, so as to achieve flexible adaptation to a variety of neural network models without changing the hardware structure.
[0018] In the computation method of the accelerator according to some example embodiments, by setting the register control module as a dual-state machine cooperative architecture, it is possible to efficiently perform updates of various loop variables.
[0019] In the computation method of the accelerator according to some example embodiments, by adopting a polynomial address mapping strategy based on nested loops, the address computation unit can uniformly transform tensor access patterns of different operators and different dimensions into regular polynomial address computation, avoiding the overhead of designing hard-wired address logic independently for each operator, and realizing flexible address generation.
[0020] In the computation method of the accelerator according to some example embodiments, the nonlinear approximation unit adopts a four-stage pipeline architecture and performs approximate calculations of exponential, reciprocal, and square root reciprocal functions through a piecewise linear approximation method. Therefore, it can support the approximation calculation of complex operators such as Sigmoid, Softmax, and LayerNorm, and fills the gap in hardware acceleration support for nonlinear operations in existing instruction set architectures. In addition, through instruction-level parallel issue mechanism and pipeline scheduling mechanism, parallel execution and time overlap of memory access operations, computation operations, and control operations are achieved, effectively hiding data migration latency and improving the parallel efficiency of computation and storage units.
[0021] In the computation method of the accelerator according to some example embodiments, the efficient collaboration between the instruction set and the hardware enables the same hardware architecture to support multiple models such as CNN and Transformer through software programming alone, effectively improving the programmability, scalability and computing resource utilization of the hardware accelerator. Attached Figure Description
[0022] Figure 1 A flowchart illustrating a computation method of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0023] Figure 2 A block diagram of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0024] Figure 3 A block diagram of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0025] Figure 4 An example structural format of a single instruction according to an exemplary embodiment of the present disclosure is shown.
[0026] Figure 5 A schematic diagram of a storage system according to an exemplary embodiment of the present disclosure is shown.
[0027] Figure 6 A schematic diagram showing a feature map according to an exemplary embodiment of the present disclosure.
[0028] Figure 7 A schematic diagram illustrating weight data according to an exemplary embodiment of the present disclosure is shown.
[0029] Figure 8 A schematic diagram of an address calculation unit according to an exemplary embodiment of the present disclosure is shown.
[0030] Figure 9 A schematic diagram of a processing unit array according to an exemplary embodiment of the present disclosure is shown.
[0031] Figure 10 A schematic diagram of a nonlinear approximation unit in a processing unit array according to an exemplary embodiment of the present disclosure is shown.
[0032] Figure 11 A schematic diagram of an inner state machine and an outer state machine in a register control module according to an exemplary embodiment of the present disclosure is shown.
[0033] Figure 12 A flowchart illustrating a computation method of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0034] Figure 13 A flowchart illustrating a computation method of an accelerator according to an exemplary embodiment of the present disclosure is shown. Detailed Implementation
[0035] The following detailed descriptions are provided to help the reader gain a comprehensive understanding of the methods, apparatus, and / or method or action decision-making apparatus according to exemplary embodiments of this disclosure. However, after understanding this disclosure, various changes, modifications, and equivalents of the methods, apparatus, and / or method or action decision-making apparatus according to exemplary embodiments of this disclosure will become apparent. For example, the order of operations described herein is merely illustrative and is not limited to those orders set forth herein, but may be changed as will become clear after understanding this disclosure, except for operations that must occur in a specific order. Furthermore, for clarity and conciseness, descriptions of features known in the art may be omitted.
[0036] The features described herein may be implemented in different forms and should not be construed as limited to the examples described herein. Rather, the examples described herein are provided only to illustrate some of the many possible ways of implementing the methods, apparatus and / or action decision-making devices according to exemplary embodiments of the present disclosure, many of which will become clear upon understanding the disclosure of this application.
[0037] As used herein, the term “and / or” includes any one of the associated listed items and any combination of any two or more.
[0038] Although terms such as “first,” “second,” and “third” may be used herein to describe various components, assemblies, regions, layers, or parts, these components, assemblies, regions, layers, or parts should not be limited by these terms. Rather, these terms are used only to distinguish one component, assembly, region, layer, or part from another. Thus, without departing from the teaching of the examples described herein, the first component, first assembly, first region, first layer, or first part referred to as the first component, first assembly, first region, first layer, or first part may also be referred to as the second component, second assembly, second region, second layer, or second part.
[0039] In the specification, when an element (such as a layer, region, or substrate) is described as being "on" another element, "connected to," or "bonded to" another element, the element may be directly "on" another element, directly "connected to," or "bonded to" the other element, or one or more other elements may be present in between. Conversely, when an element is described as being "directly on" another element, "directly connected to," or "directly bonded to" another element, no other elements may be present in between.
[0040] The terminology used herein is for the purpose of describing various examples only and is not intended to limit disclosure. Unless the context clearly indicates otherwise, the singular form is intended to include the plural form as well. The terms “comprising,” “including,” and “having” indicate the presence of the described features, quantities, operations, components, elements, and / or combinations thereof, but do not preclude the presence or addition of one or more other features, quantities, operations, components, elements, and / or combinations thereof.
[0041] Unless otherwise defined, all terms used herein (including technical and scientific terms) shall have the same meaning as would be normally understood by one of ordinary skill in the art to which this disclosure pertains upon learning of this disclosure. Unless expressly defined herein, terms (such as those defined in a general dictionary) shall be interpreted as having a meaning consistent with their meaning in the context of the relevant field and in this disclosure, and shall not be interpreted in an idealized or overly formalistic manner.
[0042] Furthermore, in the description of the examples, detailed descriptions of well-known related structures or functions will be omitted when it is believed that such detailed descriptions would lead to a vague interpretation of this disclosure.
[0043] In this disclosure, an accelerator may include a storage system and an acceleration core. The storage system may store input data, weight data, output data, and an instruction set. The acceleration core may process the input data and weight data based on the instruction set. Embodiments will be described in detail below with reference to the accompanying drawings. However, embodiments may be implemented in various forms and are not limited to those described herein.
[0044] Figure 1 A flowchart illustrating a computation method of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0045] The computational method of the accelerator according to the exemplary embodiments of this disclosure can be executed by the acceleration core of the accelerator.
[0046] Reference Figure 1 During operation of S110, instruction sets can be received from the memory system outside the acceleration core.
[0047] Storage systems can include various types of memory (e.g., various types of non-volatile memory and / or volatile memory). For example, in some exemplary embodiments, storage systems can include dynamic random access memory (DRAM), static RAM (SRAM), phase-change RAM (PRAM), ferroelectric RAM (FRAM), magnetic RAM (MRAM), resistive RAM (RRAM, flash memory, etc.).
[0048] In some example embodiments, the instruction set may include one or more instructions. Each of the one or more instructions may be a Very Long Instruction Word (VLIW) instruction and includes a memory access instruction slot for allocating memory access instructions, a computation instruction slot for allocating computation instructions, and a control instruction slot for allocating control instructions. The memory access instruction slot, computation instruction slot, and control instruction slot of each of the one or more instructions are issued in parallel within the same clock cycle. Here, the instruction set may be referred to as a Very Long Instruction Word instruction set.
[0049] In the computation method of the accelerator according to some example embodiments, since the memory access instruction slot, computation instruction slot, and control instruction slot of each instruction in the Very Long Instruction Word (VLE) instruction set are issued in parallel within the same clock cycle, parallel execution of memory access, computation, and control operations can be achieved. Furthermore, based on the instruction set-driven design paradigm, by issuing memory access, computation, and control operations in parallel within the same clock cycle using VLE, various operators such as convolution, fully connected operations, matrix multiplication, sigmoid, softmax, and LayerNorm can be flexibly configured for execution without changing the hardware structure. This provides high programmability and scalability, enabling adaptation to the rapid evolution of deep learning algorithms.
[0050] In some example embodiments, the memory access instruction slot may include a first memory access instruction slot for allocating a first memory access instruction and a second memory access instruction slot for allocating a second memory access instruction. The first memory access instruction may include a first memory access opcode field for loading input data and a first memory access immediate number field for configuring the address for calculating polynomial coefficients when loading input data. The second memory access instruction may include a second memory access opcode field for loading weight data and a second memory access immediate number field for configuring the address for calculating polynomial coefficients when loading weight data. The computation instruction slot may include a first computation instruction slot for allocating a first computation instruction and a second computation instruction slot for allocating a second computation instruction. The first computation instruction may include a first computation opcode field for vector dot product calculation or nonlinear function calculation and a first computation immediate number field for selecting the data path and operation mode within the accelerator. The second computation instruction may include a second computation opcode field for scalar arithmetic calculation or summation calculation and a second computation immediate number field for providing a scalar calculation constant or specifying the address of the register participating in the operation. Control instructions include opcodes for loop repetition or conditional jumps and immediate number fields for providing jump address offsets or hardware loop counts. By assigning instructions of different functional categories to five independent instruction slots (more specifically, two compute instruction slots, two cache instruction slots, and a control instruction slot), memory access operations, compute operations, and control operations can be statically orchestrated within a single Very Long Instruction Word (VLE) and can be executed efficiently.
[0051] In some example embodiments, the memory access instructions in the memory access instruction slot, the computation instructions in the computation instruction slot, and the control instructions in the control instruction slot are configured differently for different operators. Therefore, by unifying and abstracting the computation process of different operators (such as, but not limited to, convolution, fully connected, matrix multiplication, etc.) into a configurable instruction sequence, flexible adaptation to various neural network models can be achieved without changing the hardware structure.
[0052] In a non-limiting example, the instruction set may include a variety of instructions as shown in Table 1. However, it should be understood that the various instructions in the instruction set are not limited to those shown in Table 1, and may include a variety of other existing instructions. Optionally, one or more of the memory access instruction slots for memory access instructions, the computation instruction slots for computation instructions, and the control instruction slots for control instructions may be assigned NOP instructions according to the design requirements of the instructions.
[0053] Table 1
[0054] In operation S120, input data and weight data can be received from the storage system based on memory access instructions in the instruction set.
[0055] In some example embodiments, the acceleration core may include an instruction decoding module, a register control module, an address calculation unit, and a processing unit array.
[0056] The instruction decoding module decodes the instruction set received from the storage system to obtain memory access instructions, computation instructions, and control instructions. In some example embodiments, a delay slot mechanism ensures the correctness of control dependencies between control instructions and memory access and computation instructions.
[0057] The register control module can store loop variables, loop boundaries, and constants required for address calculations, and update loop variables based on control instructions. In some example embodiments, the register control module may include an inner state machine and an outer state machine, and also maintain a loop counter to record the remaining number of instruction repetitions. The inner state machine can control the updates of the inner loop variables and the loop counter based on control instructions, wherein the inner loop variables include the convolution kernel row index, convolution kernel column index, and input channel index associated with the input data. The outer state machine can be triggered when it receives an inner loop completion signal from the inner state machine, and controls the updates of the outer loop variables, wherein the outer loop variables include the output row index, output channel index, and output column index associated with the output data. By configuring the register control module as a dual-state machine cooperative architecture, updates of various loop variables can be performed efficiently.
[0058] In a non-limiting example of operation S120, the address calculation unit can calculate the storage address of the input data and the storage address of the weight data in the storage system based on the memory access instruction and the loop variable provided from the register control module, and the processing unit array can receive the input data and weight data from the storage system based on the storage address of the input data and the storage address of the weight data in the storage system.
[0059] In some example embodiments, to calculate the storage addresses of input data and weight data in the storage system, the address calculation unit employs a loop-nested polynomial address mapping strategy. Based on the mode selection signal corresponding to the memory access instruction, it calculates the storage addresses of the input data and weight data in the storage system by polynomially combining a loop variable provided by the register control module with pre-stored address calculation constants. This loop-nested polynomial address mapping strategy indicates a unified abstraction of access patterns of different operators to high-dimensional tensors into an address mapping strategy of polynomial functions about loop variables. By adopting this strategy, the address calculation unit can uniformly transform access patterns of tensors of different operators and dimensions into regularized polynomial address calculations, avoiding the overhead of designing hard-wired address logic independently for each operator and achieving flexible address generation.
[0060] In some example embodiments, the processing unit array may include at least one of a vector dot product unit, a scalar arithmetic unit, and a nonlinear approximation unit. The vector dot product unit may include multiple parallel multipliers for performing dot product operations over multiple clock cycles and a multi-stage pipelined addition tree. The scalar arithmetic unit may include independent adders, multipliers, and comparators for performing scalar multiplication-addition or maximum value comparison operations over a single clock cycle. The nonlinear approximation unit employs a four-stage pipelined architecture and performs approximate calculations of exponential, reciprocal, and square root reciprocal functions using a piecewise linear approximation method. Therefore, it can support approximate calculations of complex operators such as Sigmoid, Softmax, and LayerNorm, and fills the gap in hardware acceleration support for nonlinear operations in existing instruction set architectures. Furthermore, through instruction-level parallel issue mechanisms and pipelined scheduling mechanisms, parallel execution and time overlap of memory access operations, computation operations, and control operations are achieved, effectively hiding data migration latency and improving the parallel efficiency of computation and storage units.
[0061] In operation S130, calculations can be performed on input data and weight data based on calculation instructions and control instructions in the instruction set to generate output data.
[0062] In one example, the processing unit array can perform operations on the input and weight data based on computation instructions to generate output data.
[0063] In operation S140, output data can be sent to the storage system based on memory access instructions in the instruction set.
[0064] In one example, the address calculation unit calculates the storage address of the output data in the memory system based on the memory access instruction and a loop variable provided from the register control module. The processing unit array then sends the output data and its storage address in the memory system to the memory system. The memory system can then store the output data in the memory system based on its storage address.
[0065] Through efficient collaboration between instruction sets and hardware, the same hardware architecture can support multiple models such as CNN and Transformer through software programming alone, effectively improving the programmability, scalability and computing resource utilization of hardware accelerators.
[0066] Figure 2 A block diagram of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0067] Reference Figure 2 Accelerator 200 may include storage system 210 and acceleration core 220.
[0068] The storage system 210 can store input data, weight data, output data, and an instruction set. The instruction set can include one or more instructions. Each instruction in the one or more instructions is a Very Long Instruction Word (VLE) instruction and includes a memory access instruction slot for allocating memory access instructions, a computation instruction slot for allocating computation instructions, and a control instruction slot for allocating control instructions. The memory access instruction slot, computation instruction slot, and control instruction slot in each of the one or more instructions are issued in parallel within the same clock cycle.
[0069] The acceleration core 220 can receive instruction sets from the storage system, receive input data and weight data from the storage system based on memory access instructions in the instruction set, perform calculations on the input data and weight data based on calculation instructions and control instructions in the instruction set to generate output data, and output the output data to the storage system based on memory access instructions in the instruction set.
[0070] Reference Figure 1 The computational methods described for the accelerator can be applied to accelerator 200, and to avoid redundancy, similar descriptions will not be repeated here.
[0071] Figure 3 A block diagram of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0072] Reference Figure 3 The accelerator may include a storage system 310 and an acceleration core 320.
[0073] In one example, the storage system 310 may employ a multi-bank parallel architecture. For instance, the storage system 310 may be divided into an instruction memory and three sets of data memories to support high-bandwidth data access. The instruction memory (not shown) may be used to store instructions (or instruction sets) 311. The three sets of data memories (e.g., a first data memory, a second data memory, and a third data memory (not shown)) may be used to store weights (or weight data) 312, inputs (or input data) 313, and outputs (or output data) 314, respectively. In a non-limiting example, each memory bank may have independent address and data interfaces and be connected to the acceleration core via a crossbar network 315 (e.g., a crossbar matrix) to support high-bandwidth data access.
[0074] The acceleration core 320 may include an instruction decoding module 321, address calculation units (e.g., address calculation units 322-1 and 322-2), a register control module 323, and a processing unit array 324. Optionally, the acceleration core 320 may include address registers (e.g., address registers 325-1 and 325-2) for latching addresses.
[0075] The instruction decoding module 321 can be connected to the instruction memory to read and parse the instructions to be executed.
[0076] The register control module 323 can be used to maintain the inner and outer loop variables and their boundary values required during the address calculation process.
[0077] Address calculation unit 322-1 and address calculation unit 322-2 can be connected to instruction decoding module 321 and register control module 323 respectively, and are used to calculate (e.g., real-time calculation) the storage address of data (e.g., one or more of weight 312, input 313 and output 314) in storage system 310 according to the parsed control signal and the loop variable provided by register control module.
[0078] The processing unit array 324 can be a two-dimensional computing array composed of multiple processing units. Each processing unit integrates a vector dot product unit for performing multiplication-accumulation operations and a nonlinear approximation unit for performing approximate calculations of nonlinear functions such as exponents and reciprocals.
[0079] Figure 4 An example structural format of a single instruction according to an exemplary embodiment of the present disclosure is shown.
[0080] In some example embodiments, the instruction set architecture can follow a very long instruction word (VLIO) design paradigm. Depending on design requirements, a single instruction can have various bit widths. In one example, the total bit width of a single instruction is 120 bits. The various bit widths of the fields described below are exemplary, and the bit width of the fields in this disclosure is not limited thereto and can be changed as needed.
[0081] Reference Figure 4 Each instruction is strictly divided into five functionally independent instruction slots: the first memory access instruction slot, the second memory access instruction slot, the first calculation instruction slot, the second calculation instruction slot, and the control instruction slot. Each instruction slot consists of an 8-bit instruction opcode field and an immediate digital field of a certain width (e.g., different bit widths). Each bit of the immediate digital field can be directly mapped to an independent micro-operation control signal at the hardware level to configure the operating mode of the corresponding functional unit, select the data path, or control the update behavior of the status register.
[0082] The first and second memory access instruction slots can be used to store memory access instructions. The first and second calculation instruction slots can be used to store calculation instructions. The control instruction slot can be used to store control instructions. Memory access instructions, calculation instructions, and control instructions can include, but are not limited to, the instructions shown in Table 1 above.
[0083] In some example embodiments, the opcode 0 of the first memory access instruction slot can correspond to a memory access instruction that loads input data, and the immediate value 0 of the first memory access instruction slot (e.g., a 16-bit immediate value) can be used to configure the polynomial coefficients required by the address calculation unit when calculating the memory address of the input feature map. The opcode 1 of the second memory access instruction slot can correspond to a memory access instruction that loads weight data, and the immediate value 1 of the second memory access instruction slot can include 16-bit polynomial coefficients for address calculation. The highest bit of the 16-bit polynomial coefficients for address calculation is further multiplexed to define a loop variable update enable signal, while the lowest bit of the 16-bit polynomial coefficients for address calculation is used to specify the specific loop variable number that needs to be updated. This allows a single memory access instruction to trigger the register control module to advance the calculation iteration state simultaneously with initiating a data read request.
[0084] In some example embodiments, the opcode 2 of the first computation instruction slot may correspond to a computation instruction for a vector dot product or a nonlinear function, and the immediate value 2 of the first computation instruction slot (e.g., an 8-bit immediate value) may be used to select the data path and operation mode within the processing unit. The opcode 3 of the second computation instruction slot may correspond to a computation instruction for a scalar arithmetic operation or a summation operation, and the immediate value of the second computation instruction slot (e.g., a 24-bit immediate value) may be used to provide a scalar computation constant or specify the address of a register involved in the operation.
[0085] In some example embodiments, the opcode 4 of the control instruction slot may correspond to a control instruction for program flow such as loop repetition or conditional jump, and the immediate value of the control instruction slot (e.g., a 16-bit immediate value) may be used to provide a jump address offset or the number of hardware loops.
[0086] For example, based on Figure 4 The instructions output from the accelerator, during actual operation, the collaborative workflow between the instruction decoding module and each execution component can be as follows.
[0087] The instruction decoding module fetches an instruction (e.g., a 120-bit instruction) from the instruction memory in each fetch cycle. In the subsequent decoding stage, this instruction is synchronously decomposed in the hardware logic into five sets of micro-operation control signals, each corresponding to a different execution unit. These five sets of signals are completely independent in terms of physical transmission path and timing. Then, during the execution phase of a single clock cycle, these five sets of control signals are simultaneously transmitted to the corresponding functional modules.
[0088] The control signal generated by the decoding of the first memory access instruction slot (e.g., the first memory access instruction) drives the address calculation unit to calculate the read address of the input data in the second data memory based on the addressing mode configured by the immediate value 0 of the instruction and the value of the outer loop variable currently provided by the register control module. The control signal generated by the decoding of the second memory access instruction slot (e.g., the second memory access instruction) drives the address calculation unit to calculate the read address of the weighted data in the first data memory using a similar mechanism. In one example, if the instruction currently being executed by the second memory access instruction slot is an LDB instruction and its most significant bit of immediate value 1 is valid, this bit signal will act directly on the register control module as a hardware trigger condition, driving the loop variable to perform an update operation according to the number specified by the lower bit of the instruction. Simultaneously, the control signals generated by the decoding of the first and second computation instruction slots are sent to the processing unit array to pre-configure the pipeline stage registers of the addition tree inside the vector dot product unit, or to select the type of nonlinear operation performed by the nonlinear approximation unit. The signals generated by the decoding of the control instruction slots are used to update the program counter or control the repeated issue behavior of the instruction cache.
[0089] Figure 5 A schematic diagram of a storage system according to an exemplary embodiment of the present disclosure is shown.
[0090] Reference Figure 5The storage system 500 may include an instruction memory (e.g., an instruction memory (SRAM_I) 510) and a data memory (e.g., a second data memory (SRAM_A) 520, a first data memory (SRAM_B) 530, and a third data memory (SRAM_C) 540). Corresponding to the data access requirements when the accelerator executes various operators, the data involved in the computation includes input data, weight data (or parameter data), and the output data obtained from the computation. Considering the different characteristics of the above three types of data in terms of access bandwidth, multiplexing mode, and lifetime, such as... Figure 5 As shown, the data storage includes at least a second data storage 520, a first data storage 530, and a third data storage 540, and the second data storage 520, the first data storage 530, and the third data storage 540 are used to store input data, weight data, and output data, respectively. In some examples, the second data storage 520 and the third data storage 540 are divided into... M Each independent storage unit (or storage block) is divided into, and the first data storage unit 530 is divided into, N Each is an independent storage unit (or storage block), among which... M and N It is a positive integer, and M and N The value can be configured according to the parallel scale and data bit width of the processing unit array. The depth and data bit width of each memory address are preset values, enabling each memory address to store one memory address in parallel. k A dimensional vector, where, k It is a positive integer, and k The value of matches the number of elements processed in parallel by the processing unit in a single operation. In terms of addressing mode, the high-order bits of the address bus are used to identify the memory cell address within the memory block, and the low-order bits are used to identify the target memory block number. The three sets of data memories are each connected to the read / write access interface of the acceleration core 550 via independent crossbar networks (e.g., crossbar network 531, crossbar network 521, and crossbar network 541) (or crossbar matrices). Each crossbar matrix integrates an access arbitrator (e.g., arbitrator 0 to arbitrator M-1 (not shown)).
[0091] A crossbar network can be a static switch used to route physical connections between different components. A crossbar network is a non-blocking network, allowing simultaneous connections between all possible point-to-point connections. In this disclosure, the crossbar network can be any existing crossbar network.
[0092] like Figure 5As shown, for multiple concurrent access requests to the same memory block (e.g., i_rreq indicates a valid request, i_raddr indicates the requested address), the arbitrator prioritizes requests with lower memory block numbers (e.g., req2bank0 indicates the memory block with request number 0, req2bankM-1 indicates the memory block with request number M-1), while recording unresponsive requests in a pending queue (e.g., reg_raddr and reg_rreq are recorded unresponsive historical addresses and historical requests), and arbitrating them first in subsequent clock cycles. The arbitrator reorders the request sequence before issuing access requests and reassembles the response results after receiving data returned from the memory block to ensure that the order of data returned to the acceleration core remains consistent with the original request order.
[0093] Figure 6 A schematic diagram showing a feature map according to an exemplary embodiment of the present disclosure. Figure 7 A schematic diagram illustrating weight data according to an exemplary embodiment of the present disclosure is shown.
[0094] like Figure 6 As shown, feature map 610 can correspond to input data or output data. The multidimensional tensor of feature map 610 is re-expanded and stored in blocks according to a preset dimensional order before being stored in the second data memory (e.g., the first storage unit SRAM_A). Specifically, the channel dimension of feature map 610 is divided into several channel groups (e.g., in...). Figure 6 In the non-restricted example, there are 447 channel groups, each containing... k Data from each channel (e.g., in) Figure 6 In the non-restricted example, k is 16), at the same spatial location within the same channel group k Each feature value is concatenated into a single data unit and stored at the same memory address within a specific memory block. For example, feature values FMap_15 to FMap_00 at the same spatial location within the same channel group are concatenated into a single data unit and stored at the same memory address within a specific memory block. Similarly, feature values FMap_31 to FMap_16 at the same spatial location within the same channel group are concatenated into a single data unit and stored at the same memory address within a specific memory block. Likewise, feature values FMap_447 to FMap_432 at the same spatial location within the same channel group are concatenated into a single data unit and stored at the same memory address within a specific memory block. Regarding the allocation between memory blocks, different rows of input data are divided by their row numbers. M The remainder is used in storage blocks with different numbers. Data units within the same data row are stored sequentially in the contiguous address space of the corresponding storage block in ascending order of column address. Figure 7The weight data in the first data memory (e.g., the second storage unit SRAM_B) adopts a similar block-based strategy. The input and output channel dimensions of the convolution kernel are divided into channel groups (e.g., channel groups 00 to 287). The k parameter values (e.g., parameter values Kernel_270 to Kernel_287) in a parameter sub-block determined by the same input and output channel groups are concatenated into a data unit and stored sequentially in each storage block according to a preset dimension priority order. The output data in the third data memory (e.g., the third storage unit SRAM_C) is arranged in the same way as the input data, that is, it is stored in blocks according to the priority order of output channel group, row direction, and column direction.
[0095] By designing the above storage layout rules, the input data blocks, parameter data blocks, and output data blocks required for the computation process can make maximum use of the parallel bandwidth of multiple storage blocks when performing different operators such as convolution, fully connected, and matrix multiplication, thus avoiding data access blocking caused by storage conflicts.
[0096] Figure 8 A schematic diagram of an address calculation unit according to an exemplary embodiment of the present disclosure is shown.
[0097] Reference Figure 8 Based on reference Figure 6 and Figure 7 The described storage architecture and data layout rules, the polynomial address generation logic inside the address calculation unit (AGU) 810 is designed to be closely adapted to this storage layout.
[0098] In one example embodiment, the address calculation unit 810 can employ a polynomial address mapping strategy based on nested loops. The core idea of this strategy is to abstract the access patterns of different operators to high-dimensional tensors into a unified polynomial function about the loop variable, where the specific coefficients of this polynomial function are related to the dimension parameters in the aforementioned storage arrangement rules (e.g., determined by the dimension parameters in the aforementioned storage arrangement rules). To implement this strategy, the address calculation unit 810 internally pre-defines multiple sets of address generation templates. These templates can correspond to typical computational patterns such as convolution, fully connected operations, and matrix multiplication. Each template corresponds to a specific set of polynomial structures. For example, each template may include one or more adders, multipliers, and shifters. These templates can be selectively enabled based on the mode enable signal `mode_en`.
[0099] Address calculation unit 810 can receive address calculation constants (e.g., address calculation constants C1, C2...C1). n) and loop variables (e.g., loop variables V1, V2...V n The address calculation constant can be pre-calculated by the software based on the input data size, parameter size, number of channels, and step size of the current network layer. Before the calculation task starts, it is loaded from the first data memory (e.g., the second memory cell SRAM_B) into the constant register (not shown) by the LDM instruction and remains unchanged throughout the calculation of the network layer.
[0100] The current value of the loop variable is provided in real time by the register control module (not shown). The bit width of the loop variable matches the bit width of the input port of the multiply-accumulate operation path inside the address calculation unit 810. Based on one or more address calculation constants and one or more loop variables, the multiply-accumulate operation path inside the address calculation unit 810 can perform the operation and accumulation of multiple product terms in parallel within a single clock cycle, and output the original calculated address o_addr.
[0101] Meanwhile, the address calculation unit 810 may also include a boundary judgment module 811. The boundary judgment module 811 can perform validity checks on addresses (e.g., one or more intermediate calculated addresses generated during the generation of the original calculated address o_addr) based on preset cyclic boundary values (e.g., cyclic boundary values M_max and M_min). If the address exceeds the preset cyclic boundary value, the boundary judgment module 811 generates an address invalid flag, thereby masking out-of-bounds or invalid memory access requests. If the address is within the preset cyclic boundary value, the boundary judgment module 811 can output an address valid signal o_addr_vd to register (REG) 820.
[0102] The address calculation unit 810 can implement address calculation using combinational logic. Therefore, the instruction decoding module synchronously generates the address calculation signal addr_calc_en and the memory access signal mem_ren according to the current instruction type. The address calculation signal addr_calc_en latches the valid address o_addr output by the address calculation unit 810 in the current cycle into the address register 830. The output of the address register 830 is directly connected to the address interface of the on-chip memory 840 to output the address raddr in the address register 830 to the on-chip memory 840. The memory access signal mem_ren and the address valid signal o_addr_vd output by the address calculation unit 810 can be input to the judgment logic (e.g., AND gate (&)) 850 to jointly determine the access request rreq of each memory bank, and send the request signal rreq to the on-chip memory 840 (e.g., the memory arbitration module (not shown) in the on-chip memory 840).
[0103] To further illustrate the address generation process of the address calculation unit 810 in a specific operator, the following embodiment will be described using a convolution operator with a stride of 1 as an example. However, it should be understood that various other operators (such as, but not limited to, fully connected operations, matrix multiplication, etc.) are also feasible.
[0104] In a non-limiting example, the computation process of this convolution operator can correspond to a predetermined number of nested loop structures (e.g., a six-layer nested loop structure as shown in Algorithm 1 below). The outer loop variable may include the output row index, output channel index, and output column index, and is used to traverse the elements of the output feature map. The inner loop variable may include the convolution kernel row index, convolution kernel column index, and input channel index, and is used to generate all the inputs required to generate a single output element. The address calculation unit 810 generates the input data address, weight address, and output data address in parallel each clock cycle based on the current value of the loop variable.
[0105]
[0106] In Algorithm 1, the boundaries of each loop variable ( ) and the coefficients of each term in the address calculation polynomial ( All addresses are pre-calculated by the software based on the dimension parameters of the current network layer and stored as address calculation constants in the accelerator's constant register. During each cycle of address calculation, the multiply-accumulate operation path inside the address calculation unit 810 performs a polynomial combination of the current loop variable and the corresponding address calculation constant to generate the target storage address. Simultaneously, the boundary judgment module 811 checks the validity of the generated address based on preset loop boundary values. If the current convolution window exceeds the boundary of the input feature map, the boundary judgment module 811 generates an invalid address flag, thereby avoiding the loading of invalid data. The address calculation unit 810 outputs a new address each clock cycle as the loop variable changes, eliminating the need for additional address calculation cycles and thus completely overlapping with the pipelined computation of the processing unit array.
[0107] Figure 9 A schematic diagram of a processing unit array according to an exemplary embodiment of the present disclosure is shown. Figure 10 A schematic diagram of a nonlinear approximation unit in a processing unit array according to an exemplary embodiment of the present disclosure is shown.
[0108] Reference Figure 9 The processing unit array 900 may include multiple processing units 910 and can perform calculations between input data 901 and weight data 902. For example, the processing unit array 900 may employ a two-dimensional regularized computation structure composed of multiple processing units 910. In one example, the multiple processing units 910 may include M rows and N columns of processing units, where M and N are positive integers.
[0109] Each processing unit 910 may include a vector dot product unit 911, a scalar computation unit (also called a scalar operation unit) 912, a nonlinear approximation unit 913, a result register 914, and a summation unit 915, and is connected to the parameter register group through a multiplexer network to form a configurable data path. The operating mode of this data path is dynamically determined by the instruction decoding module based on the register address generated by the opcode and immediate value in the current instruction slot, thereby enabling the same hardware array to perform different types of computational tasks such as vector dot product, scalar operation, or nonlinear function approximation at different times.
[0110] The vector dot product unit 911 may include any type of circuitry configured to perform vector dot products. For example, the vector dot product unit 911 may include any number of multipliers, adders, accumulators, and registers.
[0111] The scalar calculation unit 912 may include any type of circuitry configured to perform scalar calculations. For example, the scalar calculation unit 912 may include separate adders, multipliers, and comparators.
[0112] The nonlinear approximation unit 913 may include any type of circuit configured to perform nonlinear approximation. For example, the nonlinear approximation unit 913 may include a data splitting module for data splitting, a logarithmic approximation module for logarithmic approximation, an exponential approximation module for exponential approximation, and a data correction module for data correction.
[0113] Result register 914 can be a register configured to store results (e.g., intermediate results, final results, etc.).
[0114] The summation unit 915 may include any type of circuitry configured to perform summation on at least two of the results stored in the result register 914. For example, the summation unit 915 may include any number of adders, accumulators, and registers. The summation unit 915 may operate in response to the enable signal `sum_en`. The summation unit 915 may clear its internal data in response to the control signal `clear`.
[0115] In a non-limiting example, when the first computation instruction slot decodes to generate a DOT instruction, the control signal corresponding to the DOT instruction initiates row and column broadcasting of the input feature vector and weight vector, simultaneously distributing multi-channel data from the data memory to all processing units 910 in the array; simultaneously, the parallel multiplier inside each processing unit 910 is activated, completing the data multiplication operation within a single clock cycle, and sending the multiplication result to the subsequent adder (e.g., an addition tree). In a non-limiting example, the addition tree can adopt a pipelined structure, where each adder receives the partial sum of the previous stage in the next clock cycle and accumulates it, outputting the complete dot product partial sum after multiple clock cycles. The result register (e.g., the accumulation register) 914 inside each processing unit 910 is responsible for accumulating the current partial sum with the partial sum generated in subsequent cycles in a timing-aligned manner until all multiplication and accumulation operations of a complete output sub-block are completed.
[0116] In a non-limiting example, when the second computation instruction slot decodes to generate a scalar arithmetic instruction such as ADD, MULT, or MAX, the generated control signal enables the scalar computation unit 912 within the processing unit 910. The scalar computation unit 912 may include independent adders, multipliers, and comparators. Data input to the scalar computation unit 912 may come from direct loading from a data memory or from the output of the vector dot product unit 911 or the nonlinear approximation unit 913. The scalar computation unit 912 completes the corresponding arithmetic or comparison operation within a single clock cycle and writes the result back to a designated result register (e.g., an arithmetic logic unit (ALU) register) 914.
[0117] When the second computation instruction slot decodes to generate an EXP, RECIP, or SQRT instruction, the generated control signal is used to select the nonlinear approximation unit 913 inside the processing unit. Figure 9 The nonlinear approximation element 913 can correspond to Figure 10 The nonlinear approximation element is 1000.
[0118] like Figure 10 As shown, the nonlinear approximation unit 1000 can adopt a multi-stage pipelined architecture (e.g., a four-stage pipelined architecture) and can sequentially include a data splitting module 1010, a logarithmic approximation module 1020, an exponential approximation module 1030, and a data correction module 1040. Each of the data splitting module 1010, logarithmic approximation module 1020, exponential approximation module 1030, and data correction module 1040 can include a register for storing data.
[0119] In one example embodiment, the nonlinear approximation unit 1000 can adopt a four-stage pipeline architecture and a piecewise linear approximation method, which can efficiently complete the approximate calculation of nonlinear functions such as exponents, reciprocals, and square root reciprocals. It supports low-precision inference of complex operators such as Sigmoid, Softmax, and LayerNorm, filling the gap in the hardware acceleration support for nonlinear operations in the existing instruction set architecture.
[0120] The data splitting module 1010 is responsible for splitting the input fixed-point number (e.g., INT8 fixed-point number) by x. in (or x) can be decomposed into an integer part (int) and a fractional part (frac), or represented as a base-2 floating-point form (i.e., This allows for subsequent approximation processing. The two difference forms shown above are numerically equivalent. The signal alu_op can be used to select one of the two splitting forms to output based on the splitting method. The Calc_k module can be used to calculate the order k of the output. The k-14 module can be used for order correction corresponding to 14 decimal places. The data splitting module 1010 can adjust the input parameter n. in and M in The following operation will be performed. Input parameter n in and M in It can be a fixed-point parameter of the input scaling factor s, where s=2 -n ×M, where n is a 5-bit unsigned integer and M is an 8-bit signed integer.
[0121] The logarithmic approximation module 1020 can select preset piecewise linear fitting parameters (e.g., logarithmic approximation parameter a) based on the high-order interval of the input value. i and b i The system implements a linear approximation of logarithmic operations through a multiply-accumulate unit that includes multipliers and adders, and passes the calculation result to the exponential approximation module. For example, ai and bi can be the optimal parameter pair for piecewise approximation calculations obtained by least squares. In one example, ai and bi can be one or more of the following: 16-bit signed fixed-point numbers, 1 sign bit, 1 integer bit, and 14 decimal bits.
[0122] The exponential approximation module 1030 adopts a piecewise linear structure similar to that of the logarithmic approximation module 1020, utilizing the exponential approximation parameter a selected from the pre-stored exponential approximation parameters. i and b i Perform multiplication and addition operations on the output of the previous stage to complete the power approximation to base 2.
[0123] Finally, the data correction module 1040 performs multiplication, addition, and shift adjustments on the output of the exponential approximation module to achieve data normalization and format conversion. For example, the data correction module 1040 can adjust the input parameter n... outand M out The following operation will be performed. Input parameter n out and M out It can be a fixed-point parameter of the output scaling factor s, where s=2 -n ×M, where n is a 5-bit unsigned integer and M is an 8-bit signed integer.
[0124] The aforementioned four-stage pipeline processes input data from four different stages simultaneously within a single clock cycle. Each clock cycle can initiate a new nonlinear approximation calculation, thereby achieving high computational throughput while maintaining low latency.
[0125] In a non-limiting example, the hardware pipeline lengths corresponding to different computation instructions vary. For example, in this embodiment, the DOT instruction requires multiple clock cycles to output a complete result after passing through a multiplier, an adder tree, and an accumulator register; the EXP, RECIP, and SQRT instructions, due to their four-stage pipeline, require four clock cycles to output a valid result; while scalar instructions such as ADD, MULT, and MAX can be completed in just one clock cycle.
[0126] When issuing computation instructions, the instruction decoding module does not automatically insert wait cycles. Instead, it relies on the compiler to reasonably arrange independent other operations or NOP instructions in the instruction sequence to satisfy data dependencies, i.e., delay slots. Through the above-mentioned fine-grained instruction slot partitioning and control signal generation, it is possible to achieve unified support for vector dot product, nonlinear function approximation, and scalar arithmetic operations on the same processing unit array. Moreover, each type of operation can be flexibly switched within different clock cycles without changing the hardware structure.
[0127] Figure 11 A schematic diagram of an inner state machine and an outer state machine in a register control module according to an exemplary embodiment of the present disclosure is shown.
[0128] In one example embodiment, the register control module can maintain all loop variables, loop boundaries, and constants relied upon by the address computation unit when performing multi-level nested loop address generation, while managing the loop counters required by the hardware loops. Depending on the data flow organization of the hardware computation, the register control module can divide the loop variables into an inner loop variable group and an outer loop variable group, each containing multiple counters (e.g., three independent counters). The inner loop variable group can be used to control the traversal of input data required for individual output point computation, and the outer loop variable group can be used to control the overall traversal order of the output feature map. The initial values, boundary values, and update priorities of all loop variables are pre-configured by software before the computation task starts and loaded into the register control module's dedicated register group before task startup. Furthermore, the register control module can also maintain a hardware loop counter to record the remaining number of times the current instruction needs to be executed.
[0129] To achieve automatic updating and state management of the aforementioned loop variables and loop counters, the register control module can adopt a dual-state machine collaborative architecture (for example, refer to...). Figure 11 (Inner state machine 1100 and outer state machine 1200).
[0130] The inner state machine 1100 is responsible for updating the inner loop variables (e.g., inner loop variables ic, s, and r) and the loop counter. When not executing tasks, the inner state machine 1100 can be in the idle state INNER_IDLE and wait for a task to start. The task start and variable update of the inner state machine 1100 are triggered by control signals output by the instruction decoding module (e.g., control signals corresponding to LDB / LVM instructions). The inner state machine 1100 can update the inner loop variables after each inner calculation is completed. For example, after each inner calculation is completed, the inner state machine 1100 can increment the corresponding loop variables according to a preset priority order and decrement the loop counter once. When the loop counter decrements to zero, it indicates that the current loop body has been completed. At this point, the inner state machine 1100 decides whether to continue executing the inner loop or complete the calculation of the current output point, depending on whether the loop variables have simultaneously reached a preset upper bound value. When the three variables in the inner layer reach their upper bound values simultaneously, the inner layer state machine 1100 sets the inner loop completion signal high and notifies the outer layer state machine 1200 to switch to the calculation of the next output point, while resetting the inner layer variables to their initial values.
[0131] When not performing tasks, the outer state machine 1200 can be in the idle state OUTER_IDLE and wait for tasks to start. The outer state machine 1200 can be triggered when the inner loop completion signal is valid, incrementing the outer loop variables (e.g., outer loop variables j, oc, and i) according to a preset priority order. After each update, the task is calculated for the corresponding new output point. When the three variables of the outer layer reach the upper bound value at the same time, it means that all output points of the current network layer have been calculated. The outer state machine 1200 sets the calculation completion signal high to trigger subsequent data write-back or inter-layer switching operations.
[0132] Building upon the aforementioned register control module, the control instruction slot generates corresponding control signals by decoding different instructions. These signals act on the program counter, the register control module itself, and the address mapping logic of the data memory. Specifically, when the control instruction slot decodes an RPT instruction, the control signal for the RPT instruction loads the repetition count specified in the instruction's immediate value into the hardware loop counter in the register control module, and simultaneously sets the counter to decrement mode. Subsequently, at the end of each clock cycle, the register control module automatically decrements the loop counter by one and checks if its current value is zero. If the counter is not yet zero, the program counter retains its current value, allowing the current instruction line to be repeatedly issued in the next cycle; if the counter is zero, the program counter increments to execute subsequent instructions.
[0133] When the LVM instruction is generated during decoding, the control signals of the LVM instruction are specifically used to trigger the state transitions of the state machines in the register control module. Specifically, the highest bit of the instruction immediate value is used to select the type of state machine to be triggered. When the highest bit of the instruction immediate value is a logical value of 0, the inner state machine 1100 is triggered. When the highest bit of the instruction immediate value is a logical value of 1, the outer state machine 1200 is triggered. The lower bits of the instruction immediate value are used to specify the loop variable number to be updated, which corresponds to the priority order of variable updates. When executing the LVM instruction, the register control module selects the corresponding state machine based on the highest bit, and then automatically completes the update of a set of loop variables according to the priority order specified by the lower bits: First, it attempts to increment the innermost loop variable. If the current value of the innermost loop variable has not reached the preset upper bound, only the variable is updated and the current LVM operation ends; if the current value of the variable has reached the upper bound, the variable is reset to its initial value, and the increment operation is carried over to the next level loop variable, and the above judgment process is repeated; this process continues until all three levels of variables have reached their upper bounds and have been reset. The state machine sets the corresponding cycle completion flag, that is, the inner state machine 1100 sets the inner cycle completion signal high, and the outer state machine 1200 sets the calculation completion signal high.
[0134] When the decoder generates a BC instruction, its control signals determine whether the program counter increments sequentially or jumps to the offset address specified by the immediate value, based on the loop variable boundary comparison result output by the register control module. Specifically, if the loop variable has not reached its upper bound, the program counter executes a jump; if the loop variable has reached its preset boundary, the program counter executes sequentially, thereby achieving conditional branching or loop exit.
[0135] When the LEND instruction is generated during decoding, the control signal of the LEND instruction indicates the termination of the current network layer computing task. The memory exchange indicator bit in the immediate value is used to control the exchange of the base address mapping relationship between the first and third memory units in the on-chip data memory. This enables the logical switching of the input and output memory spaces of the next network layer without actual data movement, reducing redundant off-chip memory access.
[0136] In one example embodiment, the control instructions, memory access instructions, and computation instructions mentioned above ensure the correctness of control dependencies through a delay slot mechanism. Specifically, when the control instruction slot decodes to generate a BC conditional jump instruction, this instruction is equipped with two delay slots. That is, within two clock cycles after the BC instruction is issued, the two instructions immediately following it will still execute normally. Subsequently, the program flow determines whether a jump occurs based on the loop variable boundary comparison result output by the register control module and the zeroing state of the loop counter. When generating the instruction sequence, the compiler fills these two delay slots with independent instructions or NOP instructions that are not dependent on the current control flow to ensure the correctness and continuity of the pipeline before and after the jump. The RPT instruction is also equipped with two delay slots, but its behavior is different from that of the BC instruction. After the RPT instruction is issued, the two instructions immediately following it are temporarily stored in the instruction buffer by hardware logic. At the same time, the loop counter is loaded according to the aforementioned mechanism, and the current instruction line is repeatedly executed. During the entire loop repetition, the two temporarily stored delay slot instructions are never executed. After the loop counter reaches zero and the repeated execution ends, the hardware will retrieve and execute the two previously temporarily stored instructions in sequence. Then the program counter will increment to execute the subsequent instructions after the RPT instruction.
[0137] Figure 12 A flowchart illustrating a computation method of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0138] The following table 2 will be used as an example to describe the process. Figure 12 The computational methods of the accelerator are shown in Table 2. For example, an exemplary instruction sequence for the accelerator to complete the entire computation of a convolutional layer under the control of a VLIW instruction sequence can be shown in Table 2. Note that the exemplary instruction sequences shown in Table 2 are non-limiting and can be changed according to design needs.
[0139] Table 2
[0140] Reference Figure 12 In operation S1210, constants can be initialized.
[0141] In one example, referring to Table 2, during the initialization phase, the instruction decoding module can read the VLIW instruction sequence from the instruction memory. Based on the LDM instruction in the first VLIW instruction decoded from the VLIW instruction sequence by the instruction decoding module, the address calculation constants pre-computed by the compiler (i.e., in Algorithm 1) can be used. and loop boundaries It is loaded from the first data memory SRAM_B into the constant register group of the accelerator and used in the address calculation process of the subsequent address calculation unit.
[0142] In operation S1220, the DOT register can be initialized.
[0143] In one example, referring to Table 2, based on the AccIV instruction in the next VLIW (i.e., the second VLIW instruction) decoded from the VLIW instruction sequence by the instruction decoding module, bias data loading can be performed. The bias vector corresponding to the current output channel is read from SRAM_B, and the bias vector is written into the accumulator register inside each processing unit in the processing unit array. At this point, all data preparation before computation is complete.
[0144] In operation S1230, data reading and address calculation of the inner loop can be performed.
[0145] In one example, referring to Table 2, the accelerator can enter the data reading and address calculation phase of the inner loop. The next VLIW instruction (i.e., the third VLIW instruction) can simultaneously contain LDA and LDB instructions. The LDA instruction drives the address calculation unit AGU_A to calculate the read address of the input feature map (i.e., the input data) in the second data memory SRAM_A based on the current loop variable and the address calculation constant, and latches the generated address into the address register set. The LDB instruction drives the address calculation unit AGU_B to calculate the read address of the weight data in the first data memory SRAM_B in a similar manner. After the address is generated, the accelerator reads a 16-channel input data block and the corresponding weight data block in parallel from the second data memory SRAM_A and the first data memory SRAM_B based on these addresses, and sends them to the input buffer of the processing unit array. It is worth noting that the most significant bit of the immediate value of the LDB instruction is configured to be valid. Therefore, while completing the address calculation and data reading, the instruction also triggers the inner state machine in the register control module to update the inner loop variable according to the preset priority order (convolution kernel row index, convolution kernel column index, input channel index).
[0146] In operation S1240, vector dot product calculation can be initiated and a hardware loop can be established.
[0147] For example, the accelerator initiates vector dot product calculation and establishes a hardware loop. The next instruction (i.e., the fourth VLIW instruction) combines the LDA and LDB instructions with the DOT and RPT instructions. The LDA and LDB instructions repeatedly perform address calculation and data fetch operations, providing new data for the calculation in the next cycle. The DOT instruction drives the vector dot product unit in the processing unit array to perform multiplication and addition tree accumulation on the input data block and weight data block fetched in the previous cycle, producing a partial sum result. The RPT instruction sets the hardware loop counter to the preset number of repetitions in the instruction and causes the counter to automatically decrement each clock cycle. Thereafter, the fourth VLIW instruction, which includes the LDA, LDB, DOT, and RPT instructions, is repeatedly executed until the loop counter reaches zero. During this process, the AGU outputs a new address each cycle, the data memory provides a new data block each cycle, and the vector dot product unit initiates a new multiply-accumulate operation each cycle. These three components form a pipeline, achieving complete overlap between computation and memory access.
[0148] In operation S1250, it can be determined whether the instruction loop variable (e.g., the count value of the loop counter) is 0.
[0149] If the instruction loop variable is 0 in operation S1250, then the process can return to operation S1230.
[0150] If the instruction loop variable is 0 in operation S1250, then operation S1260 can proceed.
[0151] In operation S1260, the outer loop variables can be updated, and the calculation of the current network layer ends when all outer loop variables have reached their upper bounds.
[0152] In one example, referring to Table 2, when the loop counter of the RPT instruction of the fourth VLIW instruction decrements to zero, the inner accumulation is complete, and the partial sum of the current output point has been accumulated. The next VLIW instruction executed (i.e., the fifth VLIW instruction) can include the PREC instruction and the LVM instruction. The PREC instruction can drive the address calculation unit to calculate the write address of the current output point in the third data memory SRAM_C based on the current outer loop variable, and latch this address into the address register group. The LVM instruction can trigger the outer state machine in the register control module to update the outer loop variable according to a preset priority order. Optionally, the fifth VLIW instruction can also include the DOT instruction. For example, the DOT instruction of the fifth VLIW instruction can be used to calculate the data read by the LDA and LDB instructions of the fourth VLIW instruction.
[0153] In one example, there may be a sixth VLIW instruction and a seventh VLIW instruction. The sixth and seventh VLIW instructions may contain NOP instructions. For example, the two empty lines of the sixth and seventh VLIW instructions may be because the last DOT instruction requires a several-cycle interval (e.g., 2 empty cycles) to produce the result data, thus filling in two empty operation lines.
[0154] After the above instructions are executed, the accelerator executes the BC instruction, and then executes the STORE and AccIV instructions in the delay slot of the BC instruction. For example, there may be a ninth VLIW instruction, which is a NOP instruction, between the BC instruction in the eighth VLIW instruction and the STORE instruction in the tenth VLIW instruction. Because the instruction immediately following BC should not be executed when BC jumps, a line of no-operation is filled (e.g., ). The STORE instruction can use the write address calculated by the previous PREC instruction to write the completed part and result of the processing unit array accumulation back to the third data memory SRAM_C; at the same time, the AccIV instruction can preload the bias data required for the next output point into the accumulator register of the processing unit array, preparing the data in advance for the calculation of the next output point. After two delay slot cycles, the BC instruction determines the behavior of the program counter based on the boundary comparison result of the outer state machine output. If the outer loop variable has not yet reached the upper bound, the program counter jumps to the inner loop start instruction address and begins the calculation of the next output point; if the outer loop variable has reached the upper bound, the program counter sequentially executes the subsequent LEND instructions (not shown) to end the calculation of the current network layer.
[0155] In a non-limiting example, the accelerator parameters can be set to M=16, N=16, and k=16, allowing for 4096 multiplications and additions per cycle. If the configured DOT array computing resources exceed the actual available resources, the size of the accelerator DOT array can be reduced by modifying the accelerator array parameters M, N, and k according to actual needs. Further increasing the data computation capacity can be achieved by expanding the size of the DOT array or stacking DOT arrays of the same size.
[0156] The execution of the above instruction sequence is entirely based on the same hardware architecture. If a nonlinear activation layer follows the current convolutional layer, the compiler does not need to modify the hardware configuration. It only needs to insert a new instruction sequence after the convolution instruction, replacing the corresponding nonlinear calculation instruction with the opcode of the computation instruction slot, DOT. This allows the nonlinear approximation units in the processing unit array to perform nonlinear transformations on the convolution results stored in the third data memory SRAM_C. Therefore, implementing complex operators such as Sigmoid, ReLU, Softmax, and LayerNorm only requires combining instructions such as EXP, RECIP, and SQRT with scalar operation instructions, while the hardware architecture remains unchanged. Therefore, the accelerator disclosed in this paper, through the flexible configuration of instruction sequences, adapts to various neural network models and operator types without modifying the hardware, achieving a balance between programmability and scalarity.
[0157] Figure 13 A flowchart illustrating a computation method of an accelerator according to an exemplary embodiment of the present disclosure is shown.
[0158] In operation S1310, data initialization can be performed.
[0159] During the initialization phase, the instruction sequence can be loaded into the instruction memory, the input data, weight data, and address calculation constants can be loaded into the corresponding memory blocks of the data memory, and the loop variables, loop boundaries, constants, and hardware loop counters in the register control module can be initialized.
[0160] In operation of S1320, instruction acquisition and decoding can be performed.
[0161] During the instruction fetch and decode phase, very long instruction words (VLIWs) can be read, and each instruction slot can be parsed to generate corresponding control signals. For example, the instruction decoding module can read instructions from the instruction memory, parse the opcode and immediate value of each instruction slot, and generate corresponding control signals.
[0162] In operation S1330, address generation and data reading can be performed.
[0163] During the address generation and data reading phase, the address calculation unit generates a read address by combining the current loop variable and the address calculation constant through a polynomial, and reads data from the data memory in parallel according to the read address and sends it to the processing unit array.
[0164] In one example, the address calculation unit obtains the current loop variable value from the register control module according to the calculation mode indicated by the current instruction. Combining this with pre-stored address calculation constants, it calculates the read addresses of the input memory and weight memory required for the current cycle through polynomial combination, and latches the calculation results into the address register group. Input data blocks and weight data blocks can be read in parallel from their corresponding memory banks in the input memory and weight memory according to the read addresses, and then sent to the processing unit array via the data bus.
[0165] In operation S1340, calculations can be performed.
[0166] During the computation phase, the processing unit array can be driven to perform dot product operations, scalar operations, or nonlinear approximate calculations according to the computation type indicated by the instruction, and output the computation results.
[0167] In one example, the instruction decoding module generates corresponding control signals based on the calculation type indicated by the current instruction. If the current instruction is a dot product instruction, the data is sent to the vector dot product unit to perform the dot product operation and obtain the result. If the current instruction is a nonlinear approximation calculation instruction, the data is sent to the nonlinear approximation unit, processed through a four-stage pipeline, and the calculation result is output. If the current instruction is a scalar operation instruction, the data is sent to the scalar operation unit to perform scalar multiplication and addition or maximum value comparison operations, and the calculation result is output.
[0168] In operation S1350, result write-back and status update can be performed.
[0169] During the result write-back and state update phase, the calculation results can be written back to the data storage, and the loop variable and hardware loop counter can be updated according to the loop control information. In one example, the address calculation unit can calculate the write address based on the current output location and write the calculation result back to the designated memory bank in the output memory. The register control module can update the inner loop variable based on the loop control information in the instruction; update the outer loop variable when the inner loop completes; and set the calculation completion flag when all loop variables reach the preset boundary.
[0170] In operation S1360, the above operation can be repeated until all computational tasks of the current network layer have been completed.
[0171] For example, operations S1310 through S1350 can be repeated until all computational tasks of the current network layer are completed.
[0172] The various modules in the accelerator of this disclosure shown can be configured as software, hardware, firmware, or any combination thereof to perform specific functions. For example, each module may correspond to a dedicated integrated circuit, pure software code, or a module combining software and hardware. Furthermore, one or more functions implemented by each module may also be uniformly executed by components in a physical entity device (e.g., a processor, client, or server).
[0173] Furthermore, the computational methods of the accelerator described herein can be implemented by a program (or instructions) recorded on a computer-readable storage medium. For example, according to an exemplary embodiment of the present disclosure, a computer-readable storage medium storing a computational program may be provided, wherein any of the methods described above are implemented when the computational program is executed by a processor.
[0174] The computer program in the aforementioned computer-readable storage medium can run in an environment deployed in computer devices such as clients, hosts, agent devices, and servers. It should be noted that the computer program can also be used to perform additional steps beyond those described above, or to perform more specific processing while performing the above steps. The details of these additional steps and further processing are already described in the reference... Figures 1 to 13 One or more of the related methods are mentioned in the description of the relevant methods, so they will not be repeated here to avoid repetition.
[0175] It should be noted that the various modules in the apparatus for quantizing neural network models according to exemplary embodiments of the present disclosure can rely entirely on the operation of a computer program to achieve their respective functions. That is, each module corresponds to each step in the functional architecture of the computer program, so that the entire system is called through a specialized software package (e.g., a lib library) to achieve the corresponding functions.
[0176] On the other hand, the various modules according to the various embodiments of this disclosure can also be implemented by hardware, software, firmware, middleware, microcode, or any combination thereof. When implemented in software, firmware, middleware, or microcode, the program code or code segment for performing the corresponding operation can be stored in a computer-readable medium such as a storage medium, so that a processor can perform the corresponding operation by reading and running the corresponding program code or code segment.
[0177] Here, the processor is not necessarily a single processor, but can be any collection of devices or circuits capable of executing the aforementioned instructions (or instruction sets) individually or in combination. The computing device can also be part of an integrated control system or system manager, or can be configured to interconnect locally or remotely (e.g., via wireless transmission) through an interface.
[0178] Processors may include central processing units (CPUs), graphics processing units (GPUs), programmable logic devices, dedicated processor systems, microcontrollers, or microprocessors. By way of example and not limitation, processors may also include analog processors, digital processors, microprocessors, multi-core processors, processor arrays, network processors, etc.
[0179] Some operations described in the methods of exemplary embodiments of this disclosure may be implemented in software, some operations may be implemented in hardware, and some operations may be implemented in a combination of software and hardware.
[0180] The processor can execute instructions or code stored in one of the storage components, which can also store data. Instructions and data can also be sent and received over a network via a network interface device, which can employ any known transport protocol.
[0181] Storage components can be integrated with the processor, for example, by placing RAM or flash memory within an integrated circuit microprocessor. Alternatively, storage components can include separate devices, such as external disk drives, storage arrays, or other storage devices that can be used by any database system. Storage components and the processor can be operatively coupled, or can communicate with each other, for example, via I / O ports, network connections, etc., enabling the processor to read files stored in the storage component.
[0182] The methods according to exemplary embodiments of this disclosure can be described as various interconnected or coupled functional blocks or functional diagrams. However, these functional blocks or functional diagrams can be equally integrated into a single logic device or operate according to non-precise boundaries.
[0183] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure, and are not intended to limit them. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this disclosure.
Claims
1. A calculation method for an accelerator, characterized in that, The calculation method is executed by the acceleration core of the accelerator, and the calculation method includes: The instruction set is received from the memory system outside the acceleration core. The instruction set includes one or more instructions, each of which is a Very Long Instruction Word (VLE) instruction and includes a memory access instruction slot for allocating memory access instructions, a computation instruction slot for allocating computation instructions, and a control instruction slot for allocating control instructions. The memory access instruction slot, computation instruction slot, and control instruction slot of each of the one or more instructions are issued in parallel within the same clock cycle. The memory access instructions in the instruction set receive input data and weight data from the storage system. The computation and control instructions in the instruction set are used to perform operations on the input and weight data to generate output data; and The memory access instructions based on the instruction set will send the output data to the storage system.
2. The calculation method according to claim 1, characterized in that, The acceleration core includes an instruction decoding module, a register control module, an address calculation unit, and a processing unit array. The calculation method further includes: decoding the instruction set received from the storage system using an instruction decoding module to obtain memory access instructions, calculation instructions, and control instructions. The register control module is configured to store the loop variables, loop boundaries, and constants required for address calculation, and to update the loop variables based on control instructions. The steps of receiving input data and weight data from the storage system include: calculating the storage address of the input data and the storage address of the weight data in the storage system using an address calculation unit based on memory access instructions and a loop variable provided by the register control module; and receiving the input data and weight data from the storage system using a processing unit array based on the storage addresses of the input data and weight data. The steps of performing operations on the input data and weight data include: using a processing unit array to perform operations on the input data and weight data based on computation instructions to generate output data, and The step of sending the output data to the storage system includes: calculating the storage address of the output data in the storage system by the address calculation unit based on the memory access instruction and the loop variable provided from the register control module, and sending the output data and the storage address of the output data in the storage system to the storage system by the processing unit array.
3. The calculation method according to claim 2, characterized in that, The correctness of control dependencies is ensured through a delay slot mechanism between control instructions, memory access instructions, and computation instructions.
4. The calculation method according to claim 2, characterized in that, The register control module includes an inner state machine and an outer state machine, and is also configured to maintain a loop counter for recording the remaining number of instruction repetitions. The inner state machine is configured to control the updates of the inner loop variables and loop counter based on control instructions. The inner loop variables include the convolution kernel row index, convolution kernel column index, and input channel index associated with the input data. The outer state machine is configured to be triggered when it receives an inner loop completion signal from the inner state machine, and to control the update of the outer loop variables, which include the output row index, output channel index, and output column index associated with the output data.
5. The calculation method according to claim 2, characterized in that, The steps for calculating the storage addresses of the input data and the weight data in the storage system include: The address calculation unit employs a polynomial address mapping strategy based on nested loops. According to the mode selection signal corresponding to the memory access instruction, it calculates the storage address of the input data and the storage address of the weight data in the memory system by polynomially combining the loop variable provided by the register control module with the pre-stored address calculation constant.
6. The calculation method according to claim 2, characterized in that, The processing unit array includes at least one of vector dot product units, scalar operation units, and nonlinear approximation units. The vector dot product unit includes multiple parallel multipliers for performing dot product operations over multiple clock cycles and a multi-stage pipelined addition tree. The scalar arithmetic unit includes independent adders, multipliers, and comparators for performing scalar multiplication-addition or maximum value comparison operations within a single clock cycle. The nonlinear approximation unit adopts a four-stage pipeline architecture and performs approximate calculations of exponential, reciprocal, and square root reciprocal functions through a piecewise linear approximation method.
7. The calculation method according to claim 1, characterized in that, The memory access instruction slots include a first memory access instruction slot for allocating a first memory access instruction and a second memory access instruction slot for allocating a second memory access instruction. The first memory access instruction includes a first memory access opcode field for loading input data and a first memory access immediate number field for configuring the address calculation of polynomial coefficients when loading input data. The second memory access instruction includes a second memory access opcode field for loading weight data and a second memory access immediate number field for configuring the address calculation of polynomial coefficients when loading weight data. The calculation instruction slots include a first calculation instruction slot for allocating a first calculation instruction and a second calculation instruction slot for allocating a second calculation instruction. The first calculation instruction includes a first calculation opcode field for vector dot product calculation or nonlinear approximation calculation and a first calculation immediate digital field for selecting the data path and operation mode inside the accelerator. The second calculation instruction includes a second calculation opcode field for scalar arithmetic calculation or summation calculation and a second calculation immediate digital field for providing scalar calculation constants or specifying the address of the register involved in the operation. The control instructions include opcodes for loop repetition or conditional jumps and immediate numeric fields for providing jump address offsets or hardware loop counts.
8. The calculation method according to claim 1, characterized in that, One or more of the memory access instructions in the memory access instruction slot, the calculation instructions in the calculation instruction slot, and the control instructions in the control instruction slot are configured differently for different operators.
9. An accelerator, characterized in that, The accelerator includes: The storage system is configured to store input data, weight data, output data, and instruction sets. An acceleration core, wherein the acceleration core is configured to perform the computation method as described in any one of claims 1 to 8.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the computation method as described in any one of claims 1 to 8.
