WO2022028224A1 - Data storage method and apparatus, and device and storage medium - Google Patents

Data storage method and apparatus, and device and storage medium Download PDF

Info

Publication number
WO2022028224A1
WO2022028224A1 PCT/CN2021/106394 CN2021106394W WO2022028224A1 WO 2022028224 A1 WO2022028224 A1 WO 2022028224A1 CN 2021106394 W CN2021106394 W CN 2021106394W WO 2022028224 A1 WO2022028224 A1 WO 2022028224A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
calculation
neural network
calculated
preset
Prior art date
Application number
PCT/CN2021/106394
Other languages
French (fr)
Chinese (zh)
Inventor
牛昕宇
李远超
蔡权雄
Original Assignee
深圳鲲云信息科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳鲲云信息科技有限公司 filed Critical 深圳鲲云信息科技有限公司
Publication of WO2022028224A1 publication Critical patent/WO2022028224A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/76Architectures of general purpose stored program computers
    • G06F15/82Architectures of general purpose stored program computers data or demand driven
    • G06F15/825Dataflow computers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means

Definitions

  • the embodiments of the present application relate to the technical field of neural networks, for example, to a data storage method, apparatus, device, and storage medium.
  • the neural network model usually includes multiple network layers, and the structure type of each layer is called the network computing type of each layer.
  • the computing data of the neural network usually corresponds to the network computing type. Therefore, when the computing module is fixed, the neural network chip needs to adopt different data storage methods for different network computing types.
  • the data and parameters of the data flow architecture chip are transferred from the off-chip memory to the on-chip memory, they are directly and sequentially read out to the subsequent computing modules for use, that is, external software is required to arrange the data in an orderly manner and then transfer it to the chip.
  • the chip does not include off-chip memory.
  • the above method cannot flexibly support multiple types of networks. If the network computing parameters change, the chip can only support the corresponding network computing type by supplementing data and increasing the amount of computation. The computing efficiency of the chip is reduced, and once the external real-time data is changed, the computing needs cannot be met.
  • Embodiments of the present application provide a data storage method, apparatus, device, and storage medium, so as to achieve the effect of storing and calculating data of different network computing types of a data flow architecture chip in different storage manners.
  • an embodiment of the present application provides a neural network computing type storage method, including:
  • the first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data stream network in the order of the first data matching the calculation type of the first neural network.
  • the calculation module performs calculations;
  • the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • an embodiment of the present application provides a neural network computing type storage device, including:
  • an acquisition module configured to acquire the first data to be calculated of the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated;
  • a configuration module configured to configure a first preset rule based on the first neural network calculation type
  • an on-chip storage module configured to store the first data to be calculated based on the first preset rule, so that the first data to be calculated is sent in the order of the first data matching the calculation type of the first neural network Perform calculations for the calculation modules in the data flow network;
  • the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • an embodiment of the present application provides a device, including:
  • processors one or more processors
  • the one or more processors When the one or more programs are executed by the one or more processors, the one or more processors implement the data storage method according to any embodiment of the present application.
  • an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the program is executed by a processor, the data storage method described in any embodiment of the present application is implemented.
  • FIG. 1 is a schematic flowchart of a data storage method provided in Embodiment 1 of the present application.
  • FIG. 2 is a schematic flowchart of a data storage method provided in Embodiment 2 of the present application.
  • FIG. 3 is a schematic structural diagram of a data storage device according to Embodiment 3 of the present application.
  • FIG. 4 is a schematic structural diagram of another data storage device provided in Embodiment 3 of the present application.
  • FIG. 5 is a schematic structural diagram of a device provided in Embodiment 4 of the present application.
  • Some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowchart depicts the various steps as a sequential process, many of the various steps may be performed in parallel, concurrently, or concurrently. Furthermore, the order of the various steps can be rearranged. Processing may be terminated when multiple step operations are completed, but may also have additional steps not included in the figures.
  • a process may correspond to a method, function, procedure, subroutine, subroutine, or the like.
  • first and second may be used herein to describe various directions, acts, steps or elements, etc., but are not limited by these terms. These terms are only used to distinguish a first direction, act, step or element from another direction, act, step or element.
  • the first preset rule may be referred to as the second preset rule, and similarly, the second preset rule may be referred to as the first preset rule, without departing from the scope of this application.
  • Both the first preset rule and the second preset rule are preset rules, but the first preset rule and the second preset rule are not the same preset rule.
  • the terms “first”, “second”, etc. should not be understood as indicating or implying relative importance or implying the number of indicated technical features.
  • a feature defined as “first” or “second” may expressly or implicitly include one or more of that feature.
  • “plurality” and “batch” mean at least two, such as two, three, etc., unless otherwise defined.
  • Embodiment 1 is a schematic flowchart of a data storage method provided in Embodiment 1 of the present application, which can be applied to a scenario where data of different neural network calculation types is calculated.
  • the method can be executed by a data storage device, and the device can use software and/or hardware, and can be integrated on the device.
  • the device may be a chip.
  • the data storage method provided in Embodiment 1 of the present application includes:
  • the first layer of the neural network refers to the first layer in the calculation of the neural network model.
  • the first data to be calculated refers to data to be calculated in the first layer of the neural network.
  • the first neural network calculation type refers to the neural network calculation type corresponding to the first data to be calculated.
  • the first neural network computation type may be a feedforward neural network, radial basis neural network, deep feedforward neural network, or recurrent neural network, etc.
  • the first neural network computation type is not limited herein.
  • the neural network calculation type corresponding to the data to be calculated in each of the multiple layers of the neural network may be preset.
  • the first preset rule refers to a rule applicable to data transmission and calculation corresponding to the first neural network calculation type.
  • the first preset rule refers to a rule for performing data processing on the data to be calculated that needs to be transmitted to the computing module on the chip in a certain manner.
  • the first preset rule is to store the first data to be calculated according to the order required by the calculation module, so as to send the first data to be calculated to the calculation module in the order required by the calculation module, and provide the data to the calculation module
  • the rules for the module to perform first-level operations. By arranging the data to be calculated by the calculation module in advance, the calculation efficiency of the chip is improved.
  • preset rules corresponding to different neural network calculation types are configured in advance.
  • the neural network model starts to calculate, according to the relationship between the configured neural network calculation types and the preset rules relationship, and the first neural network calculation type in the first data to be calculated, configure the first preset rule.
  • the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • the calculation module performs data calculation on the first layer of the neural network model according to the first preset rule.
  • the first data to be calculated flows in the data flow network according to the preset data flow direction, the data flow can also be obtained without relying on the instruction, and the calculation module only needs to wait for the data to arrive to perform the calculation.
  • the first data sequence refers to the data sequence mapped to the operation sequence of the first neural network calculation type. For example, when the data is processed according to the first neural network calculation type, the first data to be calculated is processed according to the operation sequence corresponding to the first neural network calculation type.
  • the first data to be calculated flows to the calculation module according to a data stream.
  • the first data to be calculated needs to be sorted according to the first data sequence and then sent to the calculation module for calculation.
  • the calculation module can cyclically control the read operation and control the address addressing of the read operation to extract the data for calculation.
  • the first data to be calculated is stored based on the configured preset rules for calculation.
  • the module calculates the first data to be calculated, and the calculation module is not limited to calculating for one type of neural network calculation.
  • the calculation module performs fixed addition and multiplication operations when performing data calculation, and the on-chip memory in the chip satisfies different calculation modes of the calculation module by storing different data arrangements.
  • the first data to be calculated is stored in the on-chip memory.
  • the on-chip memory is connected to the computing module; in addition, the on-chip memory can also be connected to the computing module through intermediate components.
  • the data flow network is a framework of the chip, and the neural network is a type of application mode of the chip.
  • the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset is configured based on the first neural network calculation type
  • the first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network.
  • the calculation module in the device performs calculation, wherein the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • the neural network calculation provided in this embodiment is not limited to one type of neural network, but the preset rules are configured through the neural network calculation type, which can cope with the single type of network calculation in the related art or the inability to flexibly support multiple types.
  • the data of different network computing types are stored in different storage methods to achieve the technical effect of computing the data of different network computing types in the data flow architecture.
  • the embodiments of the present application can also maintain high computing efficiency.
  • FIG. 2 is a schematic flowchart of a data storage method provided in Embodiment 2 of the present application. This embodiment describes the foregoing embodiments, and is applicable to scenarios in which data of different neural network calculation types are calculated.
  • the method can be performed by a data storage device, which can be implemented in software and/or hardware, and can be integrated on a device.
  • the data transmission method of the neural network includes:
  • the first layer of the neural network refers to the first layer in the calculation of the neural network model.
  • the first data to be calculated refers to data to be calculated in the first layer of the neural network.
  • the first neural network calculation type refers to the neural network calculation type corresponding to the first data to be calculated.
  • the neural network computation type may be a feedforward neural network, a radial basis neural network, a deep feedforward neural network, or a recurrent neural network, etc.
  • the computation type of the neural network is not limited herein.
  • the neural network calculation type corresponding to the data to be calculated in each of the multiple layers of the neural network may be preset.
  • the first data to be calculated includes at least one calculation parameter.
  • the calculation parameters include a convolution kernel size (kernel size), a stride (stride), a convolution kernel channel (channel) and a filter (filter), etc.
  • kernel size, stride, channel, and filter of different neural network computation types will have at least one computation parameter different.
  • the first preset rule refers to a rule applicable to data transmission and calculation corresponding to the first neural network calculation type.
  • the first preset rule refers to a rule for performing data processing on the data to be calculated that needs to be transmitted to the computing module on the chip in a certain manner.
  • the first preset rule is to store the first data to be calculated according to the order required by the calculation module, so as to send the first data to be calculated to the calculation module in the order required by the calculation module, and provide the data to the calculation module
  • the rules for the module to perform first-level operations.
  • preset rules corresponding to different neural network calculation types are configured in advance. When the neural network model starts to calculate, according to the relationship between the configured neural network calculation types and the preset rules relationship, and the first neural network calculation type in the first data to be calculated, configure the first preset rule.
  • the calculation module performs data calculation on the first layer of the neural network model according to the first preset rule.
  • the first data to be calculated is stored based on the configured preset rules for calculation.
  • the module calculates the first data to be calculated, and the calculation module is not limited to calculating for one type of neural network calculation.
  • the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • the first preset rule includes a preset storage rule and a preset calculation rule
  • S230 includes: storing the first data to be calculated based on the preset storage rule.
  • the method further includes: transmitting the preset calculation rule to the calculation module, so that the calculation module can calculate the first data to be calculated according to the preset calculation rule.
  • the preset storage rule refers to a rule for sorting data in a certain order.
  • the preset storage rule is a rule for storing the first data to be calculated according to the order of the first data.
  • the order of data storage is determined according to the order in which the computing module performs data computing, and the data is ordered in advance, which can improve the computing efficiency of the computing module.
  • the preset storage rule may be the sorting of different data, such as data, weight, and paranoia; it may also be the sorting of the same data, such as the pixel size of the picture or the three colors of red, blue, and yellow, which are not limited herein.
  • the preset calculation rule refers to the rule by which the calculation module calculates data.
  • the preset calculation rule is a rule for calculation according to the first neural network calculation type.
  • the preset calculation rule is to pull data in sequence for calculation.
  • storing the first data to be calculated based on the preset storage rule includes: storing the first data to be calculated in the on-chip in the order of the first data based on the preset storage rule and a memory, so as to transmit the sorted first data to be calculated to the calculation module after sorting the first data to be calculated according to the order of the first data through the on-chip memory.
  • the preset rules of the neural network calculation type are configured, which can reduce the layout space on the chip. As well as increasing the flexibility of data storage.
  • the second layer of the neural network refers to the next layer of the first layer of the neural network.
  • the second data to be calculated refers to data to be calculated in the second layer of the neural network.
  • the second neural network calculation type refers to the neural network calculation type of the second data to be calculated.
  • the calculation type of the second neural network may be a feedforward neural network, a radial basis neural network, a deep feedforward neural network or a recurrent neural network, etc.
  • the calculation type of the second neural network is not limited herein.
  • the second data to be calculated includes at least one calculation parameter.
  • the calculation parameters include kernel size, stride, channel, filter, etc., and the types of the calculation parameters are not limited here.
  • the first neural network calculation type is a deep feedforward neural network
  • the second neural network calculation type is also a deep feedforward neural network
  • the first neural network calculation type and the second neural network calculation type are the same.
  • the first neural network computation type is a deep feedforward neural network and the second neural network computation type is a recurrent neural network
  • the first neural network computation type and the second neural network computation type are not the same.
  • the calculation type of the first neural network is the same as the calculation type of the second neural network
  • the first preset rule is also applicable to the calculation of the neural network calculation type of the second layer
  • the second layer of the neural network can be directly activated
  • the second data to be calculated is calculated in the second layer of the neural network.
  • the second data to be calculated stored according to the second preset rule is used to be sent to the calculation module in the data flow network for calculation according to the second data sequence matching the calculation type of the second neural network .
  • a second preset rule is configured based on the second neural network calculation type, and the second data to be calculated is stored based on the second preset rule, so that the second data to be calculated is calculated according to the first
  • the second data matching the calculation types of the two neural networks is sequentially sent to the calculation module in the data flow network for calculation.
  • the second preset rule refers to a rule applicable to data transmission and calculation corresponding to the second neural network calculation type.
  • the second data order refers to the data order mapped to the operation order of the second neural network calculation type. For example, when the calculation type of the second neural network is different from the calculation type of the first neural network, for example, when the size of the convolution kernel is different, the required data order is different, so when the calculation type of the first neural network and the calculation type of the second neural network are different At different times, the second data to be calculated needs to be stored in the on-chip memory in the order of the second data corresponding to the second neural network calculation type, so as to be used by the calculation module for calculation when flowing to the calculation module.
  • the second preset rule refers to a rule for performing data processing on the data to be calculated that needs to be transmitted to the computing module on the chip in a certain manner.
  • the second preset rule is to store the second data to be calculated according to the order required by the calculation module, so as to send the second data to be calculated to the calculation module in the order required by the calculation module, and provide the data to the calculation module.
  • the rules for the module to perform the second-level operations.
  • the second preset rule is configured directly according to the second neural network calculation type. If the calculation type of the second neural network is the same as the calculation type of the first neural network, the second preset rule and the first preset rule are also the same.
  • the data to be calculated of the third layer or even more layers of the neural network is acquired, and the level of the acquired data to be calculated needs to be determined according to the number of levels of the computational model of the neural network.
  • convolutional networks are generally used to process image data.
  • a convolutional network there will be multiple convolutional layers, and different convolutional layers have different convolution kernel sizes, step sizes and filters, that is, different convolutional layers correspond to different types of neural network computations.
  • the first preset rule corresponding to the neural network calculation type sorts the image data according to the operation sequence required by the first neural network calculation type, stores it in the on-chip memory, and directly sends the data stream in the first data sequence to the calculation module Calculate, when the first convolutional layer calculation is completed, output the first feature map (feature map).
  • the image data entering the first convolutional layer is also a feature map.
  • the first feature map starts to enter the second convolutional layer for processing, first determine whether the second neural network calculation type of the second convolutional layer is the same as the first neural network calculation type.
  • the calculation type of the second neural network is different from the calculation type of the first neural network, according to the channel/width/height characteristics of the second data to be calculated, according to the second preset rule corresponding to the second neural network calculation type
  • the feature map is sorted according to the operation sequence required by the second neural network calculation type and stored in the on-chip memory, it is directly sent to the calculation module for calculation according to the data stream of the second data sequence. And so on, the image processing is done in the convolutional network.
  • the data is linearly transformed to meet the calculation needs of the calculation module, which can ensure that the convolution operation of different features of multiple neural networks is compatible with the data flow architecture. Adding extra time consumption ensures the efficiency and flexibility of the operation of the data flow structure, and can satisfy the convolution operation of multiple neural networks in the data flow structure.
  • the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset is configured based on the first neural network calculation type The first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network.
  • the calculation module in the calculation module performs calculation, after the calculation module calculates the first to-be-calculated data, obtains the second to-be-calculated data of the second layer of the neural network and the second neural network calculation type corresponding to the second to-be-calculated data, By judging whether the calculation type of the first neural network is the same as the calculation type of the second neural network, the data storage mode for the second-layer neural network is determined.
  • the neural network calculation provided in this embodiment is not limited to one type of neural network, but configures preset rules through the neural network calculation type, which can cope with the network calculation type in the related art that supports a single type or cannot flexibly support multiple types of networks
  • the data of different network computing types are stored in different storage methods to achieve the technical effect of computing data of different network computing types.
  • the embodiments of the present application can also maintain high computing efficiency.
  • the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset rule is configured based on the first neural network calculation type ; Based on the first preset rule, the first data to be calculated is stored, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network.
  • the calculation module performs calculation; wherein, the first data to be calculated flows in the data flow network according to the preset data flow direction, and when the chip of the data flow architecture supports a variety of neural network calculation types, it is necessary to pass the supplementary data It is realized by increasing the amount of calculation, reducing the computing efficiency of the chip, and realizing the data flow architecture of different network computing types. Effect.
  • FIG. 3 is a schematic structural diagram of a data storage device provided in Embodiment 3 of the present application. This embodiment is applicable to a scenario in which data of different neural network calculation types is calculated, and the device can be implemented in software and/or hardware. , and can be integrated on the device.
  • the data storage device may include an acquisition module 310, a configuration module 320, and an on-chip storage module 330, wherein: the acquisition module 310 is configured to acquire the first data to be calculated of the first layer of the neural network the first neural network calculation type corresponding to the first data to be calculated; the configuration module 320 is configured to configure a first preset rule based on the first neural network calculation type; the on-chip storage module 330 is configured to be based on the first neural network calculation type.
  • a preset rule stores the first data to be calculated, so that the first data to be calculated is sent to the calculation module in the data flow network for calculation according to the first data sequence matching the calculation type of the first neural network ; wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • the obtaining module 310 is further configured to obtain the second data to be calculated of the second layer of the neural network and the second neural network calculation type corresponding to the second data to be calculated.
  • the device further includes: a judgment module 340, the judgment module 340 is configured to judge whether the calculation type of the first neural network is the same as the calculation type of the second neural network;
  • the on-chip storage module 330 is further configured to, in response to the judgment result that the first neural network calculation type is the same as the second neural network calculation type, perform the calculation on the second data to be calculated based on the first preset rule. storing; and in response to a judgment result that the first neural network calculation type is different from the second neural network calculation type, configure a second preset rule based on the second neural network calculation type, and configure a second preset rule based on the second neural network calculation type.
  • the preset rule stores the second data to be calculated, wherein the second data to be calculated stored according to the second preset rule is used for the second data sequence matched according to the second neural network calculation type, It is sent to the calculation module in the data flow network for calculation.
  • the first preset rule includes a preset storage rule and a preset calculation rule.
  • the on-chip storage module 330 includes: a storage unit and a sending unit;
  • a storage unit configured to store the first data to be calculated based on the preset storage rule, wherein the preset storage rule is to store the first data to be calculated in the order of the first data a rule; a sending unit configured to transmit the preset calculation rule to the calculation module, so that the calculation module can calculate the first data to be calculated according to the preset calculation rule.
  • the preset calculation rule is a rule for calculation according to the first neural network calculation type.
  • the first data to be calculated includes at least one calculation parameter
  • the second data to be calculated includes at least one calculation parameter
  • the calculation parameters include: at least one of kernel size, stride, channel, and filter.
  • the storage unit is further configured to store the first data to be calculated in the on-chip memory in the order of the first data based on the preset storage rule, so as to store the first data in the on-chip memory through the on-chip memory. After the data to be calculated is sorted according to the first data sequence, it is transmitted to the calculation module.
  • the data storage device provided by the embodiment of the present application can execute the data storage method provided by any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method.
  • the data storage device can execute the data storage method provided by any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method.
  • FIG. 5 is a schematic structural diagram of a device provided in Embodiment 4 of the present application.
  • FIG. 5 shows a block diagram of an exemplary apparatus 612 suitable for implementing embodiments of the present application.
  • the device 612 shown in FIG. 5 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present application.
  • device 612 takes the form of a generic device.
  • Components of device 612 may include, but are not limited to, one or more processors 616 , storage 628 , and bus 618 connecting various system components, such as storage 628 and processor 616 .
  • Bus 618 represents one or more of several types of bus structures, including a storage device bus or storage device controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures.
  • these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, enhanced ISA bus, Video Electronics Standards Association (Video Electronics Standards) Association, VESA) local bus and Peripheral Component Interconnect (PCI) bus.
  • device 612 includes various computer system readable media. These media can be any available media that can be accessed by device 612, including volatile and non-volatile media, removable and non-removable media.
  • Storage 628 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 630 and/or cache 632 .
  • terminal 612 may include other removable/non-removable, volatile/non-volatile computer system storage media.
  • storage system 634 may be used to read and write to non-removable, non-volatile magnetic media, not shown in FIG. 5, which are commonly referred to as hard disk drives.
  • a magnetic disk drive for reading and writing to removable non-volatile magnetic disks, such as floppy disks, and removable non-volatile optical disks, such as Compact Disc Read-Only Memory, may be provided.
  • each drive may be connected to bus 618 through one or more data media interfaces.
  • the storage device 628 may include at least one program product having a set of, eg, at least one program module configured to perform the functions of the embodiments of the present application.
  • Program/utility 640 having, for example, a set of at least one program module 642, which may be stored, for example, in storage device 628, such program module 642 including, but not limited to, an operating system, one or more application programs, other program modules, and program data , each or a combination of these examples may include an implementation of a network environment.
  • Program modules 642 generally perform the functions and/or methods of the embodiments described herein.
  • Device 612 may also communicate with one or more external devices 614, such as a keyboard, pointing terminal, display 624, etc., and one or more terminals that enable a user to interact with the device 612, and/or with Any terminal (eg, network card, modem, etc.) that enables the device 612 to communicate with one or more other computing terminals. Such communication may take place through an input/output (I/O) interface 622 . Also, the device 612 may communicate with one or more networks, such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through a network adapter 620. As shown in FIG. 5 , network adapter 620 communicates with other modules of device 612 via bus 618 .
  • LAN Local Area Network
  • WAN Wide Area Network
  • public network such as the Internet
  • device 612 may be used in conjunction with device 612, including but not limited to: microcode, terminal drivers, redundant processors, external disk drive arrays, Redundant Arrays of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
  • the processor 616 executes a variety of functional applications and data processing by running the programs stored in the storage device 628, for example, implementing a data storage method provided by any embodiment of the present application, the method may include: obtaining the first data of the neural network.
  • the first data to be calculated is stored, so that the first data to be calculated is sent to the calculation module in the data flow network for calculation according to the first data sequence matching the calculation type of the first neural network; wherein, the first The data to be calculated flows in the data flow network according to a preset data flow direction.
  • the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset is configured based on the first neural network calculation type
  • the first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network.
  • the calculation module in the device performs calculation, wherein the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • the neural network calculation provided in this embodiment is not limited to one type of neural network, but the preset rules are configured through the neural network calculation type, which can cope with the single type of network calculation in the related art or the inability to flexibly support multiple types.
  • the data of different network computing types are stored in different storage methods to achieve the technical effect of computing the data of different network computing types in the data flow architecture.
  • the embodiments of the present application can also maintain high computing efficiency.
  • An embodiment of the present application further provides a system, including: a configuration device, a direct memory access (Direct Memory Access, DMA) device, an external storage device, and an on-chip storage device.
  • the configuration device can be a processor; the external storage device can be a double-rate (Double Data Rate, DDR) memory; the DMA device connects the external storage device and the on-chip storage device, and the DMA device is controlled by the configuration device; the DMA device is configured according to the processor , the data in the external storage device is moved to the on-chip storage device, and the on-chip storage device stores the data according to the processor configuration.
  • DDR Dynamic Data Rate
  • the DMA device When the DMA device is executed by the processor, the DMA device transfers the data from the external storage device to the on-chip storage device according to the processor configuration, and when the on-chip storage device is configured by the processor, the on-chip storage device transfers the data from the DMA device to the on-chip storage device according to the processor configuration.
  • the configuration mode is stored in on-chip storage, and implements the data storage method provided by any embodiment of the present application.
  • External storage devices may be referred to as off-chip memory, and on-chip storage devices may be referred to as on-chip memory.
  • Embodiment 5 of the present application further provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the program is executed by a processor, implements a data storage method as provided in any embodiment of the present application, the The method may include: acquiring first data to be calculated in the first layer of the neural network and a first neural network calculation type corresponding to the first data to be calculated; configuring a first preset rule based on the first neural network calculation type; The first preset rule stores the first data to be calculated, so that the first data to be calculated is sent to the calculation module in the data flow network according to the first data sequence matching the calculation type of the first neural network Calculate; wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • the computer-readable storage medium of the embodiments of the present application may adopt any combination of one or more computer-readable mediums.
  • the computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium.
  • the computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. Examples (non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, RAM, Read-Only Memory (ROM), erasable Erasable Programmable Read-Only Memory (EPROM or flash memory), optical fiber, CD-ROM, optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied in the computer-readable signal medium. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • a computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device .
  • the program code contained on the storage medium can be transmitted by any suitable medium, including - but not limited to wireless, wire, optical fiber cable, radio frequency (RF), etc., or any suitable combination of the above.
  • suitable medium including - but not limited to wireless, wire, optical fiber cable, radio frequency (RF), etc., or any suitable combination of the above.
  • Computer program code for performing the operations of the present application may be written in one or more programming languages, including object-oriented programming languages—such as Java, Smalltalk, C++, but also conventional Procedural programming language - such as the "C" language or similar programming language.
  • the program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or terminal.
  • the remote computer may be connected to the user's computer through any kind of network, including a LAN or WAN, or may be connected to an external computer, such as through the Internet using an Internet service provider.
  • the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset is configured based on the first neural network calculation type
  • the first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network.
  • the calculation module in the device performs calculation, wherein the first data to be calculated flows in the data flow network according to a preset data flow direction.
  • the neural network calculation provided in this embodiment is not limited to one type of neural network, but configures preset rules through the neural network calculation type, which can cope with the related art where the network calculation type is single or cannot flexibly support multiple types of networks.
  • the data of different network computing types are stored in different storage methods to achieve the technical effect of computing the data of different network computing types in the data flow architecture.
  • the embodiments of the present application can also maintain high computing efficiency.
  • the embodiment of the present application also provides a storage medium with a processor-configurable storage arrangement, in which external storage data can be stored in different arrangement sequences, and the data is transmitted by the processor through the DMA device to the storage device for execution.
  • the data storage method provided by any embodiment of the present application.

Abstract

A data storage method and apparatus, and a device and a storage medium. The data storage method comprises: acquiring a first neural network computation type corresponding to first data to be subjected to computation; configuring a first preset rule on the basis of the first neural network computation type (S120); and on the basis of the first preset rule, storing the first data to be subjected to computation, such that the first data to be subjected to computation is sent, according to a first data sequence that matches the first neural network computation type, to a computation module in a data stream network for computation (S130).

Description

数据存储方法、装置、设备和存储介质Data storage method, apparatus, device and storage medium
本公开要求在2020年08月03日提交中国专利局、申请号为202010764719.8的中国专利申请的优先权,以上申请的全部内容通过引用结合在本公开中。The present disclosure claims the priority of a Chinese patent application with application number 202010764719.8 filed with the Chinese Patent Office on Aug. 3, 2020, the entire contents of which are incorporated into the present disclosure by reference.
技术领域technical field
本申请实施例涉及神经网络技术领域,例如涉及一种数据存储方法、装置、设备和存储介质。The embodiments of the present application relate to the technical field of neural networks, for example, to a data storage method, apparatus, device, and storage medium.
背景技术Background technique
随着神经网络技术的快速发展,神经网络的计算数据量越来越大,数据存储是神经网络技术的一项重要内容。With the rapid development of neural network technology, the amount of computational data in neural network is increasing, and data storage is an important part of neural network technology.
就基于数据流架构开发的神经网络芯片而言,神经网络模型通常包括多个网络层级,每一层的结构类型称为每一层的网络计算类型,不同层之间的网络计算类型可能不同,而神经网络的计算数据通常与网络计算类型对应,因此,在计算模块固定情况下,神经网络芯片需要针对不同网络计算类型采用不同的数据存储方式。通常,数据流架构芯片的数据和参数由片外存储器搬运到片内存储器后都是直接顺序读出给后续计算模块使用,即需要外部软件将数据整理好顺序再传递到芯片上。As far as the neural network chip developed based on the data flow architecture is concerned, the neural network model usually includes multiple network layers, and the structure type of each layer is called the network computing type of each layer. The computing data of the neural network usually corresponds to the network computing type. Therefore, when the computing module is fixed, the neural network chip needs to adopt different data storage methods for different network computing types. Usually, after the data and parameters of the data flow architecture chip are transferred from the off-chip memory to the on-chip memory, they are directly and sequentially read out to the subsequent computing modules for use, that is, external software is required to arrange the data in an orderly manner and then transfer it to the chip.
其中,芯片不包括片外存储器。Among them, the chip does not include off-chip memory.
然而,在采用数据流架构的芯片中,上述方式不能灵活支持多种类型网络,如果网络计算参数发生改变,则芯片只能通过补充数据和加大计算量的方式来支持对应的网络计算类型,降低了芯片的计算效率,并且外部实时数据一旦改变,就不能满足计算需要。However, in a chip with a data flow architecture, the above method cannot flexibly support multiple types of networks. If the network computing parameters change, the chip can only support the corresponding network computing type by supplementing data and increasing the amount of computation. The computing efficiency of the chip is reduced, and once the external real-time data is changed, the computing needs cannot be met.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供一种数据存储方法、装置、设备和存储介质,以实现将数据流架构芯片的不同网络计算类型的数据按不同存储方式存储和计算的效果。Embodiments of the present application provide a data storage method, apparatus, device, and storage medium, so as to achieve the effect of storing and calculating data of different network computing types of a data flow architecture chip in different storage manners.
第一方面,本申请实施例提供了一种神经网络计算类型的存储方法,包括:In a first aspect, an embodiment of the present application provides a neural network computing type storage method, including:
获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;Obtain the first data to be calculated of the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated;
基于所述第一神经网络计算类型配置第一预设规则;Configure a first preset rule based on the first neural network calculation type;
基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算;The first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data stream network in the order of the first data matching the calculation type of the first neural network. The calculation module performs calculations;
其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。Wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
第二方面,本申请实施例提供了一种神经网络计算类型的存储装置,包括:In a second aspect, an embodiment of the present application provides a neural network computing type storage device, including:
获取模块,设置为获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;an acquisition module, configured to acquire the first data to be calculated of the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated;
配置模块,设置为基于所述第一神经网络计算类型配置第一预设规则;a configuration module, configured to configure a first preset rule based on the first neural network calculation type;
片上存储模块,设置为基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算;an on-chip storage module, configured to store the first data to be calculated based on the first preset rule, so that the first data to be calculated is sent in the order of the first data matching the calculation type of the first neural network Perform calculations for the calculation modules in the data flow network;
其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。Wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
第三方面,本申请实施例提供了一种设备,包括:In a third aspect, an embodiment of the present application provides a device, including:
一个或多个处理器;one or more processors;
存储装置,设置为存储一个或多个程序,storage means arranged to store one or more programs,
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如本申请任意实施例所述的数据存储方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the data storage method according to any embodiment of the present application.
第四方面,本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,该程序被处理器执行时实现如本申请任意实施例所述的数据存储方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the program is executed by a processor, the data storage method described in any embodiment of the present application is implemented.
附图说明Description of drawings
图1是本申请实施例一提供的一种数据存储方法的流程示意图;1 is a schematic flowchart of a data storage method provided in Embodiment 1 of the present application;
图2是本申请实施例二提供的一种数据存储方法的流程示意图;2 is a schematic flowchart of a data storage method provided in Embodiment 2 of the present application;
图3是本申请实施例三提供的一种数据存储装置的结构示意图;3 is a schematic structural diagram of a data storage device according to Embodiment 3 of the present application;
图4是本申请实施例三提供的另一种数据存储装置的结构示意图;4 is a schematic structural diagram of another data storage device provided in Embodiment 3 of the present application;
图5是本申请实施例四提供的一种设备的结构示意图。FIG. 5 is a schematic structural diagram of a device provided in Embodiment 4 of the present application.
具体实施方式detailed description
下面结合附图和实施例对本申请进行说明。本文所描述的具体实施例仅仅用于解释本申请,而非对本申请的限定。为了便于描述,附图中仅示出了与本申请相关的部分而非全部结构。The present application will be described below with reference to the accompanying drawings and embodiments. The specific embodiments described herein are only used to explain the present application, but not to limit the present application. For convenience of description, the drawings only show some but not all structures related to the present application.
一些示例性实施例被描述成作为流程图描绘的处理或方法。虽然流程图将多个步骤描述成顺序的处理,但是多个步骤中的许多步骤可以被并行地、并发地或者同时实施。此外,多个步骤的顺序可以被重新安排。当多个步骤操作完成时处理可以被终止,但是还可以具有未包括在附图中的附加步骤。处理可以对应于方法、函数、规程、子例程、子程序等等。Some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowchart depicts the various steps as a sequential process, many of the various steps may be performed in parallel, concurrently, or concurrently. Furthermore, the order of the various steps can be rearranged. Processing may be terminated when multiple step operations are completed, but may also have additional steps not included in the figures. A process may correspond to a method, function, procedure, subroutine, subroutine, or the like.
术语“第一”、“第二”等可在本文中用于描述多种方向、动作、步骤或元件等,但这些方向、动作、步骤或元件不受这些术语限制。这些术语仅用于将第一个方向、动作、步骤或元件与另一个方向、动作、步骤或元件区分。举例来说,在不脱离本申请的范围的情况下,可以将第一预设规则称为第二预设规则,且类似地,可将第二预设规则称为第一预设规则。第一预设规则和第二预设规则两者都是预设规则,但第一预设规则和第二预设规则不是同一预设规则。术语“第一”、“第二”等不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本申请的描述中,“多个”、“批量”的含义是至少两个,例如两个,三个等,除非另有限定。The terms "first," "second," etc. may be used herein to describe various directions, acts, steps or elements, etc., but are not limited by these terms. These terms are only used to distinguish a first direction, act, step or element from another direction, act, step or element. For example, the first preset rule may be referred to as the second preset rule, and similarly, the second preset rule may be referred to as the first preset rule, without departing from the scope of this application. Both the first preset rule and the second preset rule are preset rules, but the first preset rule and the second preset rule are not the same preset rule. The terms "first", "second", etc. should not be understood as indicating or implying relative importance or implying the number of indicated technical features. Thus, a feature defined as "first" or "second" may expressly or implicitly include one or more of that feature. In the description of this application, "plurality" and "batch" mean at least two, such as two, three, etc., unless otherwise defined.
实施例一Example 1
图1为本申请实施例一提供的一种数据存储方法的流程示意图,可适用于对不同神经网络计算类型的数据进行计算的场景,该方法可以由数据存储装置来执行,该装置可以采用软件和/或硬件的方式实现,并可集成在设备上。例如,设备可为芯片。1 is a schematic flowchart of a data storage method provided in Embodiment 1 of the present application, which can be applied to a scenario where data of different neural network calculation types is calculated. The method can be executed by a data storage device, and the device can use software and/or hardware, and can be integrated on the device. For example, the device may be a chip.
如图1所示,本申请实施例一提供的数据存储方法包括:As shown in FIG. 1 , the data storage method provided in Embodiment 1 of the present application includes:
S110、获取神经网络的第一层的第一待计算数据和第一待计算数据对应的第一神经网络计算类型。S110. Acquire the first data to be calculated of the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated.
本实施例中,神经网络中欲进行计算操作的层级有多层,当当前层计算完成后,执行下一层的数据运算。神经网络的第一层是指在神经网络模型计算中最先开始计算的层级。第一待计算数据是指在神经网络的第一层进行计算的数据。第一神经网络计算类型是指第一待计算数据对应的神经网络计算类型。一实施例中,第一神经网络计算类型可为前馈神经网络、径向基神经网络、深度前馈神经网络或递归神经网络等,本文对于第一神经网络计算类型不作限制。In this embodiment, there are multiple layers in the neural network for which calculation operations are to be performed. After the calculation of the current layer is completed, the data operation of the next layer is performed. The first layer of the neural network refers to the first layer in the calculation of the neural network model. The first data to be calculated refers to data to be calculated in the first layer of the neural network. The first neural network calculation type refers to the neural network calculation type corresponding to the first data to be calculated. In one embodiment, the first neural network computation type may be a feedforward neural network, radial basis neural network, deep feedforward neural network, or recurrent neural network, etc. The first neural network computation type is not limited herein.
在一实施例中,可以预先设置神经网络的多层中每层的待计算数据对应的神经网络计算类型。In one embodiment, the neural network calculation type corresponding to the data to be calculated in each of the multiple layers of the neural network may be preset.
S120、基于所述第一神经网络计算类型配置第一预设规则。S120. Configure a first preset rule based on the first neural network calculation type.
本实施例中,第一预设规则是指适用于第一神经网络计算类型对应的数据传输及计算的规则。一实施例中,第一预设规则是指按照一定方式对需要传输给芯片上的计算模块的待计算数据进行数据处理的规则。在本实施例中,第一预设规则为根据计算模块需要的顺序对第一待计算数据进行存储,以将第一待计算数据按照计算模块需要的顺序发送至计算模块中,提供数据给计算模块进行第一层运算的规则。通过将计算模块需要计算的数据提前排好序,提高了芯片的计算效率。一实施例中,在神经网络模型开始计算前,将不同神经网络计算类型对应的预设规则提前配置好,当神经网络模型开始计算时,根据配置好的神经网络计算类型和预设规则的关联关系,以及第一待计算数据中的第一神经网络计算类型,配置第一预设规则。In this embodiment, the first preset rule refers to a rule applicable to data transmission and calculation corresponding to the first neural network calculation type. In one embodiment, the first preset rule refers to a rule for performing data processing on the data to be calculated that needs to be transmitted to the computing module on the chip in a certain manner. In this embodiment, the first preset rule is to store the first data to be calculated according to the order required by the calculation module, so as to send the first data to be calculated to the calculation module in the order required by the calculation module, and provide the data to the calculation module The rules for the module to perform first-level operations. By arranging the data to be calculated by the calculation module in advance, the calculation efficiency of the chip is improved. In one embodiment, before the neural network model starts to calculate, preset rules corresponding to different neural network calculation types are configured in advance. When the neural network model starts to calculate, according to the relationship between the configured neural network calculation types and the preset rules relationship, and the first neural network calculation type in the first data to be calculated, configure the first preset rule.
S130、基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算。S130. Store the first data to be calculated based on the first preset rule, so that the first data to be calculated is sent to a data stream network in the order of the first data matching the calculation type of the first neural network The calculation module in the calculation.
其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。Wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
本实施例中,计算模块根据第一预设规则在神经网络模型的第一层进行数据的计算。其中,第一待计算数据按照预设的数据流向在数据流网络中流动,数据的流动不依赖于指令也能获取,计算模块只需要等待数据来到即可进行计算。第一数据顺序是指跟第一神经网络计算类型的运算顺序映射的数据顺序。例如,在按照第一神经网络计算类型对数据进行处理时,是按照与第一神经网络计算类型对应的运算顺序对第一待计算数据进行处理。而本实施例中的第一待计算数据是按照数据流的方式流向计算模块中,因此,需要先将第一待计算数据按照第一数据顺序排好序再发送给计算模块进行计算。将第一待计算数据按照第一数据顺序排好序后,计算模块可以循环控制读操作,并且控制读操作的地址寻址,来提取数据进行计算。In this embodiment, the calculation module performs data calculation on the first layer of the neural network model according to the first preset rule. Wherein, the first data to be calculated flows in the data flow network according to the preset data flow direction, the data flow can also be obtained without relying on the instruction, and the calculation module only needs to wait for the data to arrive to perform the calculation. The first data sequence refers to the data sequence mapped to the operation sequence of the first neural network calculation type. For example, when the data is processed according to the first neural network calculation type, the first data to be calculated is processed according to the operation sequence corresponding to the first neural network calculation type. In this embodiment, the first data to be calculated flows to the calculation module according to a data stream. Therefore, the first data to be calculated needs to be sorted according to the first data sequence and then sent to the calculation module for calculation. After arranging the first data to be calculated according to the first data sequence, the calculation module can cyclically control the read operation and control the address addressing of the read operation to extract the data for calculation.
在本实施例中,通过确定第一待计算数据的神经网络计算类型,并针对不同的神经网络计算类型配置预设规则,基于配置的预设规则对第一待计算数据进行存储,以供计算模块对第一待计算数据进行计算,计算模块并没有局限于针对一种神经网络计算类型进行计算。一实施例中,计算模块在进行数据计算时,执行固定的加法和乘法运算,芯片内的片内存储器通过存储不同的数据排布方式满足计算模块不同的计算方式。In this embodiment, by determining the neural network calculation type of the first data to be calculated, and configuring preset rules for different neural network calculation types, the first data to be calculated is stored based on the configured preset rules for calculation. The module calculates the first data to be calculated, and the calculation module is not limited to calculating for one type of neural network calculation. In one embodiment, the calculation module performs fixed addition and multiplication operations when performing data calculation, and the on-chip memory in the chip satisfies different calculation modes of the calculation module by storing different data arrangements.
在一实施例中,将第一待计算数据存储到片内存储器中。片内存储器与计 算模块连接;此外,片内存储器也可通过中间部件与计算模块连接。In one embodiment, the first data to be calculated is stored in the on-chip memory. The on-chip memory is connected to the computing module; in addition, the on-chip memory can also be connected to the computing module through intermediate components.
在一实施例中,数据流网络为芯片的框架,神经网络为芯片的一类应用方式。In one embodiment, the data flow network is a framework of the chip, and the neural network is a type of application mode of the chip.
本申请实施例,通过获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;基于所述第一神经网络计算类型配置第一预设规则;基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算,其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。本实施例提供的神经网络计算,并没有局限于一种计算类型的神经网络,而是通过神经网络计算类型配置预设规则,可应对相关技术中网络计算类型单一或不能够灵活支持多种类型网络的工况,将不同网络计算类型的数据按不同存储方式存储以达到对数据流架构的不同网络计算类型的数据进行计算的技术效果。此外,本申请实施例还能保持高计算效率。In this embodiment of the present application, the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset is configured based on the first neural network calculation type The first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network. The calculation module in the device performs calculation, wherein the first data to be calculated flows in the data flow network according to a preset data flow direction. The neural network calculation provided in this embodiment is not limited to one type of neural network, but the preset rules are configured through the neural network calculation type, which can cope with the single type of network calculation in the related art or the inability to flexibly support multiple types. In the working condition of the network, the data of different network computing types are stored in different storage methods to achieve the technical effect of computing the data of different network computing types in the data flow architecture. In addition, the embodiments of the present application can also maintain high computing efficiency.
实施例二Embodiment 2
图2是本申请实施例二提供的一种数据存储方法的流程示意图。本实施例对上述实施例进行说明,适用于对不同神经网络计算类型的数据进行计算的场景。该方法可以由数据存储装置来执行,该装置可以采用软件和/或硬件的方式实现,并可集成在设备上。FIG. 2 is a schematic flowchart of a data storage method provided in Embodiment 2 of the present application. This embodiment describes the foregoing embodiments, and is applicable to scenarios in which data of different neural network calculation types are calculated. The method can be performed by a data storage device, which can be implemented in software and/or hardware, and can be integrated on a device.
如图2所示,本申请实施例二提供的神经网络的数据传输方法包括:As shown in FIG. 2 , the data transmission method of the neural network provided by the second embodiment of the present application includes:
S210、获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型。S210. Obtain the first data to be calculated of the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated.
本实施例中,神经网络中欲进行计算的层级有多层,当当前层计算完成后,执行下一层的数据运算。神经网络的第一层是指在神经网络模型计算中最先开始计算的层级。第一待计算数据是指在神经网络的第一层进行计算的数据。第一神经网络计算类型是指第一待计算数据对应的神经网络计算类型。一实施例中,神经网络计算类型可为前馈神经网络、径向基神经网络、深度前馈神经网络或递归神经网络等,本文对于神经网络计算类型不作限制。In this embodiment, there are multiple layers to be calculated in the neural network. After the calculation of the current layer is completed, the data operation of the next layer is performed. The first layer of the neural network refers to the first layer in the calculation of the neural network model. The first data to be calculated refers to data to be calculated in the first layer of the neural network. The first neural network calculation type refers to the neural network calculation type corresponding to the first data to be calculated. In one embodiment, the neural network computation type may be a feedforward neural network, a radial basis neural network, a deep feedforward neural network, or a recurrent neural network, etc. The computation type of the neural network is not limited herein.
在一实施例中,可以预先设置神经网络的多层中每层的待计算数据对应的神经网络计算类型。In one embodiment, the neural network calculation type corresponding to the data to be calculated in each of the multiple layers of the neural network may be preset.
在本实施例中,第一待计算数据包括至少一种计算参数。一实施例中,计 算参数包括卷积核大小(kernel size)、步长(stride)、卷积核通道(channel)和滤波器(filter)等,本文对于计算参数的类型不作限制。例如,不同神经网络计算类型的kernel size、stride、channel和filter至少会有一个计算参数不同。In this embodiment, the first data to be calculated includes at least one calculation parameter. In one embodiment, the calculation parameters include a convolution kernel size (kernel size), a stride (stride), a convolution kernel channel (channel) and a filter (filter), etc. The types of calculation parameters are not limited herein. For example, kernel size, stride, channel, and filter of different neural network computation types will have at least one computation parameter different.
S220、基于所述第一神经网络计算类型配置第一预设规则。S220. Configure a first preset rule based on the first neural network calculation type.
本实施例中,第一预设规则是指适用于第一神经网络计算类型对应的数据传输及计算的规则。一实施例中,第一预设规则是指按照一定方式对需要传输给芯片上的计算模块的待计算数据进行数据处理的规则。在本实施例中,第一预设规则为根据计算模块需要的顺序对第一待计算数据进行存储,以将第一待计算数据按照计算模块需要的顺序发送至计算模块中,提供数据给计算模块进行第一层运算的规则。一实施例中,在神经网络模型开始计算前,将不同神经网络计算类型对应的预设规则提前配置好,当神经网络模型开始计算时,根据配置好的神经网络计算类型和预设规则的关联关系,以及第一待计算数据中的第一神经网络计算类型,配置第一预设规则。In this embodiment, the first preset rule refers to a rule applicable to data transmission and calculation corresponding to the first neural network calculation type. In one embodiment, the first preset rule refers to a rule for performing data processing on the data to be calculated that needs to be transmitted to the computing module on the chip in a certain manner. In this embodiment, the first preset rule is to store the first data to be calculated according to the order required by the calculation module, so as to send the first data to be calculated to the calculation module in the order required by the calculation module, and provide the data to the calculation module The rules for the module to perform first-level operations. In one embodiment, before the neural network model starts to calculate, preset rules corresponding to different neural network calculation types are configured in advance. When the neural network model starts to calculate, according to the relationship between the configured neural network calculation types and the preset rules relationship, and the first neural network calculation type in the first data to be calculated, configure the first preset rule.
S230、基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算。S230. Store the first data to be calculated based on the first preset rule, so that the first data to be calculated is sent to the data stream network in the order of the first data matching the calculation type of the first neural network The calculation module in the calculation.
一实施例中,计算模块根据第一预设规则在神经网络模型的第一层进行数据的计算。In one embodiment, the calculation module performs data calculation on the first layer of the neural network model according to the first preset rule.
在本实施例中,通过确定第一待计算数据的神经网络计算类型,并针对不同的神经网络计算类型配置预设规则,基于配置的预设规则对第一待计算数据进行存储,以供计算模块对第一待计算数据进行计算,计算模块并没有局限于针对一种神经网络计算类型进行计算。其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。In this embodiment, by determining the neural network calculation type of the first data to be calculated, and configuring preset rules for different neural network calculation types, the first data to be calculated is stored based on the configured preset rules for calculation. The module calculates the first data to be calculated, and the calculation module is not limited to calculating for one type of neural network calculation. Wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
在S230中,第一预设规则包括预设存储规则和预设计算规则,S230包括:基于所述预设存储规则对所述第一待计算数据进行存储。在S230之后还包括:将所述预设计算规则传输到所述计算模块,以供所述计算模块根据所述预设计算规则对所述第一待计算数据进行计算。In S230, the first preset rule includes a preset storage rule and a preset calculation rule, and S230 includes: storing the first data to be calculated based on the preset storage rule. After S230, the method further includes: transmitting the preset calculation rule to the calculation module, so that the calculation module can calculate the first data to be calculated according to the preset calculation rule.
本实施例中,预设存储规则是指按一定顺序将数据排序的规则。例如,预设存储规则为将所述第一待计算数据按照所述第一数据顺序进行存储的规则。一实施例中,数据存储的排序根据计算模块进行数据计算的顺序确定,提前将数据排序,能提高计算模块的计算效率。一实施例中,预设存储规则可以是对不同数据的排序,例如数据、权重和偏执等;也可以是对同一数据的排序,例 如图片的像素大小或红蓝黄三种颜色,本文不作限制。预设计算规则是指计算模块计算数据的规则。例如,预设计算规则为按照所述第一神经网络计算类型进行计算的规则。一实施例中,预设计算规则为按顺序拉取数据进行计算。In this embodiment, the preset storage rule refers to a rule for sorting data in a certain order. For example, the preset storage rule is a rule for storing the first data to be calculated according to the order of the first data. In one embodiment, the order of data storage is determined according to the order in which the computing module performs data computing, and the data is ordered in advance, which can improve the computing efficiency of the computing module. In one embodiment, the preset storage rule may be the sorting of different data, such as data, weight, and paranoia; it may also be the sorting of the same data, such as the pixel size of the picture or the three colors of red, blue, and yellow, which are not limited herein. . The preset calculation rule refers to the rule by which the calculation module calculates data. For example, the preset calculation rule is a rule for calculation according to the first neural network calculation type. In one embodiment, the preset calculation rule is to pull data in sequence for calculation.
本实施例中,基于所述预设存储规则对所述第一待计算数据进行存储包括:基于所述预设存储规则将所述第一待计算数据按照所述第一数据顺序存储到片内存储器,以通过所述片内存储器将所述第一待计算数据按照所述第一数据顺序排序后,将排序后的第一待计算数据传输到所述计算模块。In this embodiment, storing the first data to be calculated based on the preset storage rule includes: storing the first data to be calculated in the on-chip in the order of the first data based on the preset storage rule and a memory, so as to transmit the sorted first data to be calculated to the calculation module after sorting the first data to be calculated according to the order of the first data through the on-chip memory.
在本步骤中,对于神经网络模型中需要计算的第一待计算数据,不需要针对第一待计算数据的神经网络计算类型进行数据的识别以传输到不同片内存储器中。所有的神经网络计算类型都传输到同一片内存储器后,并按照神经网络计算类型的运算顺序对数据排好序后,再配置神经网络计算类型的预设规则,能够减少芯片上的布置空间,以及提高数据存储的灵活性。In this step, for the first data to be calculated that needs to be calculated in the neural network model, it is not necessary to identify the neural network calculation type of the first data to be calculated to transmit the data to different on-chip memories. After all neural network calculation types are transferred to the same on-chip memory, and the data is sorted according to the operation sequence of the neural network calculation type, the preset rules of the neural network calculation type are configured, which can reduce the layout space on the chip. As well as increasing the flexibility of data storage.
S240、获取神经网络的第二层的第二待计算数据和第二待计算数据对应的第二神经网络计算类型。S240. Acquire the second data to be calculated of the second layer of the neural network and the second neural network calculation type corresponding to the second data to be calculated.
本实施例中,神经网络的第二层是指神经网络的第一层的下一层。第二待计算数据是指在神经网络的第二层中进行计算的数据。第二神经网络计算类型是指第二待计算数据的神经网络计算类型。一实施例中,第二神经网络计算类型可为前馈神经网络、径向基神经网络、深度前馈神经网络或递归神经网络等,本文对于第二神经网络计算类型不作限制。In this embodiment, the second layer of the neural network refers to the next layer of the first layer of the neural network. The second data to be calculated refers to data to be calculated in the second layer of the neural network. The second neural network calculation type refers to the neural network calculation type of the second data to be calculated. In one embodiment, the calculation type of the second neural network may be a feedforward neural network, a radial basis neural network, a deep feedforward neural network or a recurrent neural network, etc. The calculation type of the second neural network is not limited herein.
在本实施例中,第二待计算数据包括至少一种计算参数。一实施例中,计算参数包括kernel size、stride、channel和filter等,此处对于计算参数的类型不作限制。In this embodiment, the second data to be calculated includes at least one calculation parameter. In one embodiment, the calculation parameters include kernel size, stride, channel, filter, etc., and the types of the calculation parameters are not limited here.
S250、判断所述第一神经网络计算类型是否与所述第二神经网络计算类型相同。S250. Determine whether the calculation type of the first neural network is the same as the calculation type of the second neural network.
示例性的,如果第一神经网络计算类型是深度前馈神经网络,且第二神经网络计算类型也是深度前馈神经网络,则第一神经网络计算类型和第二神经网络计算类型相同。如果第一神经网络计算类型是深度前馈神经网络,且第二神经网络计算类型是递归神经网络,则第一神经网络计算类型和第二神经网络计算类型不相同。Exemplarily, if the first neural network calculation type is a deep feedforward neural network, and the second neural network calculation type is also a deep feedforward neural network, the first neural network calculation type and the second neural network calculation type are the same. If the first neural network computation type is a deep feedforward neural network and the second neural network computation type is a recurrent neural network, the first neural network computation type and the second neural network computation type are not the same.
S260、响应于所述第一神经网络计算类型与所述第二神经网络计算类型相同的判断结果,基于所述第一预设规则对所述第二待计算数据进行存储。S260. In response to a judgment result that the first neural network calculation type is the same as the second neural network calculation type, store the second data to be calculated based on the first preset rule.
一实施例中,第一神经网络计算类型和第二神经网络计算类型相同,则第 一预设规则也适用于第二层的神经网络计算类型的计算,可以直接启动针对神经网络的第二层的数据计算,在神经网络的第二层中对第二待计算数据进行计算。In one embodiment, the calculation type of the first neural network is the same as the calculation type of the second neural network, the first preset rule is also applicable to the calculation of the neural network calculation type of the second layer, and the second layer of the neural network can be directly activated The second data to be calculated is calculated in the second layer of the neural network.
S270、响应于所述第一神经网络计算类型与所述第二神经网络计算类型不相同的判断结果,基于所述第二神经网络计算类型配置第二预设规则,基于所述第二预设规则对所述第二待计算数据进行存储。S270. In response to the judgment result that the first neural network calculation type is different from the second neural network calculation type, configure a second preset rule based on the second neural network calculation type, and based on the second preset The rule stores the second data to be calculated.
其中,按照所述第二预设规则存储的第二待计算数据,用于按照所述第二神经网络计算类型匹配的第二数据顺序,被发送给所述数据流网络中的计算模块进行计算。Wherein, the second data to be calculated stored according to the second preset rule is used to be sent to the calculation module in the data flow network for calculation according to the second data sequence matching the calculation type of the second neural network .
例如,基于所述第二神经网络计算类型配置第二预设规则,基于所述第二预设规则对所述第二待计算数据进行存储,以使所述第二待计算数据按照所述第二神经网络计算类型匹配的第二数据顺序发送给所述数据流网络中的计算模块进行计算。For example, a second preset rule is configured based on the second neural network calculation type, and the second data to be calculated is stored based on the second preset rule, so that the second data to be calculated is calculated according to the first The second data matching the calculation types of the two neural networks is sequentially sent to the calculation module in the data flow network for calculation.
本实施例中,第二预设规则是指适用于第二神经网络计算类型对应的数据传输及计算的规则。第二数据顺序是指跟第二神经网络计算类型的运算顺序映射的数据顺序。例如,当第二网络神经网络计算类型和第一神经网络计算类型不同时,例如卷积核大小不同时,所需要的数据顺序不同,因此当第一神经网络计算类型和第二神经网络计算类型不同时,需要将第二待计算数据按照第二神经网络计算类型对应的第二数据顺序在片内存储器存储,从而在流向计算模块时供计算模块进行计算。一实施例中,第二预设规则是指按照一定方式对需要传输给芯片上的计算模块的待计算数据进行数据处理的规则。在本实施例中,第二预设规则为根据计算模块需要的顺序对第二待计算数据进行存储,以将第二待计算数据按照计算模块需要的顺序发送至计算模块中,提供数据给计算模块进行第二层的运算的规则。In this embodiment, the second preset rule refers to a rule applicable to data transmission and calculation corresponding to the second neural network calculation type. The second data order refers to the data order mapped to the operation order of the second neural network calculation type. For example, when the calculation type of the second neural network is different from the calculation type of the first neural network, for example, when the size of the convolution kernel is different, the required data order is different, so when the calculation type of the first neural network and the calculation type of the second neural network are different At different times, the second data to be calculated needs to be stored in the on-chip memory in the order of the second data corresponding to the second neural network calculation type, so as to be used by the calculation module for calculation when flowing to the calculation module. In one embodiment, the second preset rule refers to a rule for performing data processing on the data to be calculated that needs to be transmitted to the computing module on the chip in a certain manner. In this embodiment, the second preset rule is to store the second data to be calculated according to the order required by the calculation module, so as to send the second data to be calculated to the calculation module in the order required by the calculation module, and provide the data to the calculation module. The rules for the module to perform the second-level operations.
在一代替实施例中,也可以不需要判断第二神经网络计算类型是否和第一神经网络计算类型相同。直接根据第二神经网络计算类型配置第二预设规则。如果第二神经网络计算类型和第一神经网络计算类型相同,则第二预设规则和第一预设规则也相同。In an alternative embodiment, it may not be necessary to determine whether the calculation type of the second neural network is the same as the calculation type of the first neural network. The second preset rule is configured directly according to the second neural network calculation type. If the calculation type of the second neural network is the same as the calculation type of the first neural network, the second preset rule and the first preset rule are also the same.
在另一代替实施例中,获取神经网络的第三层甚至是更多层的待计算数据,获取的待计算数据的层级需要根据神经网络的计算模型的层级数量确定。In another alternative embodiment, the data to be calculated of the third layer or even more layers of the neural network is acquired, and the level of the acquired data to be calculated needs to be determined according to the number of levels of the computational model of the neural network.
举例来说,当数据是图像数据时,在人工智能领域,一般都是用卷积网络来对图像数据进行处理。对于卷积网络来说,会有多个卷积层,而不同的卷积 层的卷积核大小,步长和滤波器等并不相同,即不同卷积层对应的神经网络计算类型不同。当图像数据进入第一个卷积层的开始处理时,先判断第一个卷积层的第一神经网络计算类型,然后根据图像数据的channel/width(宽度)/height特征,将以第一神经网络计算类型对应的第一预设规则将图像数据按照第一神经网络计算类型所需的运算顺序排好序,存储在片内存储器后,直接按照第一数据顺序的数据流发送给计算模块计算,当第一个卷积层计算完成时,输出第一个feature map(特征图)。进入第一个卷积层的图像数据也是一种特征图。当第一个feature map开始进入第二个卷积层进行处理时,先判断第二个卷积层的第二神经网络计算类型与第一神经网络计算类型是否相同,当第二个卷积层的第二神经网络计算类型与第一神经网络计算类型不相同时,根据第二待计算数据的channel/width/height特征,按照第二神经网络计算类型对应的第二预设规则将第一个feature map按照第二神经网络计算类型所需的运算顺序排好序存在片内存储器后,直接按照第二数据顺序的数据流发送给计算模块计算。以此类推,在卷积网络中对图像处理完成。For example, when the data is image data, in the field of artificial intelligence, convolutional networks are generally used to process image data. For a convolutional network, there will be multiple convolutional layers, and different convolutional layers have different convolution kernel sizes, step sizes and filters, that is, different convolutional layers correspond to different types of neural network computations. When the image data enters the start processing of the first convolutional layer, first determine the calculation type of the first neural network of the first convolutional layer, and then according to the channel/width (width)/height characteristics of the image data, the first The first preset rule corresponding to the neural network calculation type sorts the image data according to the operation sequence required by the first neural network calculation type, stores it in the on-chip memory, and directly sends the data stream in the first data sequence to the calculation module Calculate, when the first convolutional layer calculation is completed, output the first feature map (feature map). The image data entering the first convolutional layer is also a feature map. When the first feature map starts to enter the second convolutional layer for processing, first determine whether the second neural network calculation type of the second convolutional layer is the same as the first neural network calculation type. When the calculation type of the second neural network is different from the calculation type of the first neural network, according to the channel/width/height characteristics of the second data to be calculated, according to the second preset rule corresponding to the second neural network calculation type After the feature map is sorted according to the operation sequence required by the second neural network calculation type and stored in the on-chip memory, it is directly sent to the calculation module for calculation according to the data stream of the second data sequence. And so on, the image processing is done in the convolutional network.
可以理解的是,在神经网络计算类型不同时先将数据进行线性转换以满足计算模块的计算需要,既可以保证兼容数据流架构中,多个神经网络的不同特征的卷积的运算,也没有增加额外的时间消耗,保证了数据流架构的运算的高效以及灵活,可在数据流结构中满足多个神经网络的卷积运算。It is understandable that when the neural network calculation types are different, the data is linearly transformed to meet the calculation needs of the calculation module, which can ensure that the convolution operation of different features of multiple neural networks is compatible with the data flow architecture. Adding extra time consumption ensures the efficiency and flexibility of the operation of the data flow structure, and can satisfy the convolution operation of multiple neural networks in the data flow structure.
本申请实施例,通过获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;基于所述第一神经网络计算类型配置第一预设规则;基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算,在计算模块对第一待计算数据进行计算之后,获取神经网络的第二层的第二待计算数据和所述第二待计算数据对应的第二神经网络计算类型,通过判断第一神经网络计算类型是否与第二神经网络计算类型相同,确定针对第二层神经网络的数据存储方式。本实施例提供的神经网络计算,并没有局限于一类型的神经网络,而是通过神经网络计算类型配置预设规则,可应对相关技术中网络计算类型支持单一或不能够灵活支持多种类型网络的工况,将不同网络计算类型的数据按不同存储方式存储以达到对不同网络计算类型的数据进行计算的技术效果。此外,本申请实施例还能保持高计算效率。In this embodiment of the present application, the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset is configured based on the first neural network calculation type The first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network. The calculation module in the calculation module performs calculation, after the calculation module calculates the first to-be-calculated data, obtains the second to-be-calculated data of the second layer of the neural network and the second neural network calculation type corresponding to the second to-be-calculated data, By judging whether the calculation type of the first neural network is the same as the calculation type of the second neural network, the data storage mode for the second-layer neural network is determined. The neural network calculation provided in this embodiment is not limited to one type of neural network, but configures preset rules through the neural network calculation type, which can cope with the network calculation type in the related art that supports a single type or cannot flexibly support multiple types of networks The data of different network computing types are stored in different storage methods to achieve the technical effect of computing data of different network computing types. In addition, the embodiments of the present application can also maintain high computing efficiency.
本申请实施例通过获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;基于所述第一神经网络计算类型配置第一预设规则;基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算;其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动,可应对数据流架构的芯片支持多种神经网络计算类型时,需要通过补充数据和加大计算量的方式来实现,降低了芯片的计算效率的工况,实现了将数据流架构的不同网络计算类型的数据按不同存储方式存储以达到对不同网络计算类型的数据进行计算的效果。In this embodiment of the present application, the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset rule is configured based on the first neural network calculation type ; Based on the first preset rule, the first data to be calculated is stored, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network. The calculation module performs calculation; wherein, the first data to be calculated flows in the data flow network according to the preset data flow direction, and when the chip of the data flow architecture supports a variety of neural network calculation types, it is necessary to pass the supplementary data It is realized by increasing the amount of calculation, reducing the computing efficiency of the chip, and realizing the data flow architecture of different network computing types. Effect.
实施例三Embodiment 3
图3是本申请实施例三提供的一种数据存储装置的结构示意图,本实施例可适用于对不同神经网络计算类型的数据进行计算的场景,该装置可以采用软件和/或硬件的方式实现,并可集成在设备上。FIG. 3 is a schematic structural diagram of a data storage device provided in Embodiment 3 of the present application. This embodiment is applicable to a scenario in which data of different neural network calculation types is calculated, and the device can be implemented in software and/or hardware. , and can be integrated on the device.
如图3所示,本实施例提供的数据存储装置可以包括获取模块310、配置模块320和片上存储模块330,其中:获取模块310,设置为获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;配置模块320,设置为基于所述第一神经网络计算类型配置第一预设规则;片上存储模块330,设置为基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算;其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。As shown in FIG. 3 , the data storage device provided in this embodiment may include an acquisition module 310, a configuration module 320, and an on-chip storage module 330, wherein: the acquisition module 310 is configured to acquire the first data to be calculated of the first layer of the neural network the first neural network calculation type corresponding to the first data to be calculated; the configuration module 320 is configured to configure a first preset rule based on the first neural network calculation type; the on-chip storage module 330 is configured to be based on the first neural network calculation type. A preset rule stores the first data to be calculated, so that the first data to be calculated is sent to the calculation module in the data flow network for calculation according to the first data sequence matching the calculation type of the first neural network ; wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
参考图4,一实施例中,所述获取模块310,还设置为获取神经网络的第二层的第二待计算数据和所述第二待计算数据对应的第二神经网络计算类型。Referring to FIG. 4 , in one embodiment, the obtaining module 310 is further configured to obtain the second data to be calculated of the second layer of the neural network and the second neural network calculation type corresponding to the second data to be calculated.
所述装置还包括:判断模块340,所述判断模块340设置为判断所述第一神经网络计算类型是否与所述第二神经网络计算类型相同;The device further includes: a judgment module 340, the judgment module 340 is configured to judge whether the calculation type of the first neural network is the same as the calculation type of the second neural network;
所述片上存储模块330,还设置为响应于所述第一神经网络计算类型与所述第二神经网络计算类型相同的判断结果,基于所述第一预设规则对所述第二待计算数据进行存储;以及响应于所述第一神经网络计算类型与所述第二神经网络计算类型不相同的判断结果,基于所述第二神经网络计算类型配置第二预设规则,基于所述第二预设规则对所述第二待计算数据进行存储,其中,按照所述第二预设规则存储的第二待计算数据,用于按照所述第二神经网络计算类型 匹配的第二数据顺序,被发送给所述数据流网络中的计算模块进行计算。The on-chip storage module 330 is further configured to, in response to the judgment result that the first neural network calculation type is the same as the second neural network calculation type, perform the calculation on the second data to be calculated based on the first preset rule. storing; and in response to a judgment result that the first neural network calculation type is different from the second neural network calculation type, configure a second preset rule based on the second neural network calculation type, and configure a second preset rule based on the second neural network calculation type. The preset rule stores the second data to be calculated, wherein the second data to be calculated stored according to the second preset rule is used for the second data sequence matched according to the second neural network calculation type, It is sent to the calculation module in the data flow network for calculation.
一实施例中,所述第一预设规则包括预设存储规则和预设计算规则。In one embodiment, the first preset rule includes a preset storage rule and a preset calculation rule.
片上存储模块330包括:包括存储单元、发送单元;The on-chip storage module 330 includes: a storage unit and a sending unit;
存储单元,设置为基于所述预设存储规则对所述第一待计算数据进行存储,其中,所述预设存储规则为将所述第一待计算数据按照所述第一数据顺序进行存储的规则;发送单元,设置为将所述预设计算规则传输到所述计算模块,以供所述计算模块根据所述预设计算规则对所述第一待计算数据进行计算。A storage unit configured to store the first data to be calculated based on the preset storage rule, wherein the preset storage rule is to store the first data to be calculated in the order of the first data a rule; a sending unit configured to transmit the preset calculation rule to the calculation module, so that the calculation module can calculate the first data to be calculated according to the preset calculation rule.
其中,所述预设计算规则为按照所述第一神经网络计算类型进行计算的规则。Wherein, the preset calculation rule is a rule for calculation according to the first neural network calculation type.
一实施例中,所述第一待计算数据包括至少一种计算参数,所述第二待计算数据包括至少一种计算参数。In one embodiment, the first data to be calculated includes at least one calculation parameter, and the second data to be calculated includes at least one calculation parameter.
一实施例中,所述计算参数包括:kernel size、stride、channel和filter中的至少一种。In one embodiment, the calculation parameters include: at least one of kernel size, stride, channel, and filter.
一实施例中,存储单元,还设置为基于所述预设存储规则将所述第一待计算数据按照所述第一数据顺序存储到片内存储器,以通过所述片内存储器将所述第一待计算数据按照所述第一数据顺序排序后传输到所述计算模块。In one embodiment, the storage unit is further configured to store the first data to be calculated in the on-chip memory in the order of the first data based on the preset storage rule, so as to store the first data in the on-chip memory through the on-chip memory. After the data to be calculated is sorted according to the first data sequence, it is transmitted to the calculation module.
本申请实施例所提供的数据存储装置可执行本申请任意实施例所提供的数据存储方法,具备执行方法相应的功能模块和有益效果。本实施例中未描述的内容可以参考本申请任意方法实施例中的描述。The data storage device provided by the embodiment of the present application can execute the data storage method provided by any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method. For content not described in this embodiment, reference may be made to the description in any method embodiment of this application.
实施例四Embodiment 4
图5是本申请实施例四提供的一种设备的结构示意图。图5示出了适于用来实现本申请实施方式的示例性设备612的框图。图5显示的设备612仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。FIG. 5 is a schematic structural diagram of a device provided in Embodiment 4 of the present application. FIG. 5 shows a block diagram of an exemplary apparatus 612 suitable for implementing embodiments of the present application. The device 612 shown in FIG. 5 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present application.
如图5所示,设备612以通用设备的形式表现。设备612的组件可以包括但不限于:一个或者多个处理器616,存储装置628,连接不同系统组件的总线618,系统组件例如包括存储装置628和处理器616。As shown in FIG. 5, device 612 takes the form of a generic device. Components of device 612 may include, but are not limited to, one or more processors 616 , storage 628 , and bus 618 connecting various system components, such as storage 628 and processor 616 .
总线618表示几类总线结构中的一种或多种,包括存储装置总线或者存储装置控制器,外围总线,图形加速端口,处理器或者使用多种总线结构中的任意总线结构的局域总线。举例来说,这些体系结构包括但不限于工业标准体系结构(Industry Standard Architecture,ISA)总线,微通道体系结构(Micro Channel Architecture,MCA)总线,增强型ISA总线、视频电子标准协会(Video Electronics  Standards Association,VESA)局域总线以及外围组件互连(Peripheral Component Interconnect,PCI)总线。 Bus 618 represents one or more of several types of bus structures, including a storage device bus or storage device controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, enhanced ISA bus, Video Electronics Standards Association (Video Electronics Standards) Association, VESA) local bus and Peripheral Component Interconnect (PCI) bus.
一实施例中,设备612包括多种计算机系统可读介质。这些介质可以是任何能够被设备612访问的可用介质,包括易失性和非易失性介质,可移动的和不可移动的介质。In one embodiment, device 612 includes various computer system readable media. These media can be any available media that can be accessed by device 612, including volatile and non-volatile media, removable and non-removable media.
存储装置628可以包括易失性存储器形式的计算机系统可读介质,例如随机存取存储器(Random Access Memory,RAM)630和/或高速缓存632。一实施例中,终端612可以包括其它可移动/不可移动的、易失性/非易失性计算机系统存储介质。仅作为举例,存储系统634可以用于读写不可移动的、非易失性磁介质,图5未显示,不可移动的、非易失性磁介质通常称为硬盘驱动器。尽管图5中未示出,可以提供用于对可移动非易失性磁盘例如软盘读写的磁盘驱动器,以及对可移动非易失性光盘,例如只读光盘(Compact Disc Read-Only Memory,CD-ROM),数字视盘(Digital Video Disc-Read Only Memory,DVD-ROM)或者其它光介质读写的光盘驱动器。在这些情况下,每个驱动器可以通过一个或者多个数据介质接口与总线618相连。存储装置628可以包括至少一个程序产品,该程序产品具有一组例如至少一个程序模块,这些程序模块被配置以执行本申请实施例的功能。 Storage 628 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 630 and/or cache 632 . In one embodiment, terminal 612 may include other removable/non-removable, volatile/non-volatile computer system storage media. For example only, storage system 634 may be used to read and write to non-removable, non-volatile magnetic media, not shown in FIG. 5, which are commonly referred to as hard disk drives. Although not shown in FIG. 5, a magnetic disk drive for reading and writing to removable non-volatile magnetic disks, such as floppy disks, and removable non-volatile optical disks, such as Compact Disc Read-Only Memory, may be provided. CD-ROM), Digital Video Disc (Digital Video Disc-Read Only Memory, DVD-ROM) or other optical media read and write optical disc drives. In these cases, each drive may be connected to bus 618 through one or more data media interfaces. The storage device 628 may include at least one program product having a set of, eg, at least one program module configured to perform the functions of the embodiments of the present application.
具有一组例如至少一个程序模块642的程序/实用工具640,可以存储在例如存储装置628中,这样的程序模块642包括但不限于操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或一种组合中可能包括网络环境的实现。程序模块642通常执行本申请所描述的实施例中的功能和/或方法。Program/utility 640 having, for example, a set of at least one program module 642, which may be stored, for example, in storage device 628, such program module 642 including, but not limited to, an operating system, one or more application programs, other program modules, and program data , each or a combination of these examples may include an implementation of a network environment. Program modules 642 generally perform the functions and/or methods of the embodiments described herein.
设备612也可以与一个或多个外部设备614通信,外部设备614例如键盘、指向终端、显示器624等,还可与一个或者多个使得用户能与该设备612交互的终端通信,和/或与使得该设备612能与一个或多个其它计算终端进行通信的任何终端(例如网卡,调制解调器等等)通信。这种通信可以通过输入/输出(Input/Output,I/O)接口622进行。并且,设备612还可以通过网络适配器620与一个或者多个网络通信,网络例如局域网(Local Area Network,LAN),广域网(Wide Area Network,WAN)和/或公共网络,公共网络例如因特网。如图5所示,网络适配器620通过总线618与设备612的其它模块通信。尽管图中未示出,可以结合设备612使用其它硬件和/或软件模块,包括但不限于:微代码、终端驱动器、冗余处理器、外部磁盘驱动阵列、磁盘阵列(Redundant Arrays of  Independent Disks,RAID)系统、磁带驱动器以及数据备份存储系统等。 Device 612 may also communicate with one or more external devices 614, such as a keyboard, pointing terminal, display 624, etc., and one or more terminals that enable a user to interact with the device 612, and/or with Any terminal (eg, network card, modem, etc.) that enables the device 612 to communicate with one or more other computing terminals. Such communication may take place through an input/output (I/O) interface 622 . Also, the device 612 may communicate with one or more networks, such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through a network adapter 620. As shown in FIG. 5 , network adapter 620 communicates with other modules of device 612 via bus 618 . Although not shown, other hardware and/or software modules may be used in conjunction with device 612, including but not limited to: microcode, terminal drivers, redundant processors, external disk drive arrays, Redundant Arrays of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
处理器616通过运行存储在存储装置628中的程序,从而执行多种功能应用以及数据处理,例如实现本申请任意实施例所提供的一种数据存储方法,该方法可以包括:获取神经网络的第一层的第一待计算数据和第一待计算数据对应的第一神经网络计算类型;基于所述第一神经网络计算类型配置第一预设规则;基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算;其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。The processor 616 executes a variety of functional applications and data processing by running the programs stored in the storage device 628, for example, implementing a data storage method provided by any embodiment of the present application, the method may include: obtaining the first data of the neural network. The first data to be calculated in one layer and the first neural network calculation type corresponding to the first data to be calculated; configure a first preset rule based on the first neural network calculation type; based on the first preset rule The first data to be calculated is stored, so that the first data to be calculated is sent to the calculation module in the data flow network for calculation according to the first data sequence matching the calculation type of the first neural network; wherein, the first The data to be calculated flows in the data flow network according to a preset data flow direction.
本申请实施例,通过获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;基于所述第一神经网络计算类型配置第一预设规则;基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算,其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。本实施例提供的神经网络计算,并没有局限于一种计算类型的神经网络,而是通过神经网络计算类型配置预设规则,可应对相关技术中网络计算类型单一或不能够灵活支持多种类型网络的工况,将不同网络计算类型的数据按不同存储方式存储以达到对数据流架构的不同网络计算类型的数据进行计算的技术效果。此外,本申请实施例还能保持高计算效率。In this embodiment of the present application, the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset is configured based on the first neural network calculation type The first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network. The calculation module in the device performs calculation, wherein the first data to be calculated flows in the data flow network according to a preset data flow direction. The neural network calculation provided in this embodiment is not limited to one type of neural network, but the preset rules are configured through the neural network calculation type, which can cope with the single type of network calculation in the related art or the inability to flexibly support multiple types. In the working condition of the network, the data of different network computing types are stored in different storage methods to achieve the technical effect of computing the data of different network computing types in the data flow architecture. In addition, the embodiments of the present application can also maintain high computing efficiency.
本申请实施例还提供了一种系统,包括:配置装置、直接内存存取(Direct Memory Access,DMA)装置、外部存储装置和片上存储装置。其中,配置装置可以是处理器;外部存储装置可以是双倍速率(Double Data Rate,DDR)内存;DMA装置连接外部存储装置与片上存储装置,DMA装置由配置装置控制;DMA装置根据处理器配置,将外部存储装置中的数据搬到片上存储装置,片上存储装置根据处理器配置方式存储数据。当DMA装置被处理器执行,使得DMA装置按处理器配置将外部存储装置的数据传输到片上存储装置,当片上存储装置被处理器配置,使得片上存储装置将DMA装置传输来的数据按处理器配置方式存储在片上存储,实现本申请任意实施例提供的数据存储方法。An embodiment of the present application further provides a system, including: a configuration device, a direct memory access (Direct Memory Access, DMA) device, an external storage device, and an on-chip storage device. The configuration device can be a processor; the external storage device can be a double-rate (Double Data Rate, DDR) memory; the DMA device connects the external storage device and the on-chip storage device, and the DMA device is controlled by the configuration device; the DMA device is configured according to the processor , the data in the external storage device is moved to the on-chip storage device, and the on-chip storage device stores the data according to the processor configuration. When the DMA device is executed by the processor, the DMA device transfers the data from the external storage device to the on-chip storage device according to the processor configuration, and when the on-chip storage device is configured by the processor, the on-chip storage device transfers the data from the DMA device to the on-chip storage device according to the processor configuration. The configuration mode is stored in on-chip storage, and implements the data storage method provided by any embodiment of the present application.
外部存储装置可记为片外存储器,片上存储装置可记为片内存储器。External storage devices may be referred to as off-chip memory, and on-chip storage devices may be referred to as on-chip memory.
实施例五Embodiment 5
本申请实施例五还提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,该程序被处理器执行时实现如本申请任意实施例所提供的一种数据存储方法,该方法可以包括:获取神经网络的第一层的第一待计算数据和第一待计算数据对应的第一神经网络计算类型;基于所述第一神经网络计算类型配置第一预设规则;基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算;其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。Embodiment 5 of the present application further provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the program is executed by a processor, implements a data storage method as provided in any embodiment of the present application, the The method may include: acquiring first data to be calculated in the first layer of the neural network and a first neural network calculation type corresponding to the first data to be calculated; configuring a first preset rule based on the first neural network calculation type; The first preset rule stores the first data to be calculated, so that the first data to be calculated is sent to the calculation module in the data flow network according to the first data sequence matching the calculation type of the first neural network Calculate; wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
本申请实施例的计算机可读存储介质,可以采用一个或多个计算机可读的介质的任意组合。计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、RAM、只读存储器(Read-Only Memory,ROM)、可擦式可编程只读存储器(Erasable Programmable Read-Only Memory,EPROM或闪存)、光纤、CD-ROM、光存储器件、磁存储器件、或者上述的任意合适的组合。在本文件中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。The computer-readable storage medium of the embodiments of the present application may adopt any combination of one or more computer-readable mediums. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. Examples (non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, RAM, Read-Only Memory (ROM), erasable Erasable Programmable Read-Only Memory (EPROM or flash memory), optical fiber, CD-ROM, optical storage device, magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,计算机可读的信号介质中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied in the computer-readable signal medium. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device .
存储介质上包含的程序代码可以用任何适当的介质传输,包括——但不限于无线、电线、光缆、射频(Radio Frequency,RF)等等,或者上述的任意合适的组合。The program code contained on the storage medium can be transmitted by any suitable medium, including - but not limited to wireless, wire, optical fiber cable, radio frequency (RF), etc., or any suitable combination of the above.
可以以一种或多种程序设计语言或其组合来编写用于执行本申请操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机 上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或终端上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括LAN或WAN—连接到用户计算机,或者,可以连接到外部计算机,例如利用因特网服务提供商来通过因特网连接到外部计算机。Computer program code for performing the operations of the present application may be written in one or more programming languages, including object-oriented programming languages—such as Java, Smalltalk, C++, but also conventional Procedural programming language - such as the "C" language or similar programming language. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or terminal. Where a remote computer is involved, the remote computer may be connected to the user's computer through any kind of network, including a LAN or WAN, or may be connected to an external computer, such as through the Internet using an Internet service provider.
本申请实施例,通过获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;基于所述第一神经网络计算类型配置第一预设规则;基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算,其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。本实施例提供的神经网络计算,并没有局限于一类型的神经网络,而是通过神经网络计算类型配置预设规则,可应对相关技术中网络计算类型单一或不能够灵活支持多种类型网络的工况,将不同网络计算类型的数据按不同存储方式存储以达到对数据流架构的不同网络计算类型的数据进行计算的技术效果。此外,本申请实施例还能保持高计算效率。In this embodiment of the present application, the first data to be calculated in the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated are obtained; the first preset is configured based on the first neural network calculation type The first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data flow network in the order of the first data matching the calculation type of the first neural network. The calculation module in the device performs calculation, wherein the first data to be calculated flows in the data flow network according to a preset data flow direction. The neural network calculation provided in this embodiment is not limited to one type of neural network, but configures preset rules through the neural network calculation type, which can cope with the related art where the network calculation type is single or cannot flexibly support multiple types of networks. Working conditions, the data of different network computing types are stored in different storage methods to achieve the technical effect of computing the data of different network computing types in the data flow architecture. In addition, the embodiments of the present application can also maintain high computing efficiency.
本申请实施例还提供了一种处理器可配置存储排布的存储介质,存储介质中可以将外部存储数据按不同排布顺序存储,该数据被处理器通过DMA装置传输至存储装置执行时实现本申请任意实施例提供的数据存储方法。The embodiment of the present application also provides a storage medium with a processor-configurable storage arrangement, in which external storage data can be stored in different arrangement sequences, and the data is transmitted by the processor through the DMA device to the storage device for execution. The data storage method provided by any embodiment of the present application.

Claims (14)

  1. 一种数据存储方法,包括:A data storage method comprising:
    获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;Obtain the first data to be calculated of the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated;
    基于所述第一神经网络计算类型配置第一预设规则;Configure a first preset rule based on the first neural network calculation type;
    基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算;其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。The first data to be calculated is stored based on the first preset rule, so that the first data to be calculated is sent to the data stream network in the order of the first data matching the calculation type of the first neural network. The calculation module performs calculation; wherein, the first data to be calculated flows in the data flow network according to a preset data flow direction.
  2. 如权利要求1所述的方法,在所述基于所述第一预设规则对所述第一待计算数据进行存储之后,还包括:The method according to claim 1, after storing the first data to be calculated based on the first preset rule, further comprising:
    获取神经网络的第二层的第二待计算数据和所述第二待计算数据对应的第二神经网络计算类型;Obtain the second data to be calculated of the second layer of the neural network and the second neural network calculation type corresponding to the second data to be calculated;
    判断所述第一神经网络计算类型是否与所述第二神经网络计算类型相同;judging whether the calculation type of the first neural network is the same as the calculation type of the second neural network;
    响应于所述第一神经网络计算类型与所述第二神经网络计算类型相同的判断结果,基于所述第一预设规则对所述第二待计算数据进行存储;In response to the judgment result that the calculation type of the first neural network is the same as the calculation type of the second neural network, the second data to be calculated is stored based on the first preset rule;
    响应于所述第一神经网络计算类型与所述第二神经网络计算类型不相同的判断结果,基于所述第二神经网络计算类型配置第二预设规则,基于所述第二预设规则对所述第二待计算数据进行存储,其中,按照所述第二预设规则存储的第二待计算数据,用于按照所述第二神经网络计算类型匹配的第二数据顺序,被发送给所述数据流网络中的计算模块进行计算。In response to the judgment result that the calculation type of the first neural network is different from the calculation type of the second neural network, a second preset rule is configured based on the calculation type of the second neural network, and based on the second preset rule The second data to be calculated is stored, wherein the second data to be calculated stored according to the second preset rule is used for the second data sequence matching the calculation type of the second neural network to be sent to the The calculation module in the data flow network described above performs the calculation.
  3. 如权利要求1或2所述的方法,其中,所述第一预设规则包括预设存储规则和预设计算规则;The method according to claim 1 or 2, wherein the first preset rule includes a preset storage rule and a preset calculation rule;
    所述基于所述第一预设规则对所述第一待计算数据进行存储,包括:The storing the first data to be calculated based on the first preset rule includes:
    基于所述预设存储规则对所述第一待计算数据进行存储,其中,所述预设存储规则为将所述第一待计算数据按照所述第一数据顺序进行存储的规则;The first data to be calculated is stored based on the preset storage rule, wherein the preset storage rule is a rule for storing the first data to be calculated in the order of the first data;
    在所述基于所述第一神经网络计算类型配置第一预设规则之后,所述方法还包括:After the first preset rule is configured based on the first neural network calculation type, the method further includes:
    将所述预设计算规则传输到计算模块,以供所述计算模块根据所述预设计算规则对所述第一待计算数据进行计算。The preset calculation rule is transmitted to a calculation module for the calculation module to calculate the first data to be calculated according to the preset calculation rule.
  4. 如权利要求2所述的方法,其中,所述第一待计算数据包括至少一种计算参数,所述第二待计算数据包括至少一种计算参数。The method of claim 2, wherein the first data to be calculated includes at least one calculation parameter, and the second data to be calculated includes at least one calculation parameter.
  5. 如权利要求4所述的方法,其中,所述计算参数包括:卷积核大小kernel  size、步长stride、卷积核通道channel和滤波器filter中的至少一种。The method of claim 4, wherein the calculation parameters include at least one of: convolution kernel size kernel size, stride stride, convolution kernel channel channel and filter filter.
  6. 如权利要求3所述的方法,其中,所述基于所述预设存储规则对所述第一待计算数据进行存储,包括:The method of claim 3, wherein the storing the first data to be calculated based on the preset storage rule comprises:
    基于所述预设存储规则将所述第一待计算数据按照所述第一数据顺序存储到片内存储器,以通过所述片内存储器将所述第一待计算数据按照所述第一数据顺序排序后,将排序后的第一待计算数据传输到所述计算模块。The first data to be calculated is stored in the on-chip memory in the order of the first data based on the preset storage rule, so that the first data to be calculated is stored in the on-chip memory in the order of the first data After sorting, the sorted first data to be calculated is transmitted to the calculation module.
  7. 一种数据存储装置,包括:A data storage device, comprising:
    获取模块,设置为获取神经网络的第一层的第一待计算数据和所述第一待计算数据对应的第一神经网络计算类型;an acquisition module, configured to acquire the first data to be calculated of the first layer of the neural network and the first neural network calculation type corresponding to the first data to be calculated;
    配置模块,设置为基于所述第一神经网络计算类型配置第一预设规则;a configuration module, configured to configure a first preset rule based on the first neural network calculation type;
    片上存储模块,设置为基于所述第一预设规则对所述第一待计算数据进行存储,以使所述第一待计算数据按照所述第一神经网络计算类型匹配的第一数据顺序发送给数据流网络中的计算模块进行计算;An on-chip storage module, configured to store the first data to be calculated based on the first preset rule, so that the first data to be calculated is sent in the order of the first data matching the calculation type of the first neural network Perform calculations for the calculation modules in the data flow network;
    其中,所述第一待计算数据按照预设的数据流向在所述数据流网络中流动。The first data to be calculated flows in the data flow network according to a preset data flow direction.
  8. 如权利要求7所述的装置,其中,所述获取模块,还设置为获取神经网络的第二层的第二待计算数据和所述第二待计算数据对应的第二神经网络计算类型;The device according to claim 7, wherein the obtaining module is further configured to obtain the second data to be calculated of the second layer of the neural network and the second neural network calculation type corresponding to the second data to be calculated;
    所述装置还包括:判断模块,所述判断模块设置为判断所述第一神经网络计算类型是否与所述第二神经网络计算类型相同;The device further includes: a judgment module, the judgment module is configured to judge whether the calculation type of the first neural network is the same as the calculation type of the second neural network;
    所述片上存储模块,还设置为响应于所述第一神经网络计算类型与所述第二神经网络计算类型相同的判断结果,基于所述第一预设规则对所述第二待计算数据进行存储;以及响应于所述第一神经网络计算类型与所述第二神经网络计算类型不相同的判断结果,基于所述第二神经网络计算类型配置第二预设规则,基于所述第二预设规则对所述第二待计算数据进行存储,其中,按照所述第二预设规则存储的第二待计算数据,用于按照所述第二神经网络计算类型匹配的第二数据顺序,被发送给所述数据流网络中的计算模块进行计算。The on-chip storage module is further configured to, in response to a judgment result that the calculation type of the first neural network is the same as the calculation type of the second neural network, perform a calculation on the second data to be calculated based on the first preset rule. storing; and in response to a judgment result that the first neural network calculation type is different from the second neural network calculation type, configure a second preset rule based on the second neural network calculation type, and based on the second preset Set the rules to store the second data to be calculated, wherein the second data to be calculated stored according to the second preset rule is used for the second data sequence matched according to the second neural network calculation type, is It is sent to the calculation module in the data flow network for calculation.
  9. 如权利要求7或8所述的装置,其中,所述第一预设规则包括预设存储规则和预设计算规则;The apparatus according to claim 7 or 8, wherein the first preset rule includes a preset storage rule and a preset calculation rule;
    所述片上存储模块包括存储单元、发送单元;The on-chip storage module includes a storage unit and a sending unit;
    所述存储单元,设置为基于所述预设存储规则对所述第一待计算数据进行存储,其中,所述预设存储规则为将所述第一待计算数据按照所述第一数据顺序进行存储的规则;The storage unit is configured to store the first data to be calculated based on the preset storage rule, wherein the preset storage rule is to store the first data to be calculated in the order of the first data storage rules;
    所述发送单元,设置为将所述预设计算规则传输到计算模块,以供所述计算模块根据所述预设计算规则对所述第一待计算数据进行计算。The sending unit is configured to transmit the preset calculation rule to a calculation module, so that the calculation module can calculate the first data to be calculated according to the preset calculation rule.
  10. 如权利要求8所述的装置,其中,所述第一待计算数据包括至少一种计算参数,所述第二待计算数据包括至少一种计算参数。The apparatus of claim 8, wherein the first data to be calculated includes at least one calculation parameter, and the second data to be calculated includes at least one calculation parameter.
  11. 如权利要求10所述的装置,其中,所述计算参数包括:卷积核大小kernel size、步长stride、卷积核通道channel和滤波器filter中的至少一种。The apparatus of claim 10, wherein the calculation parameters include at least one of: a convolution kernel size kernel size, a stride stride, a convolution kernel channel channel, and a filter filter.
  12. 如权利要求9所述的装置,其中,所述存储单元,还设置为基于所述预设存储规则将所述第一待计算数据按照所述第一数据顺序存储到片内存储器,以通过所述片内存储器将所述第一待计算数据按照所述第一数据顺序排序后,将排序后的第一待计算数据传输到所述计算模块。The apparatus according to claim 9, wherein the storage unit is further configured to store the first data to be calculated in the on-chip memory in the order of the first data based on the preset storage rule, so as to pass the After the on-chip memory sorts the first data to be calculated according to the order of the first data, the sorted first data to be calculated is transmitted to the calculation module.
  13. 一种设备,包括:A device comprising:
    至少一个处理器;at least one processor;
    存储装置,设置为存储至少一个程序;a storage device configured to store at least one program;
    当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现如权利要求1-6中任一项所述的数据存储方法。When the at least one program is executed by the at least one processor, the at least one processor is caused to implement the data storage method according to any one of claims 1-6.
  14. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1-6中任一项所述的数据存储方法。A computer-readable storage medium storing a computer program, when the computer program is executed by a processor, implements the data storage method according to any one of claims 1-6.
PCT/CN2021/106394 2020-08-03 2021-07-15 Data storage method and apparatus, and device and storage medium WO2022028224A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010764719.8A CN111737193B (en) 2020-08-03 2020-08-03 Data storage method, device, equipment and storage medium
CN202010764719.8 2020-08-03

Publications (1)

Publication Number Publication Date
WO2022028224A1 true WO2022028224A1 (en) 2022-02-10

Family

ID=72657002

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/106394 WO2022028224A1 (en) 2020-08-03 2021-07-15 Data storage method and apparatus, and device and storage medium

Country Status (2)

Country Link
CN (1) CN111737193B (en)
WO (1) WO2022028224A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111737193B (en) * 2020-08-03 2020-12-08 深圳鲲云信息科技有限公司 Data storage method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180129933A1 (en) * 2016-11-10 2018-05-10 Beijing Baidu Netcom Science And Technology Co., Ltd. Method and Apparatus for Processing Data Sequence
CN109799977A (en) * 2019-01-25 2019-05-24 西安电子科技大学 The method and system of instruction repertorie exploitation scheduling data
CN110046704A (en) * 2019-04-09 2019-07-23 深圳鲲云信息科技有限公司 Depth network accelerating method, device, equipment and storage medium based on data flow
CN110717574A (en) * 2018-07-11 2020-01-21 杭州海康威视数字技术股份有限公司 Neural network operation method and device and heterogeneous intelligent chip
CN111260019A (en) * 2020-02-18 2020-06-09 深圳鲲云信息科技有限公司 Data processing method, device and equipment of neural network model and storage medium
CN111737193A (en) * 2020-08-03 2020-10-02 深圳鲲云信息科技有限公司 Data storage method, device, equipment and storage medium

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10762894B2 (en) * 2015-03-27 2020-09-01 Google Llc Convolutional neural networks
US10049322B2 (en) * 2015-05-21 2018-08-14 Google Llc Prefetching weights for use in a neural network processor
CN109360154B (en) * 2018-10-29 2022-09-20 厦门美图之家科技有限公司 Convolutional neural network generation method and super-resolution method of image
CN109740508B (en) * 2018-12-29 2021-07-23 北京灵汐科技有限公司 Image processing method based on neural network system and neural network system
CN110782015A (en) * 2019-10-25 2020-02-11 腾讯科技(深圳)有限公司 Training method and device for network structure optimizer of neural network and storage medium
CN111091183B (en) * 2019-12-17 2023-06-13 深圳鲲云信息科技有限公司 Neural network acceleration system and method
CN111309265B (en) * 2020-02-18 2023-06-13 深圳鲲云信息科技有限公司 Node storage method, system, server and storage medium based on neural network

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180129933A1 (en) * 2016-11-10 2018-05-10 Beijing Baidu Netcom Science And Technology Co., Ltd. Method and Apparatus for Processing Data Sequence
CN110717574A (en) * 2018-07-11 2020-01-21 杭州海康威视数字技术股份有限公司 Neural network operation method and device and heterogeneous intelligent chip
CN109799977A (en) * 2019-01-25 2019-05-24 西安电子科技大学 The method and system of instruction repertorie exploitation scheduling data
CN110046704A (en) * 2019-04-09 2019-07-23 深圳鲲云信息科技有限公司 Depth network accelerating method, device, equipment and storage medium based on data flow
CN111260019A (en) * 2020-02-18 2020-06-09 深圳鲲云信息科技有限公司 Data processing method, device and equipment of neural network model and storage medium
CN111737193A (en) * 2020-08-03 2020-10-02 深圳鲲云信息科技有限公司 Data storage method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111737193B (en) 2020-12-08
CN111737193A (en) 2020-10-02

Similar Documents

Publication Publication Date Title
US11775430B1 (en) Memory access for multiple circuit components
US11294599B1 (en) Registers for restricted memory
US11561833B1 (en) Allocation and placement of resources for network computation
WO2021259041A1 (en) Ai computational graph sorting method and apparatus, device, and storage medium
CN110825435B (en) Method and apparatus for processing data
WO2022028224A1 (en) Data storage method and apparatus, and device and storage medium
CN111651383B (en) Method and apparatus for data flow in a processor having a data flow manager
WO2022012563A1 (en) Neural network data processing method, apparatus and device, and storage medium
WO2021077281A1 (en) Method and device for adjusting deep learning framework, server, and storage medium
CN109558565B (en) Operation method, device and related product
CN109543835B (en) Operation method, device and related product
US11263517B1 (en) Flexible weight expansion
CN111966399A (en) Instruction processing method and device and related product
CN111488970A (en) Execution optimization method and device of neural network
CN111061507A (en) Operation method, operation device, computer equipment and storage medium
CN111353595A (en) Operation method, device and related product
WO2023115529A1 (en) Data processing method in chip, and chip
CN111290789B (en) Operation method, operation device, computer equipment and storage medium
CN111124497B (en) Operation method, operation device, computer equipment and storage medium
CN111339060B (en) Operation method, device, computer equipment and storage medium
CN111026440A (en) Operation method, operation device, computer equipment and storage medium
CN112394990A (en) Floating point to half precision floating point instruction processing device and method and related products
CN112394993A (en) Half-precision floating point to short shaping instruction processing device and method and related product
CN111338694A (en) Operation method, operation device, computer equipment and storage medium
CN111062483A (en) Operation method, operation device, computer equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21853188

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21853188

Country of ref document: EP

Kind code of ref document: A1