Vector reduction using shared scratchpad memory
A shared scratchpad memory architecture with DMA and arithmetic units addresses inefficiencies in vector reduction by allowing simultaneous accumulation across processor cores, enhancing neural network computation efficiency.
Patent Information
- Application Number
- JP2024083843
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2020-08-31
- Filing Date
- 2024-05-23
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-11-30
AI Technical Summary
Existing neural network computations face inefficiencies in vector reduction operations due to the need for synchronization and resource reservation across multiple processor cores, leading to performance and power consumption issues in memory systems.
Implementing a shared scratchpad memory architecture with direct memory access (DMA) and arithmetic units to perform accumulation operations directly in shared memory, allowing simultaneous vector accumulation across processor cores without the need for synchronization.
This approach reduces computational overhead and power consumption by enabling efficient vector reduction operations, improving performance and bandwidth in neural network computations.
Smart Images

Figure 2024116166000001_ABST
Abstract
Description
[Technical field]
[0001] background This specification relates generally to the circuitry of hardware circuits used to perform neural network computations. [Background technology]
[0002] A neural network is a machine learning model that utilizes one or more layers of nodes to generate an output (e.g., a classification) for a received input. Some neural networks include one or more hidden layers in addition to an output layer. The output of each hidden layer is used as an input to one or more other layers in the network (e.g., other hidden layers or the output layer of the network). Some of the layers of the network generate outputs from the received input according to the current values of a respective set of parameters. Some neural networks may be convolutional neural networks (CNNs) configured for image processing or recurrent neural networks (RNNs) configured for speech and language processing. Different types of neural network architectures can be used to perform a variety of tasks related to classification or pattern recognition, prediction including data modeling, and information clustering.
[0003] A neural network layer of a CNN may have an associated set of kernels, which may correspond to parameters or weights. The associated set of kernels is used to process an input (e.g., a batch of inputs) through the neural network layer to generate a corresponding output of the layer for computing a neural network inference. The batch of inputs and the set of kernels may be represented as a tensor (i.e., a multidimensional array) of inputs and weights. A hardware circuit that executes a neural network includes a memory having locations identified by address values. The memory locations may correspond to elements of the tensor, and the tensor elements may be traversed or accessed using the control logic of the circuit. For example, the control logic may determine or calculate a memory address value of an element to load or store a corresponding data value of the element. Summary of the Invention [Means for solving the problem]
[0004] overview This document describes techniques for performing data storage and vector reduction in a large shared scratch pad memory. In particular, these techniques are used to reduce the overall amount of operations required to perform vector reduction, including reducing values or outputs generated as a result of computations performed in each processor core of a computing system. For example, the system includes a hardware circuit that may have multiple processor cores and an architecture that incorporates static random access memory (SRAM) memory resources. The SRAM memory resources are allocated to be shared among multiple respective processor cores of the circuit.
[0005] A plurality of sets of computations performed in the computing system may be distributed to respective cores of one or more hardware circuits to generate respective vectors of values. A shared memory receives each of the vectors of values from a respective resource of a processor core using a direct memory access (DMA) data path of the shared memory. The shared memory performs an accumulation operation on each of the vectors of values using a processor unit coupled to the shared memory. The processor unit may include a processor unit encoded with the processor unit. The multiplier is configured to accumulate values based on the selected arithmetic operation. A result vector is generated based on the accumulation operation.
[0006] One aspect of the subject matter described herein may be embodied in a method performed with a hardware circuit having a shared memory and a plurality of processor cores in communication with the shared memory. The method includes generating a first vector of values based on a computation performed at a first processor core, the shared memory receiving the first vector of values from the first processor core using a direct memory access (DMA) data path of the shared memory, and performing an accumulation operation in the shared memory between the first vector of values and a vector stored in the shared memory. The accumulation operation is performed with a calculator unit that is i) coupled to the shared memory and ii) configured to accumulate a plurality of vectors. The method includes generating a result vector based on the accumulation operation.
[0007] Each of these and other implementations may optionally include one or more of the following features. For example, in some implementations, the vector stored in the shared memory was received from a second processor core, and the method includes the first processor core performing an accumulate-to-memory operation to accumulate respective values of a first vector of values into memory locations of the shared memory, and the second processor core performing an accumulate-to-memory operation to accumulate respective values of a second vector of values into memory locations of the shared memory, the second vector of values corresponding to the vector stored in the shared memory. In some cases, the second processor sets a flag (e.g., an initial vector / value flag) such that values of the second vector of values are written as initial values, while the first processor core sets a different flag (e.g., an accumulation flag) such that values of the first vector of values are accumulated with values of the second vector of values.
[0008] In some implementations, generating the result vector based on the accumulation operation includes generating the result vector without the first processor core performing a step of pre-accumulating products resulting from calculations performed by the first processor core, and generating the result vector without the second processor core performing a step of pre-accumulating products resulting from calculations performed by the second processor core.
[0009] In some implementations, generating the result vector includes generating a vector of accumulated values as a result of performing the accumulation operation on a first vector of values, applying an activation function to each value in the vector of accumulated values, and generating the result vector as a result of applying the activation function to each value in the vector of accumulated values. Accumulation may be performed on values of the first vector, or accumulation may include pair-wise accumulation of values of the first vector and values of the vector stored in the shared memory.
[0010] In some implementations, each resource of the first processor core is a first matrix calculation unit, and the method further includes generating a first vector of accumulated values corresponding to the first vector of values based on a matrix multiplication performed using the first matrix calculation unit of the first processor core.
[0011] In some implementations, the respective resource of the second processor core is a second matrix computation unit, and the method further comprises: computing a matrix multiplication for the second vector of values based on a matrix multiplication performed using the second matrix computation unit of the second processor core. The hardware circuit may be a hardware accelerator configured to execute a neural network having a plurality of neural network layers, the method including generating an output of a layer of the neural network based on the result vector.
[0012] The method may further include generating a first vector of values based on a calculation performed on the first processor core and generating a second vector of values based on a calculation performed on the second processor core. The calculation performed on the first processor core and the calculation performed on the second processor core may be part of a mathematical operation controlled by commutativity. In some implementations, the mathematical operation is a floating point multiplication operation, a floating point addition operation, an integer addition operation, or a min-max operation. In some implementations, the mathematical operation includes a floating point addition operation and an integer addition operation. The first processor core and the second processor core may be the same processor core.
[0013] In some implementations, the shared memory is configured to function as a shared global memory space including memory banks and registers shared between two or more processor cores of the hardware circuit.
[0014] Other implementations of this and other aspects include corresponding systems, devices, and computer programs configured to perform the actions of the methods encoded on a computer storage device. One or more computer systems may be so configured by software, firmware, hardware, or combinations thereof installed on the system that, when operated, causes the system to perform the actions. One or more computer programs may be so configured by having instructions that, when executed by a data processing device, cause the device to perform the actions.
[0015] The subject matter described herein can be implemented in particular embodiments to realize one or more of the following advantages.
[0016] The techniques described herein take advantage of the ability of large shared scratchpad memories that support a DMA mode to atomically shrink incoming vector data to a shared memory location, rather than simply overwriting this data. In other words, multiple processor cores or processors can simultaneously execute shrink operations that update the same shared memory location, so that the resulting shrink values are calculated as if the operations occurred consecutively, even if the shrink operations involve values associated with the same memory location. If instead each processor simply overwrites the shared memory location, a previous value written by another processor may be unintentionally lost (e.g., corresponding to a lost update problem). Based on the control loop, the system can detect an "atomic" shrink of the data and cause the memory location to hold (or store) the final result of the shrink operation by allowing the overwriting of the value in the shared memory location either way. In some cases, the various techniques described herein are extendable to other memory types (including on-chip and off-chip memory) present throughout the system.
[0017] The arithmetic unit is closely coupled to the shared memory to support various arithmetic operations for accumulating vector values into the shared memory cells / locations. The arithmetic operations may be based on any reduction operator (such as floating point atomic addition, integer addition, maximum, minimum, max pooling, and even multiplication). The arithmetic unit closely coupled to the shared memory provides the advantage of integrating software managed addressing of the shared resource and commutative mathematical operations into a single memory system.
[0018] These techniques include a read-modify-write control loop running in a shared memory control unit to keep track of outstanding operations to ensure atomicity, and to stop or reorder write traffic as necessary to prevent vector values from accumulating against old vector values. The read-modify-write control loop also provides performance and energy improvements over alternative, inefficient approaches that require reading vector data stored in a first processor core, performing arithmetic operations on the read vector values in a computation unit remote from the first core, and then storing / writing back to the first processor core. When a system has a large vector memory, these alternative, inefficient approaches may require moving data significant distances across the chip. Such approaches unnecessarily consume computation cycles in the processor core and bandwidth on the wires to and from the core. These inefficiencies also generate deeper computation schedules and unnecessarily consume register bandwidth.
[0019] These techniques include an accumulate-to-memory feature based in part on an accumulate flag generated in a processor core and used with a shared memory DMA path. This feature allows two or more processor cores to accumulate vectors directly into a shared memory location in a shared memory system. This feature can be particularly useful in multi-node systems by allowing DMA from multiple cores to simultaneously target the same memory sectors and addresses without requiring external synchronization or software locks to arbitrate operations between the cores. For example, this can be useful for configuring shared memory cells as a fully-reduced buffer across multiple chips or as a distributed system of processor cores.
[0020] Some implementations relate to methods, systems, and apparatus, including computer-readable media, for performing vector reduction using a shared scratchpad memory of a hardware circuit, the hardware circuit having processor cores in communication with the shared memory. For each processor core, a respective vector of values is generated based on computations performed in the processor core. The shared memory receives each of the vectors of values from a resource of each of the processor cores using a direct memory access (DMA) data path of the shared memory. The shared memory performs an accumulation operation on each of the vectors of values using a processor unit coupled to the shared memory. The processor unit is configured to accumulate values based on arithmetic operations encoded in the processor unit. A result vector is generated based on the accumulation operation.
[0021] The details of one or more implementations of the subject matter described in this specification are set forth in the accompanying drawings and the description below. Other potential features, aspects, and advantages of the subject matter will become apparent from the description, drawings, and claims. [Brief description of the drawings]
[0022] [Figure 1] 1 is a block diagram of a computing system having hardware circuitry including an exemplary shared memory. [Diagram 2] FIG. 2 is a block diagram illustrating an example of a processor core communicating with a shared memory in a hardware circuit. [Diagram 3] FIG. 2 is a block diagram illustrating an example of a vector processor in communication with a matrix computation unit of a hardware circuit. [Figure 4] FIG. 2 is a block diagram illustrating an example accumulation pipeline. [Diagram 5] FIG. 2 is a diagram illustrating an example of an input tensor, a weight tensor, and an output tensor. [Figure 6] 2 is a flow diagram illustrating an example process for performing vector reduction using the shared memory of FIG. 1. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0023] Detailed Description Like reference numbers and designations in the various drawings indicate like elements.
[0024] Reduction operations are often used in computations that utilize linear algebra, such as computationally intensive workloads for operations involving artificial neural networks. For example, a reduction operation may be necessary to average gradient values computed across different processing nodes of a distributed system when training a neural network. Reduction operations can be performed distributed, such as in the case of a full reduction operation, or locally for a given computation (such as a matrix multiplication tile sum operation).
[0025] Performance and power concerns can be important factors for efficiently building and executing these operations in a computing system. Typically, a reduction operation requires pulling data through the memory hierarchy of a system (e.g., a distributed system) to an arithmetic logic unit (ALU) of a processor (or processor core), performing the calculation / reduction on the pulled data, and then writing the result back through the memory system. However, performing these various steps in a system comes at a high cost in both performance and power. In addition, performing reduction operations across cores in memory visible to multiple processor cores typically requires synchronization and / or resource reservation in non-overlapping memory regions, which can add significant performance and capacity overhead, as well as programming complexity.
[0026] Based on the above context, a data processing technique is described herein for performing vector reduction by accumulating a vector of values in one or more memory address locations in a large shared scratch pad memory. The vector reduction and accumulation is performed in the shared scratch pad memory based on software managed addressing of memory locations used to write (store) the results of the calculation, rather than based on an addressing scheme typically used in hardware managed cache memory systems. The shared memory includes resources such as memory cells that are shared across a distributed system of processor cores. The described technique includes an accumulation function into the memory to perform an accumulative reduction step (e.g., for vector reduction) when processing the vector of values. For example, the accumulative reduction step can be performed across matrix multiplications performed on different sets of inputs processed through a layer of a neural network to generate the output of the layer.
[0027] The data processing techniques including the shared scratchpad memory are implemented using an improved hardware circuit architecture compared to previous designs. The hardware circuit may be a dedicated processor (such as a neural network processor, an application specific integrated circuit (ASIC), or a hardware accelerator). The hardware circuit is configured to execute a neural network including multiple neural network layers. The improved architecture and data processing techniques described herein enable the circuit representing the hardware accelerator to achieve increased speed and bandwidth to further accelerate computations.
[0028] The computation may be a particular type of mathematical operation, such as a floating-point multiplication, floating-point addition, or integer addition operation. The computation may also be included among the operations of an example neural network model that are performed to compute an inference or to train the model. In some examples, the computation is used to process inputs through layers of a CNN or RNN to generate outputs corresponding to a neural network inference, or may be used to generate a CNN or RNN output. Alternatively, it can be used to calculate gradients with respect to the parameters of an RNN and update the parameters of the neural network during training.
[0029] The mathematical operations are controlled by commutativity and may include atomic reductions (e.g., atomic floating-point reductions). An atomic reduction is treated as an accumulation or vector reduction step in which a vector is accumulated directly into a memory location of a shared memory (or a vector stored therein) without the need to synchronize activity among the cores providing the vectors of values requiring accumulation. In other words, two or more cores of the hardware circuit may accumulate values into a central address location of a shared memory cell in any order such that the final result vector provides the correct mathematical result of the accumulation. In one example, the accumulation involves a pair-wise accumulation of values of a first vector provided by a first core and values of a second vector provided by a second core.
[0030] FIG. 1 is a block diagram of a computing system 100 including an exemplary hardware circuit 101. As mentioned above, the hardware circuit 101 may represent a hardware accelerator or some other dedicated processor. In some cases, the system 100 is an exemplary computing system for accelerating tensor or neural network calculations associated with an artificial deep neural network (DNN) (such as an RNN or CNN). For example, the system 100 is configured to execute a CNN on an exemplary hardware accelerator and pass data values to the hardware accelerator to generate an output for computing an inference. In some implementations, the system 100 is a system-on-chip. For example, the system-on-chip may include the hardware circuit 101 and some (or all) of the other components and devices described herein as being included in the system 100.
[0031] The hardware circuit 101 may be a hardware accelerator configured to accelerate the execution and / or performance of a neural network model. For example, the execution of the neural network model may be accelerated compared to the execution of the model on an exemplary general purpose machine (such as a central processing unit (CPU)). Similarly, the performance and execution of the neural network model may be accelerated compared to the execution of the model on another hardware accelerator (such as a graphics processing unit (GPU)) that does not have the improved hardware features and techniques described herein.
[0032] The system 100 including the circuit 101 includes a system memory 102 and a shared memory 104. The system memory 102 may represent a high bandwidth memory ("HBM 102") or an input / output (I / O) device that communicates data to and from the processor cores 105-1, 105-2 of the hardware circuit 101. The data communication may generally include writing data values to or reading data from the vector memories 106, 108 located at a particular processor core 105-1, 105-2. For example, the HBM 102 may communicate data to and from the processor core 105-1 to pass inputs to the core and receive outputs generated by one or more computational resources of the core.
[0033] The data values may represent arrays of vector elements or vector values. For example, a first vector array may represent a batch of inputs to be processed through a neural network layer, while a second vector array may represent a set of weights for that layer. Relatedly, a third vector array may represent a vector of accumulation values corresponding to outputs generated by processor core 105-1, while a fourth vector array may represent a vector of activation values representing outputs generated by processor core 105-2.
[0034] The HBM 102 may be a dynamic random access memory (DRAM) asset of the system 100. In some implementations, the HBM 102 is an external or off-chip memory with respect to the circuit 101 and is configured to communicate data to and from an on-chip vector memory bank (described below) of the system 100. For example, the HBM 102 may be located at a physical location that is external to the integrated circuit die representing the circuit 101. Thus, the HBM 102 may be separate from or non-local to computational resources located within the integrated circuit die. Alternatively, the HBM 102, or portions of the resources, may be located within the integrated circuit die representing the circuit 101 such that the HBM 102 is local to or co-located with the computational resources of the circuit.
[0035] System 100 may include one or more processor cores 105-1, 105-2. In some implementations, system 100 includes multiple processor cores 105-n, where n is an integer equal to or greater than 1. In the examples of FIG. 1 and FIGS. 2 and 3 described below, system 100 is shown as including two processor cores, but system 100 including hardware circuitry 101 described herein may have more or fewer processor cores. Generally, processor core 105-n is a separate, self-contained processing / computation unit of system 100 (or hardware circuitry 101).
[0036] Each processor core 105 is configured to independently perform computations (e.g., neural network computations) required by one or more layers of a multi-layer neural network. The computations may be necessary to process data of a machine learning workload or to perform a particular task of the workload. The computations performed in the processor cores to process inputs through one or more neural network layers may include multiplication of a first set of data values (e.g., inputs or activations) with a second set of data values (e.g., weights). For example, the computations may include multiplying input or activation values with weight values in one or more cycles and performing an accumulation of products over multiple cycles.
[0037] The different values in the first and second sets of data values are stored in specific memory locations of a memory construct in a processor core of the hardware circuit 101. In some implementations, the individual values in the first set of data values may correspond to respective elements of an input tensor, while the individual values in the second set of data values may correspond to respective elements of a weight (or parameter) tensor. As an example, a neural network layer in a series of layers may process a set of inputs (such as inputs of image pixel data) or a set of activation values generated by another neural network layer in the series of layers.
[0038] The set of inputs or activation values can be represented as a one-dimensional (1D) or multi-dimensional tensor (e.g., 2D or 3D) having multiple elements along each dimension. Each of the memory locations that store data values can be mapped to a corresponding element of the one-dimensional or multi-dimensional tensor, and the tensor elements can be traversed or accessed using the control logic of the circuit. For example, the control logic can determine or calculate a memory address value that maps to an element to load or store the corresponding data value of the element.
[0039] The hardware circuit 101 has a dedicated memory hierarchy that includes different memory constructs. Each of these memory constructs may have different bandwidth and latency characteristics compared to the other constructs, and may also have different physical locations within the hardware circuit 101. Exemplary memory constructs include a shared memory 104, vector memories 106, 108, and vector registers 110, 112. In general, the memory constructs store data values to be processed by the neural network layers (such as inputs, vector values related to activations, or gain values) and vector registers 110, 112. and output activations generated by the neural network layer in response to processing the input or activations through the neural network layer. The generation and storage of output activations, as well as the various memory structures used to perform these operations, are described in more detail below with reference to Figures 2 and 3.
[0040] FIG. 2 is a block diagram 200 illustrating an example of how resources or sections of the shared memory 104 may be arranged in the hardware circuit 101 to facilitate data communication between various components of the hardware circuit. As described above, the shared memory 104 provides a basis for improving the hardware architecture and data processing techniques of the system 100. The shared memory 104 is a larger on-chip SRAM compared to the on-chip memory of some other neural network processor chips. In some implementations, the shared memory 104 may be described as being between the HBM 102 and the vector memories 106, 108 of the corresponding processor cores 105-1, 105-2, respectively (e.g., logically or physically). For example, the act of utilizing the shared memory 104 to move data between the HBM 102 and the vector memories 106, 108 may involve the data traversing the shared resources of the shared memory 104.
[0041] The shared memory 104 may represent a shared central space on the chip or circuit 101. For example, the shared memory 104 is configured to function as a shared global memory space, which includes memory resources corresponding to memory banks and registers shared among one or more processor cores 105-1, 105-2 of a plurality of processor cores that may be present in the system 100 and / or included in the hardware circuit 101. As described in more detail below, the shared memory 104 is configured to function as a software-controlled scratch pad (e.g., similar to an exemplary vector). In some implementations, some (or all) of the resources of the shared memory 104 are configured to function as a software-controlled scratch pad (staging resource) rather than a hardware-managed cache.
[0042] System 100 is configured to expose at least two programming interfaces to a user for utilizing the data transfer functions provided by shared memory 104. A first interface exposes programmable DMA data transfer functions and operations, while a second, different interface exposes programmable load / store data transfer functions and operations. Each of these interface functions may represent logical attributes of shared memory 104, which are described in more detail below.
[0043] As discussed above, the memory configurations of the system 100 have various bandwidth and latency characteristics. For example, the shared memory 104 may have a higher bandwidth and lower latency than the DRAM accesses of the HBM 102, but a lower bandwidth and higher latency than the accesses to the vector memories 106, 108. In some examples, the shared memory 104 has a lower data capacity than the DRAM assets of the HBM 102, but a higher data capacity than the respective vector memories of the processor cores. In general, these various bandwidth and latency characteristics represent standard memory hierarchy trade-offs.
[0044] The memory constructs of the system 100, and in particular the shared memory 104, may also vary in their physical location within the hardware circuit 101. The shared memory 104 includes resources such as memory banks and registers that may be physically and logically arranged with respect to the location of the particular computational resources of the processor cores 105-1, 105-2. In this context, the shared memory 104 may be generally characterized with reference to its physical structure and its logical structure. The physical structure of the shared memory 104 is described first, followed by its logical structure.
[0045] In terms of its physical structure, the shared memory 104 resources may be physically distributed across dedicated or neural net processor chips corresponding to the hardware circuit 101. For example, different subsets, portions, or sections of the resources forming the shared memory 104 may be physically distributed across various locations of the circuit 101 to allow different types of data transfer operations and processing techniques to be performed in the system 100. In some implementations, one section of the shared memory 104 resources may be internal to the processor core of the circuit 101, while another section of the resources may be external to the processor core of the circuit 101. In the example of FIG. 2, a section of the shared memory 104 is external to each of the processor cores 105-1, 105-2 to allow DMA operations to move large blocks of data between memory locations of the HBM 102 and memory locations of the shared memory 104.
[0046] Referring briefly back to the HBM 102, this type of system memory may be an external memory structure used by the system 100 to provide high bandwidth data to and / or from the vector memory of each processor core. In some implementations, the HBM 102 is configured for various direct memory access (DMA) operations to retrieve data from or provide data to memory address locations of the vector memory within the processor core of the circuit 101. More specifically, DMA operations, including the HBM 102 transferring data to and from the vector memories 106, 108, are enabled by an exemplary control scheme and memory resources of the shared memory 104.
[0047] 2 and 3 (described below), the shared memory 104 includes a shared memory control unit 201 ("control unit 201"). The control unit 201 is configured to generate control signals 114 for controlling memory access operations (including the HBM 102, the shared memory 104, the vector memories 106, 108, and each of the vector registers 110, 112).
[0048] The control unit 201 executes a control scheme that is distributed to the different memories of the system 100 (e.g., the HBM 102, the shared memory 104, the vector memories 106, 108, and the vector registers 110, 112). In some implementations, this control scheme is distributed to the different memories based on communication between the control unit 201 and each memory's respective control unit. For example, the control scheme can be distributed to the memories based on control signals provided by the control unit 201 that are processed locally by each of these different memories' respective control units. Data path sharing can be used to move data between the HBM 102 and the respective vector memories of the processor cores 105-1, 105-2. Once this is done, the system 100 will initiate any (and all) necessary control units for a given memory or data path to manage the data handoff that needs to take place at the appropriate touchpoint.
[0049] The control unit 201 is configured to execute software instructions and generate control signals that cause a first portion of memory resources of the shared memory 104 to function as a DMA memory unit. The first portion of resources may be represented by a shared core data path 204 referenced to the processor core 105-1 and a shared core data path 224 referenced to the processor core 105-2. This representative DMA memory unit is operable to move data between the HBM 102 and each of the first and second processor cores 105-1 and 105-2 based on the control signals generated by the control unit 201.
[0050] For example, control signals may be generated to perform DMA operations to move blocks of data (e.g., vectors) between memory locations in shared memory 104 and vector memory 106 a) using data path 202, shared core data path 204, or data path 206, and b) between memory locations in shared memory 104 and vector memory 108 using data path 222, shared core data path 224, or data path 226. In some implementations, shared memory 104 may alternatively be referred to as shared CMEM 104.
[0051] In this document, CMEM generally corresponds to a block of physically contiguous memory (CMEM) that provides a configuration useful as a data buffer and on-chip SRAM storage. As described in more detail below, in system 100, blocks of CMEM resources are physically distributed in hardware circuitry 101 and arranged to be shared among components of a processor core, which may be configured as hardware accelerators or other types of dedicated processors. Each of shared core data paths 204 and 224 is an exemplary node that may exhibit static contention that may occur on the shared data path due to the movement of vector data across these points in the system.
[0052] As shown in the example of FIG. 2, the hardware circuit 101 and system 100 shown in FIG. 1 are configured to include multiple load-store data paths 202, 206, multiple CMEM load data paths 208, 214, 228, 234, and multiple CMEM store data paths 215, 235. The hardware circuit 101 and system 100 also include multiple shared staging blocks 210, 230 (described below). In the example of FIG. 2, each of the data paths 202, 222 can be configured as a data path for routing data (e.g., vector or scalar values) in response to performing a DMA operation, as a data path for routing data in response to performing a CMEM load / store operation, or both. The DMA operations and data paths 202, 206, 222, and 226 supported by the shared memory 104 can be used to move data between different memory structures with reference to specific memory offsets and stride parameters.
[0053] For example, system 100 may be configured to perform a DMA operation with shared memory 104, the DMA operation including moving or copying 1 megabyte of data from one set of memory locations to another set of memory locations at an offset of 0x04. Shared memory 104 and system 100 are operable to support various stride functions when performing the DMA operation. For example, a DMA operation to move 1 megabyte of data may include a stride operation that inserts an address interval every 200 kilobytes relative to an address base or address value of a base memory location.
[0054] In some implementations, a stride operation is used to insert address intervals based on a desired read sequence that is later executed to read a megabyte of data after it has been moved to a destination location. For example, a one megabyte block of data may be stored based on a stride operation that corresponds to how the data is read or retrieved and processed in different layers of a neural network, or across different sets of filters or weights of a particular neural network layer.
[0055] The control unit 201 of the shared memory 104 is also configured to cause various load and store operations to be performed. For example, the control unit 201 may: a) (in the case of a load operation on the core 105-1) transfer a memory location in the shared memory 104 to a memory location in the shared staging block 210 using the data path 202, the shared core data path 204, or the data path 208; and b) (in the case of a load operation in core 105-2) generating control signals to perform load and store operations that move various amounts of data (e.g., vectors or vector values) between memory locations in shared memory 104 and memory locations in shared staging block 230 using data path 222, shared core data path 224, or data path 228.
[0056] Similarly, control signals may be generated to perform load and store operations that move various amounts of data (e.g., vectors or vector values) a) between memory locations in shared memory 104 and vector register 110 using data path 202, shared core data path 204, or data path 215 (in the case of a store operation in core 105-1), and b) between memory locations in shared memory 104 and vector register 112 using data path 222, shared core data path 224, or data path 235 (in the case of a store operation in core 105-2).
[0057] Turning now to the logical structure of the shared memory 104, as described above, the system 100 is configured to expose at least two programming interfaces to a user to take advantage of the data transfer capabilities afforded by the shared memory 104. At least one interface exposes programmable DMA capabilities and another interface exposes programmable CMEM load / store capabilities, each of which may represent logical attributes of the shared memory 104. For load / store purposes, the shared memory 104 is logically exposed as a parallel memory to the vector memories 106, 108. In this manner, each load-store data path is operable to provide an additional (or parallel) data path for moving blocks of data or particular data through the memory system (such as through the vector registers of the respective processor cores 105-1, 105-2, or through multiple cores of the circuit 101). For example, load-store operations may be performed against the memory resources of the shared memory 104 simultaneously with DMA operations.
[0058] More specifically, a DMA operation may be performed to move a vector of values between memory locations in shared memory 104 and vector memory 106 using DMA data path 206, and load and store operations may be performed concurrently with the DMA operation to move different vectors of values between memory locations in shared memory 104 and shared staging block 210. Similar concurrent operations may be performed in processor core 105-2 (or other cores) using resources of processor core 105-2 that correspond to the resources of processor core 105-1.
[0059] Load / store operations performed using the CMEM resources of shared memory 104 may represent a high performance feature of shared memory 104 or a high performance method of using shared memory 104, as compared to DMA operations. In some implementations, control unit 201 is configured to execute software instructions and generate control signals that cause a second portion of the memory resources of shared memory 104 to function as software controlled staging resources used to perform the load / store operations.
[0060] A second portion of the resources may be represented by a shared staging block 210 referenced to the processor core 105-1 and a shared staging block 230 referenced to the processor core 105-2. Each of the shared staging blocks 210, 230 may thus represent a software-controlled staging resource (or scratch pad) formed from a subset of the memory resources of the shared memory 104. In some examples, the software-controlled staging resources of the system 100 are configured to manage the flow of vector data values from the HBM 102 to the vector registers 110 or 112 of the first processor core 105-1 or second processor core 105-2, respectively.
[0061] The shared memory 104 and its resources have the property of being uniquely configurable, for example, not only as a DMA memory for moving data between memory constructs (such as the HBM 102 or vector memories 106, 108), but also as a load / store memory for moving data directly into the respective vector registers 110, 112 on each processor core 105-1, 105-2. These configurable aspects of the shared memory 104 allow its resources and addressing to be scheduled at a fine granularity by software running on the cores. For example, the shared memory 104 can be a software-managed (not hardware-managed) SRAM resource, in which the processor core's compiler specifically manages the addressing of that memory (including types of data that may or may not reside at memory address locations of the shared memory 104).
[0062] In some implementations, the software-controlled staging resources of the shared memory 104 are configured as a first-in-first-out (FIFO) memory structure (e.g., shared staging block 210 or 230) along the load portion of the load-store data path of the processor core that includes a CMEM store data path 215 or 235 for routing data for storage in the shared CMEM 203 or HBM 102. The FIFO memory structure is configured to temporarily store a set of data values for a threshold number of processor cycles and then route the set of values to the vector registers 110, 112 of the first processor core 105-1 or second processor core 105-2, respectively. The FIFO memory structure is used to mitigate register pressure and scheduling complications that may be caused by CMEM load operations having a particular load latency.
[0063] In some implementations, the threshold number of clock cycles is determined based on an exemplary high latency (e.g., 50 cycles) CMEM load operation that may cause register pressure and scheduling complexities associated with reserving a given register for the entire 50 cycles. To alleviate or mitigate concerns about register pressure, a CMEM result FIFO ("CRF") is physically instantiated in the hardware circuit 100 using resources of the shared memory 104. In the example of FIG. 2, a first CRF is represented by staging block 210 of the processor core 105-1, while a second CRF is represented by staging block 230. Each of the CRFs may divide an exemplary CMEM load operation into at least two phases: i) a CMEM → CRF phase (where CMEM address information is provided), and ii) a CRF → register phase (where a vector register target is provided).
[0064] For example, each of the shared staging blocks 210, 230 is configured to receive a data value (e.g., a scalar or vector value) and temporarily store the data value for a threshold number of processor cycles. In the processor core 105-1, the data value is routed to the shared staging block 210 along a load data path 208 (and shared core data path 204) that connects the staging block 210 to other memory locations in the shared memory 104. In the processor core 105-2, the data value is routed to the shared staging block 230 along a load data path 228 (and shared core data path 224) that connects the staging block 230 to other memory locations in the shared memory 104.
[0065] The shared staging block 210 is configured to provide a data value to the vector register 110 of the processor core 105-1 in response to temporarily storing the data value for a threshold number of processor cycles. is configured to provide a data value to the vector register 112 of the processor core 105-2 in response to having temporarily stored the data value for a threshold number of processor cycles.
[0066] The system 100 is configured to issue multiple CMEM load instructions in the same cycle. For example, the system 100 can issue a CMEM load instruction executed using the data path 208 (or 214) and the shared staging block 210, and issue a load to the vector memory 106 executed using the data path 212 in the same cycle. In some examples, from a software control perspective, a Cmem load operation traversing the data path 214 between the resource 210 and the vector register 110, and a Vmem load operation traversing the data path 212 between the vector memory 106 and the vector register 110 can each be issued and executed in the same cycle. In some implementations, the vector registers 110, 112 are adapted to include an additional port that allows the vector registers 110, 112 to receive simultaneous load operations, as compared to previous designs.
[0067] For example, vector register 112 is configured to include additional ports that enable the register to receive respective vector payloads from vector memory 108 and shared staging block 230 during concurrent load operations executing in processor core 105-2. In some examples, a single piece of payload data loaded into each of vector registers 110, 112 includes 128 separate loads based on up to 128 data items that may be moved into vector register 110 or vector register 112 during a single load operation.
[0068] The CMEM load / store functionality of the shared memory 104 can provide higher peak performance compared to previous designs because it does not require routing data through vector memory macros. For example, loads and stores (along data paths 215, 235) can be performed in parallel with vector memory loads and stores, such as by virtue of available additional register ports in the vector registers 110, 112.
[0069] In some implementations, the system 100 includes an exemplary load-store interface that provides a parallel interface to each of the shared staging blocks 210, 230 that bypasses some (or all) of the bandwidth limitations that may exist when traversing a data path through the vector memories 106, 108. This exemplary load-store interface can effectively provide higher memory bandwidth that allows additional performance to be extracted from the exemplary workload. For example, the system 100 can be configured to perform various load / store operations using resources (e.g., software-controlled staging resources) of the shared memory 104, where the load / store operations can be performed to bypass moving data through the vector memories in the processor cores.
[0070] For example, components of hardware circuitry 101 may communicate with shared memory 104 to read data from a single address location in a memory bank or register file of shared memory 104. In some examples, data stored at a single address in memory may be read and the single datum may be moved to a register file or staging block located internal to a processor core. For example, a single datum may be read from an address location in shared CMEM 104, moved through shared core data path 224, and moved to an address location of shared staging block 230 in processor core 105-2 for further processing. This operation reduces the number of data items in a single memory location, by bypassing moving the data through the memory system via vector memory 108. This can be done to save processor clock cycles in -2 and bandwidth in the data path connecting to the vector memory 108.
[0071] 3 is a block diagram 300 illustrating an example of a vector processor in communication with a matrix computation unit of a hardware circuit 101. More specifically, in some implementations, a tensor processor core 302-1 of the hardware circuit 101 includes a vector processing unit 304 ("vector processor 304") and a matrix computation unit 308 coupled to the vector processor 304. Similarly, another tensor processor core 302-2 of the hardware circuit 101 includes a vector processor 306 and a matrix computation unit 310 coupled to the vector processor 306. Thus, the matrix computation units 308, 310 are resources of each of the processor cores 302-1, 302-2.
[0072] In general, the hardware circuit 101 is configured to perform calculations to generate outputs of the neural network layers. Each of the matrix computation units 308 and 310 included in the circuit 101 is configured to perform a subset of calculations to generate accumulation values used to generate outputs of the neural network layers. In some implementations, the software-controlled staging resources described above (e.g., staging blocks 210, 230) are configured to manage the flow of data (e.g., vector operands) from the HBM 102 shown in FIG. 1 to each of the matrix computation units 308, 310. In some cases, the operands are inputs and weights provided by the HBM 102. The operands may be structured as vector arrays based on data operations performed using an arithmetic logic unit (ALU) of the vector processor 304 or 306.
[0073] In the example of Figure 3, the control unit 201 generates control signals to manage the retrieval (or reading) of batches of inputs and sets of weights from memory locations in the shared memory 104, the vector memories 106, 108, and the vector registers 110, 112. The retrieved inputs and weights may be processed through neural network layers to generate accumulated values based on calculations performed in the matrix computation units 308, 310. The accumulated values may be processed in the vector processors 304, 306 to generate activation values corresponding to the outputs of the neural network layers.
[0074] Control signals generated by the control unit 201 are used to store (or write) multiple sets of outputs or output activations generated by the vector processors 304, 306 in other memory locations of the HBM 102 or hardware circuit 101 for processing in one or more other neural network layers. More specifically, the system 100 is configured to execute data processing techniques for performing vector reduction, which includes accumulating vectors of values in one or more memory address locations in a large shared scratchpad memory (such as the shared memory 104). As described above, vector reduction and accumulation can be performed in the shared scratchpad memory 104 based on software-managed addressing of locations in memory cells of the shared memory 104. Address locations in memory cells of the shared memory 104 can be used to write (store) results of calculations performed in different components of the system 100.
[0075] System 100 includes a calculator / accumulator unit 320 ("calculator 320") that is coupled (or may be coupled) to shared memory 104. Operator 320 is configured to accumulate values based on one or more arithmetic operations. The arithmetic operations may be programmed or encoded in operator 320 in software, firmware, hardware, or a combination of each. Operator 320 may represent a dense portion of computational logic that is coupled near memory cells of shared memory 104 and performs accumulation operations on vector values being routed to shared memory cells of shared memory 104.
[0076] In some implementations, the operator 320 is a computation unit that includes hardware circuits for performing different types of adders (e.g., normalizing adders) and multipliers, each configured to perform different types of mathematical operations on values having different types of numeric formats. For example, the operator 320 is configured to perform mathematical operations (such as floating-point multiplication, floating-point addition, integer addition operations, and min-max operations). In some other implementations, the operator 320 is included in the system 100 as a hardware feature of the shared memory 104. One or more arithmetic operations or functions of the operator 320 may also be implemented in software and hardware.
[0077] The operator 320 may include logic 325 for selecting a particular arithmetic operation or for selecting circuitry in the operator 320 configured to perform a particular arithmetic operation. In some implementations, the operator 320 is instantiated in the shared memory 104 and / or the hardware circuitry 101 based on one or more numeric formats (e.g., two's complement integer and floating point) of the values in the vector of values. For example, the numeric format corresponds to a data format used to represent the numbers or values in the vector. In some implementations, the operator 320 includes circuitry for a normalization unit, circuitry for a pooling unit, or both.
[0078] As mentioned above, the described techniques include an accumulate to memory function for performing an accumulated reduction step (e.g., for vector reduction) when processing a vector of values. In the example of Fig. 3, each of the processor cores 302-1, 302-2 may generate a respective accumulation flag 330, 335 to cause the control unit 201 of the shared memory 104 to perform an accumulate to memory function on an exemplary vector of values. The vector of values may be moved to the shared memory 104, for example, using a DMA operation that moves the vector to the shared memory 104 using the data path 206 or the data path 226.
[0079] 4 is a block diagram illustrating an example accumulation pipeline 400 ("pipeline 400"). Pipeline 400 illustrates example data processing steps for an example operation of accumulating a vector of values in a shared memory cell 445 of shared memory 104.
[0080] Vector operands, such as individual input and weight values, may be represented as tensor values that are multiplied using multiplication cells of an exemplary matrix unit of the processor core and then stored in the vector memory of the core (402). In some implementations, the inputs of the vector operands correspond to partitions of an input matrix or input tensor. For example, an input tensor may be split into two sections, and input values from different respective dimensions of each section may be sent to a particular processor core to be multiplied with weight values to generate output values. The input tensors, along with the weight tensors and output tensors, are described in more detail below with reference to FIG. 5.
[0081] The final result vector 450 may be based on a final set of output values representing the outputs calculated for the layer of the neural network using each of the input matrices / tensors of input. Thus, even if the data / input values of the input tensors may be split to be processed by different processor cores, generating the correct and accurate final result vector 450 actually depends on the correct and accurate accumulation of at least two different sets of output values generated by each core. For example, a different set of output values generated by each core may need to be summed or accumulated to generate the correct final result vector 450.
[0082] In the example of FIG. 4, each processor core is shown as core_0 (e.g., processor core 302-1) and core_1 (e.g., processor core 302-2). Depending on the matrix multiplication performed by each matrix unit (e.g., matrix 308 or 310) of the processor core, multiple output values may be generated. In some implementations, the output values are stored in a vector memory of the processor core performing the matrix multiplication and then sent to the shared memory 104 for an accumulation operation. The final result vector 450 may be obtained based on both processor cores aggregating their respective halves of the calculations assigned to them. In some implementations, the aggregation to obtain the final result vector corresponds to a "pre-accumulation operation."
[0083] Previous approaches to accumulating vector values required one core to move its results to another core. These approaches required additional processor cycles, memory resources, computational bandwidth, and specific software control to move different sets of result values between different cores in the system. The accumulation reduction technique herein allows these aggregations to occur in a shared memory system based on accumulation functions natively executable in the shared memory 104.
[0084] Each of the processor cores may generate a respective accumulation flag 330, 335 to cause the control unit 201 of the shared memory 104 to perform an accumulation to memory function on the exemplary vector of values (404). The vector of values generated by each processor core 105 may be moved to the shared memory 104 using a DMA operation as described above. The technique for accumulating the vector of values into shared memory cells or address locations of the shared scratchpad memory 104 may be performed via the programmable DMA data transfer functionality of the system 100. For example, any DMA operation operable to move data into memory cells of the shared memory 104 may use the accumulation techniques described herein. In this manner, each of the cores 0 and 1 in the examples of Figures 2 and 3 may both accumulate vector values into the same address locations of particular shared memory cells of the shared memory 104. In one example, the accumulation involves a pair-wise accumulation of values of a first vector provided by core 0 and corresponding values of a second vector provided by core 1.
[0085] In some implementations, the system 100 is configured to provide large vector "store accumulate" in a load / store usage mode of the shared memory 104, rather than using the DMA mode of the shared memory. For example, a shared load / store memory layer between multiple processor cores can be used to perform the "store accumulate" function, which isolates the need for some (or all) synchronization between the processor cores. In some implementations, the shared load / store memory layer between multiple processor cores used to perform the store accumulate function includes at least the data paths 212, 232 described above with reference to FIG. 2.
[0086] The shared memory 104 and control unit 201 perform an accumulation operation on each of the vectors of values (406) using the operator 320. For example, the control unit 201 performs an accumulation reduction step across matrix multiplications performed on different sets of inputs processed through the layer of the neural network to generate the output of the layer. In some implementations, the vectors of values can be each of the vectors of accumulated values generated as a result of the matrix multiplications described above.
[0087] The control unit 201 is configured to mask one or more vector elements to enable or disable accumulation on particular vector elements, perform controls to manage accumulation of different vectors, and keep track of outstanding accumulation operations (408).
[0088] With respect to mask elements, system 100 may include machines (such as computational servers or related hardware circuitry) each including a 16B (16-bit) wide vector unit (e.g., vector processor). The vector units operate on 16-bit wide data elements. The system 100 may be configured to operate on one or more 9-element wide vectors, but the vector of values generated by the hardware circuitry (or server) resources may be only a 9B wide vector. In some implementations, the system 100 operates on one or more 9-element wide vectors, each of which includes nine data values, each of which is 16 bits. In this example, the control unit 201 may identify a data structure for the vector of values to be accumulated in a shared memory location of the shared memory 104. Based on this data structure, the control unit 201 may determine that the values to be accumulated in the shared location are 9B wide vectors for the 16B wide vector configuration of the vector unit.
[0089] The control unit 201 can execute a mask function 430 that causes the operator 320 to apply arithmetic operations to, for example, only the first 9 fields in a vector when performing accumulation or reduction. For example, a request from the processor core 302-1 to the shared memory 104 to accumulate a vector in the shared memory cell 445 may be presented as a 16B wide vector based on the configuration of the vector processing unit 304 of the processor core 302-1. The control unit 201 is configured to determine whether the value being accumulated is represented by the second half of the 16B wide vector or by a 9B wide vector represented by the first 9 fields of the 16B wide vector. Thus, the system 100 is operable to identify and select or otherwise control which particular elements in the vector are accumulated in the shared memory cell 445.
[0090] With respect to accumulation control, control unit 201 is configured to execute read-modify-write control 435 ("control 435") to control and manage the accumulation of distinct vectors of values in the shared memory system. Control 435 provides performance and energy improvements over inefficient alternative approaches that require reading data at a first core, performing computations on the read values at a computation unit remote from the first core, and then storing / writing back to the first core.
[0091] With regard to tracking of pending operations, the control unit 201 is configured to execute an operation tracker 440 to track pending requests and current (or pending) operations to accumulate different vectors of values in the shared memory system. For example, the control unit 201 uses the operation tracker 440 to track each write operation that requests to write a vector of values to a memory location (such as a shared memory cell 445) of the shared memory. In some implementations, the control unit 201 tracks the operations based on an accumulation flag 330, 335 that accompanies a write request from a processor core. The accumulation flag 330, 335 indicates that a vector of values should be written as an initial value or accumulated with an existing value at a particular memory location of the shared memory 104.
[0092] The control unit 201 sends control signals to the calculator 320 to cause the calculator 320 to perform an accumulation operation between a current value stored in a particular memory address location and a vector of values being written to that shared memory location. In some implementations, a request from a processor core to write a vector of values to a shared memory cell 445 requires at least two clock cycles to process. Because this write request may require at least two clock cycles to process, a read / write hazard may occur if the control unit 201 is attempting to read a value from a shared memory location while another vector is being written to the same shared memory location. In this case, the value being read is not the most current value because the write operation was not fully processed before performing the read of the value.
[0093] The control unit 201 uses the activity tracker 440 to determine which requests have been sent to the shared memory 104 in the last few clock cycles and to determine whether the value stored in a particular memory location is old or new. It may be determined whether a value is stale or new based on a timestamp of the request or based on the time (e.g., more than one clock cycle) required to process the last write request. For example, the timestamp may indicate that more than two clock cycles have passed since the last request was initiated or processed in shared memory 104. If it is determined that the value is new, control unit 201 reads the value. If it is determined that the value is stale, control unit 201 stops reading the value until the number of clock cycles required to indicate that the value is new again for reading or accumulation has passed.
[0094] System 100 is configured to receive a value (e.g., a vector) and accumulate it onto an existing value in a shared memory location (410) without losing any previous accumulations stored in shared memory location 445. For example, system 100 is configured to perform accumulation operations without requiring external software locks to mitigate race conditions that may overwrite vector accumulations previously stored in a memory location (e.g., shared memory cell 445). System 100 performs accumulation operations without requiring a local pre-accumulation operation to be performed on each processor core and without requiring pre-synchronization between processor cores. For example, a local pre-accumulation operation may be performed to accumulate each set of partial sums that are calculated locally on a given processor core.
[0095] The shared memory 104 is configured to natively support this functionality, which represents the atomic aspect of the vector reduction feature of the present technology. For example, multiple cores (e.g., 10 cores) of the system 100 may all be generating different vectors of values, and each core may submit a request to accumulate their respective vectors in a shared memory location. In some implementations, the request includes an accumulation flag 330, 335 and a corresponding core ID (e.g., core 0, core 1, core N, etc.) and the value to be accumulated in the memory location. In some implementations, a large matrix multiplication job may be split between at least two processor cores of the system 100, and this accumulation / vector reduction technique is used to simplify the accumulation of partial sums or dot products generated from the matrix multiplication.
[0096] In some implementations, these techniques for accumulating vectors of values in a shared memory cell are used during training of a neural network model. For example, these techniques can be used to perform a full reduction operation for gradient accumulation that reduces gradients calculated as part of the training step across a distributed system of processor cores. In particular, based on the disclosed accumulation reduction techniques, this gradient accumulation for training a neural network model can be performed natively in system 100 as a function of the memory system or shared memory 104.
[0097] FIG. 5 illustrates an example of a tensor or multi-dimensional matrix 500 including an input tensor 504, a transformation of a weight tensor 506, and an output tensor 508. In FIG. 5, each of the tensors 500 includes elements corresponding to data values for a computation performed at a given layer of a neural network. The computation may include multiplying the input / activation tensor 504 with the parameter / weight tensor 506 on one or more clock cycles to generate an output or output value. Each output value in the set of outputs corresponds to a respective element of the output tensor 508. Multiplying the activation tensor 504 with the weight tensor 506 includes multiplying activations from elements of the tensor 504 with weights from elements of the tensor 506 to generate partial sum(s).
[0098] In some implementations, the processor cores of system 100 operate on vectors that correspond to i) discrete elements in a multidimensional tensor, ii) vectors of values that include multiple discrete elements along the same or different dimensions of a multidimensional tensor, or iii) combinations of each of the discrete elements or multiple discrete elements in a multidimensional tensor. can be expressed using X,Y coordinates (2D) or using X,Y,Z coordinates (3D), depending on the dimensionality of the tensor.
[0099] The system 100 can calculate multiple partial sums corresponding to products generated by multiplying the batch inputs with corresponding weight values. As described above, the system 100 can perform the accumulation of products (e.g., partial sums) over multiple clock cycles. For example, the accumulation of products can be performed in the shared memory 104 according to techniques described herein. In some implementations, the input-weight multiplication can be written as a sum of products where each weight element is multiplied with a discrete input of the input volume (e.g., a row or slice of the input tensor 504). The row or slice can represent a given dimension (e.g., a first dimension 510 of the input tensor 504, or a second, different dimension 515 of the input tensor 504).
[0100] In some implementations, an exemplary set of calculations can be used to calculate the output of a convolutional neural network layer. The calculations for a CNN layer may include performing a 2D spatial convolution between a 3D input tensor 504 and at least one 3D filter (weight tensor 506). For example, convolving one 3D filter 506 with a 3D input tensor 504 may generate a 2D spatial plane 520 or 525. The calculations may include calculating a sum of dot products for a particular dimension of the input volume.
[0101] For example, spatial plane 520 may include sum-of-products output values calculated from inputs along dimension 510, while spatial plane 525 may include sum-of-products output values calculated from inputs along dimension 515. The calculations to generate the sum-of-products output values in each of spatial planes 520 and 525 may be performed in shared memory 104 (e.g., in shared memory cells 445) using an accumulated reduction step as described herein.
[0102] 6 is a flow diagram illustrating an example process 600 for performing vector reduction using a shared scratchpad memory in a hardware circuit having processor cores in communication with the shared memory. In some implementations, the process 600 is part of a technique used to accelerate neural network computations using the shared memory of FIG.
[0103] Process 600 can be realized or performed using the above-mentioned system 100. The description of process 600 can refer to the above-mentioned computational resources of system 100. The steps or actions of process 600 can be enabled by programmed firmware or software instructions executable by one or more processors of the devices and resources described in this document. In some implementations, the steps of process 600 correspond to a method of performing computations to generate outputs of neural network layers using hardware circuitry configured to execute a neural network.
[0104] Referring now to process 600, vectors of values are generated (602) in system 100. For example, for each processor core included in one or more hardware circuits of system 100, a respective vector of values is generated based on computations performed by the processor core.
[0105] A shared memory of the system 100 receives each of the vectors of values (604). For example, the shared memory 104 receives the vectors of values from the resources of each of the processor cores using a direct memory access (DMA) data path of the shared memory 104. In some implementations, a vector or vectors of values may be shared by a single processor core (or The vector of values may be generated by a first processor core (or each of a plurality of processor cores) and then provided to a shared memory of system 100, which performs a calculation using the vector of values. For example, the shared memory may obtain a vector from a first processor core and perform a reduction operation using the obtained vector and one or more other vectors. The one or more other vectors may be received or obtained from a processor core other than the first processor core.
[0106] In some other implementations, the system 100 is configured to perform direct store operations along with accumulation operations. For example, the system 100 can generate accumulation flags 330, 335 that are used to directly store one or more vectors of values in shared memory locations of the shared memory 104. The vectors may be from a single processor core or may be from multiple different processor cores. For example, the processor cores 105-1 or 302-2 can generate control signals representing the accumulation flags and pass the control signals to the control unit 201 of the shared memory 104. The system 100 can be configured to store the vectors of values in the vector memories 106, 108 and then perform DMA operations to move the vectors of values from the vector memories to the shared memory 104.
[0107] The system 100 performs an accumulation operation on each of the vectors of values (606). More specifically, the shared memory 104 performs the accumulation operation as each of the vectors of values is written to a shared memory location. For example, the system 100 causes the shared memory 104 to perform an accumulation operation on each of the vectors of values using an operator 320 coupled to the shared memory 104. The system 100 is operable to accumulate values corresponding to different elements (or values) of the same vector and elements of different vectors. The operator 320 is configured to accumulate values based on arithmetic operations encoded in the operator units. In some implementations, the arithmetic operations are mathematical operations controlled by commutativity. The arithmetic operations may include atomic reductions (e.g., atomic floating-point reductions).
[0108] For example, atomic reduction is treated as an accumulation or vector reduction step in which a vector of values is accumulated directly into memory locations (e.g., shared cells) of a shared memory. In one example, the system 100 accumulates multiple vectors generated from multiple different cores as part of an accumulation operation. In another example, the system 100 accumulates values (e.g., vectors) already stored in the shared memory 104 (e.g., in shared cells of the memory) with values generated by the cores. In another example, the system 100 accumulates multiple vectors generated from multiple different cores with one or more values already stored in the shared memory 104. The above examples involving vectors generated by the cores and values already stored in the shared memory are also applicable to reduction operations, as well as other types of arithmetic operations that may be performed using the operator 320.
[0109] In some other implementations, each of the processor cores 302-1, 302-2 provides a vector that needs to be accumulated, and the values are accumulated directly in memory locations without synchronizing activity between the processor cores 302-1, 302-2. Similarly, values can be accumulated directly in memory locations without either of the processor cores 302-1, 302-2 performing a step of pre-accumulating products (e.g., partial sums) that may result from calculations performed on either of these processor cores. In other words, two or more cores of the system 100 can accumulate vectors of values containing partial sums in address locations (e.g., central address locations) of shared memory cells of the memory 104 in any order. The system 100 is configurable such that in some implementations, no pre-accumulation operations need to be performed locally at a core, and in some other implementations, some of the partial sums or certain types of partial sums can be accumulated at a given core.
[0110] The system 100 generates a result vector (e.g., a final result vector) based on the accumulation operation. Generate (608). For example, the system 100 generates a final result vector based on performing an accumulation operation with one or more vectors of values and the vector stored in the shared memory. In some implementations, the system 100 generates a result vector whose individual elements result from pairwise application of the accumulation operation to each element of the first vector and each corresponding element of the vector stored in the shared memory. The result vector provides the correct mathematical result of the accumulation regardless of the order in which each of the vectors that are accumulated to generate the final result arrive at the shared memory cell.
[0111] In some implementations, to achieve this desired result, one or more DMA operations may be detected, prioritized, and ordered based on control 435 (e.g., a read-modify-write control loop) performed using control unit 201 and at least control logic 325 of operator 320. For example, control unit 201 may detect a set of incoming vectors / vector values with corresponding cores providing vectors, and use operator 320 to serialize individual accumulation operations based on a given priority scheme specified by control 435. The priority scheme may be used to stop or reorder write traffic as necessary to prevent vector values from accumulating against older vector values.
[0112] The result vector may be a final result vector representing a set of outputs of the neural network layer, e.g., the neural network layer may be a convolutional neural network layer and the outputs may be a set of activation values generated in response to convolving each kernel (e.g., parameters / weights of tensor 506) over a particular input volume of input tensor 504.
[0113] The system 100 can generate a vector of accumulated values as a result of performing an accumulation operation on each of the vectors of values. In some implementations, each of the vectors of values is a partial sum corresponding to a dot product. For example, referring back to the convolutional neural network layer, the inputs of the input volume described above are processed by performing a dot product operation with i) each input value along a given dimension (e.g., dimension 510) of the input tensor 504 and ii) a set of parameters of the convolutional layer. In response to convolving at least one kernel of the weight tensor 506 with a portion of the inputs along the given dimension of the input volume, a corresponding set of dot products or partial sums can be accumulated in memory locations of the shared memory 104 to generate a set of accumulated values.
[0114] The system 100 can apply an activation function to each value in the vector of accumulated values. For example, the layer of the neural network may or may not have an activation function (such as ReLU, sigmoid, or tanh) that represents a nonlinear function that provides nonlinearity in the neural network. The system 100 generates a result vector in response to applying the activation function to each value in the vector of accumulated values. In some implementations, the hardware circuit 101 is a hardware accelerator configured to execute a neural network that includes multiple neural network layers, and the system 100 generates an output of the layer of the neural network based on the result vector. For example, processing the layer inputs at the neural network layer may include the layer applying an activation function to generate a set of activation values that are the output of the neural network layer. The activations generated by the first neural network layer can be processed through a second or subsequent layer of the neural network.
[0115] The embodiments and functional operations of the subject matter described herein can be implemented in digital electronic circuitry, in computer software or firmware tangibly embodied in computer hardware, including the structures disclosed herein and structural equivalents thereof. or in a combination of one or more of these. Embodiments of the subject matter described herein may be implemented as one or more computer programs, i.e. as one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier for execution by or controlling the operation of a data processing apparatus.
[0116] Alternatively or additionally, the program instructions may be encoded on an artificially generated propagated signal (e.g., a machine-generated electrical, optical, or electromagnetic signal) that is generated to encode information that is transmitted to an appropriate receiving device for execution by a data processing device. The computer storage medium may be a machine-readable storage medium, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of these.
[0117] The term "computing system" encompasses all kinds of apparatus, devices, and machines for processing data, including, by way of example, a programmable processor, a computer, or multiple processors or computers. An apparatus may include special purpose logic circuitry (e.g., a field programmable gate array (FPGA) or an application specific integrated circuit (ASIC)). In addition to hardware, an apparatus may also include code that creates an execution environment for a subject computer program (e.g., code that constitutes a processor firmware, a protocol stack, a database management system, an operating system, or a combination of one or more of these).
[0118] Computer programs (which may also be referred to or described as programs, software, software applications, modules, software modules, scripts, or code) may be written in any type of programming language (including compiled or interpreted languages, or declarative or procedural languages) and may be deployed in any form (such as as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment).
[0119] A computer program may, but need not, correspond to a file in a file system. A program may be stored as part of a file that holds other programs or data (e.g., one or more scripts stored in a markup language document), in a single file dedicated to the program in question, or in multiple associated files (e.g., a file that stores one or more modules, subprograms, or portions of code). A computer program may be deployed to be executed on one computer or deployed to be executed on multiple computers that are located at one site or distributed across multiple sites and interconnected by a communications network.
[0120] The processes and logic flows described herein may be performed by one or more programmable computers executing one or more computer programs to perform functions by operating on input data to generate output. These processes and logic flows may also be performed by, or an apparatus may be implemented as, special purpose logic circuitry (e.g., an FPGA (field programmable gate array), an ASIC (application specific integrated circuit), or a GPGPU (general purpose graphics processing unit)).
[0121] Computers suitable for the execution of a computer program include, by way of example, general purpose or special purpose microprocessors or both, or other types of central processing units; The computer may be based on these. Typically, a central processing unit receives instructions and data from a read-only memory or a random access memory or both. Some elements of a computer are a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, a computer also includes one or more mass storage devices (e.g., magnetic disks, magneto-optical disks, or optical disks) for storing data, or is operatively coupled to receive, transmit, or transmit data to or from one or more of these mass storage devices. However, a computer need not have such devices. Furthermore, a computer may be incorporated into another device (e.g., a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device (e.g., a universal serial bus (USB) flash drive), to name a few).
[0122] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media and memory devices, including, by way of example, semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks. The processor and the memory can be supplemented by, or incorporated in, special purpose logic circuitry.
[0123] To provide for user interaction, embodiments of the subject matter described herein may be implemented on a computer having a display device (e.g., an LCD (liquid crystal display) monitor) for displaying information to the user, and a keyboard and pointing device (e.g., a mouse or trackball) by which the user can provide input to the computer. Other types of devices may also be used to provide user interaction. For example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback), and input from the user may be received in any form, including acoustic, speech, or tactile input. Additionally, the computer may provide user interaction by sending and receiving documents to and from a device used by the user (e.g., by sending a web page to a web browser on the user's client device in response to receiving a request from the web browser).
[0124] An embodiment of the subject matter described herein may be implemented in a computing system that includes a back-end component, for example as a data server, or a middleware component (e.g., an application server), or a front-end component (e.g., a client computer having a graphical user interface or a web browser through which a user can interact with an implementation of the subject matter described herein), or any combination of one or more such back-end, middleware, or front-end components. These components of the system may be interconnected by any form or medium of digital data communication (e.g., a communications network). Examples of communications networks include a local area network ("LAN") and a wide area network ("WAN") (e.g., the Internet).
[0125] A computing system may include clients and servers. Clients and servers are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship.
[0126] Although the present specification contains many specific details of implementation, these should not be construed as limitations on the scope of any invention or what may be claimed, but rather as descriptions of features that may be specific to a particular embodiment of a particular invention. Certain features described in the present specification in the context of separate embodiments may also be realized in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be realized in multiple embodiments separately or in any suitable subcombination. Furthermore, although features may be described as functioning in a particular combination and initially claimed as such, one or more features included in a claimed combination may, in some cases, be omitted from the combination, and the claimed combination may relate to a subcombination or a variation of the subcombination.
[0127] Similarly, although operations are shown in a particular order in the figures, this should not be understood as requiring such operations to be performed in the particular order or sequential order shown, or that all of the operations shown must be performed to achieve a desired result. Multitasking and parallel processing may be advantageous in certain situations. Furthermore, the separation of various system modules and components in the above embodiments should not be understood as requiring such separation in all embodiments. It should be understood that the program components and systems described may generally be integrated into a single software product or packaged into multiple software products.
[0128] Specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims may be performed in a different order and still achieve desirable results. By way of example, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In certain implementations, multitasking and parallel processing may be advantageous.
Claims
1. 1. A method implemented using a hardware circuit having a shared memory and a plurality of processor cores in communication with the shared memory, the method comprising: generating a first vector of values based on computations performed on a first processor core; the shared memory receiving, using a direct memory access (DMA) data path of the shared memory, the first vector of values from the first processor core; performing an accumulation operation in the shared memory between the first vector of values and a vector stored in the shared memory; The accumulation operation is performed using a calculator unit, the calculator unit comprising: i) coupled to said shared memory; ii) accumulating values of a plurality of vectors, said method further comprising: generating a result vector based on the accumulation operation.
2. The vector stored in the shared memory is received from a second processor core, and the method further comprises: the first processor core performing an accumulate to memory operation to accumulate each value of the first vector of values to a memory location of the shared memory; 2. The method of claim 1, further comprising: the second processor core performing an accumulate to memory operation to accumulate each value of a second vector of values into the memory locations of the shared memory, the second vector of values corresponding to the vectors stored in the shared memory.
3. generating the result vector based on the accumulation operation, generating the result vector without the first processor core performing a step of pre-accumulating products resulting from calculations performed by the first processor core; and generating the result vector without the second processor core performing a step of pre-accumulating products resulting from calculations performed by the second processor core.
4. Generating the result vector comprises: generating a vector of accumulated values as a result of performing the accumulation operation on the first vector of values; applying an activation function to each value in the vector of accumulated values; and generating the result vector as a result of applying the activation function to each value in the vector of accumulated values.
5. Each resource of the first processor core is a first matrix calculation unit, and the method further comprises:
3. The method of claim 2, comprising generating a first vector of accumulated values corresponding to the first vector of values based on a matrix multiplication performed with the first matrix computation unit of the first processor core.
6. Each resource of the second processor core is a second matrix calculation unit, and the method further comprises:
6. The method of claim 5, comprising generating a second vector of accumulated values corresponding to the second vector of values based on a matrix multiplication performed using the second matrix computation unit of the second processor core.
7. the hardware circuit is a hardware accelerator configured to execute a neural network including a plurality of neural network layers; The method of claim 1 , wherein the method comprises generating an output of a layer of the neural network based on the result vector.
8. generating a first vector of values based on calculations performed on the first processor core; generating a second vector of values based on calculations performed on the second processor core; The method of claim 2 , wherein the computations performed by the first processor core and the computations performed by the second processor core are part of a mathematical operation that is controlled by commutativity.
9. The mathematical operation is Floating-point multiplication operations, Floating-point addition operations, An integer addition operation, or The method of claim 8, wherein the operation is a min-max operation.
10. The method of claim 8 , wherein the mathematical operations include floating point addition operations and integer addition operations.
11. The method of claim 2 , wherein the first processor core and the second processor core are the same processor core.
12. The method of claim 1 , wherein the shared memory is configured to function as a shared global memory space including memory banks and registers shared among two or more processor cores of the hardware circuit.
13. 1. A system comprising: A processing device; a hardware circuit having a shared memory and a plurality of processor cores in communication with the shared memory; and a non-transitory machine-readable storage device for storing instructions executable by the processing device to perform operations, the operations including: generating a first vector of values based on computations performed on a first processor core; the shared memory receiving, using a direct memory access (DMA) data path of the shared memory, the first vector of values from the first processor core; performing an accumulation operation in the shared memory between the first vector of values and a vector stored in the shared memory; The accumulation operation is performed using a calculator unit, the calculator unit comprising: i) coupled to said shared memory; ii) accumulating a plurality of vectors, said operations further comprising: generating a result vector based on performing the accumulation operation with the first vector of values.
14. the vector stored in the shared memory is received from a second processor core, and the operation comprises: The first processor core stores the first vector of values in memory locations of the shared memory. performing an accumulation operation into a memory accumulating each value of 14. The system of claim 13, further comprising: the second processor core performing an accumulate to memory operation to accumulate each value of a second vector of values to the memory locations of the shared memory, the second vector of values corresponding to the vector stored in the shared memory.
15. generating the result vector based on performing the accumulation operation, generating the result vector without the first processor core performing a step of pre-accumulating products resulting from calculations performed by the first processor core; and generating the result vector without the second processor core performing a step of pre-accumulating products resulting from calculations performed by the second processor core.
16. Generating the result vector comprises: generating a vector of accumulated values as a result of performing the accumulation operation on the first vector of values; applying an activation function to each value in the vector of accumulated values; and generating the result vector as a result of applying the activation function to each value in the vector of accumulated values.
17. Each resource of the first processor core is a first matrix calculation unit, and the operation further comprises:
15. The system of claim 14, further comprising generating a first vector of accumulated values corresponding to the first vector of values based on a matrix multiplication performed using the first matrix computation unit of the first processor core.
18. The resource of each of the second processor cores is a second matrix calculation unit, and the operation further comprises:
20. The system of claim 17, further comprising generating a second vector of accumulated values corresponding to the second vector of values based on a matrix multiplication performed using the second matrix computation unit of the second processor core.
19. the hardware circuit is a hardware accelerator configured to execute a neural network including a plurality of neural network layers; 14. The system of claim 13, wherein the actions include generating an output of a layer of the neural network based on the result vector.
20. generating a first vector of values based on calculations performed on the first processor core; generating a second vector of values based on calculations performed on the second processor core; 15. The system of claim 14, wherein the computations performed by the first processor core and the computations performed by the second processor core are part of a mathematical operation controlled by commutativity.
21. The mathematical operation is Floating-point multiplication operations, Floating-point addition operations, An integer addition operation, or 21. The system of claim 20, wherein the operation is a min-max operation.
22. 21. The system of claim 20, wherein the mathematical operations include a floating point add operation and an integer add operation.
23. 15. The system of claim 14, wherein the first processor core and the second processor core are the same processor core.
24. 14. The system of claim 13, wherein the shared memory is configured to function as a shared global memory space including memory banks and registers shared among two or more processor cores of the hardware circuit.
25. A non-transitory machine-readable storage device for storing instructions executable by a processor to cause the processor to perform operations, the operations including: generating a first vector of values based on calculations performed on a first processor core of the hardware circuit; a shared memory of the hardware circuit receiving the first vector of values from the first processor core using a direct memory access (DMA) data path of the shared memory; performing an accumulation operation in the shared memory between the first vector of values and a vector stored in the shared memory; The accumulation operation is performed using a calculator unit, the calculator unit comprising: i) coupled to said shared memory; ii) accumulating a plurality of vectors, said operations further comprising: generating a result vector based on the accumulation operation.
Citation Information
Patent Citations
Software-defined memory bandwidth reduction by hierarchical stream buffering for general matrix multiplication in a programmable IC
US10354733B1
Inline image preprocessing for convolution operations using a matrix multiplier on an integrated circuit
US10460416B1
Systems and methods for reliable replication of an application-state, distributed replication table
US20140304354A1
Applications of back-end-of-line (BEOL) capacitors in compute-in-memory (CIM) circuits
US20190138893A1
Method and apparatus for tensor and convolution operations
US20190179635A1
