CN112884139A - Neural network data flow control method and device, electronic equipment and storage medium - Google Patents

Neural network data flow control method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112884139A
CN112884139A CN202011640067.3A CN202011640067A CN112884139A CN 112884139 A CN112884139 A CN 112884139A CN 202011640067 A CN202011640067 A CN 202011640067A CN 112884139 A CN112884139 A CN 112884139A
Authority
CN
China
Prior art keywords
neural network
calculation
module
control instruction
data flow
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011640067.3A
Other languages
Chinese (zh)
Inventor
王佳东
李远超
蔡权雄
牛昕宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Industry Research Kunyun Artificial Intelligence Research Institute Co ltd
Original Assignee
Shandong Industry Research Kunyun Artificial Intelligence Research Institute Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Industry Research Kunyun Artificial Intelligence Research Institute Co ltd filed Critical Shandong Industry Research Kunyun Artificial Intelligence Research Institute Co ltd
Priority to CN202011640067.3A priority Critical patent/CN112884139A/en
Publication of CN112884139A publication Critical patent/CN112884139A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30007Arrangements for executing specific machine instructions to perform operations on data operands
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3005Arrangements for executing specific machine instructions to perform operations for flow control
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Evolutionary Computation (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • Neurology (AREA)
  • Feedback Control In General (AREA)

Abstract

The embodiment of the invention provides a neural network data flow control method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a neural network data flow control instruction, wherein the neural network data flow control instruction comprises a data flow calculation direction control instruction, a first neural network control instruction and a second neural network control instruction, and the first neural network control instruction is used for controlling a first neural network calculation module; determining a calculation direction of a data stream between the first neural network calculation module and the second neural network calculation module according to the data stream calculation direction control instruction; and controlling the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction. The universality of the computing module is improved, and meanwhile the efficiency of the neural network data flow computing is improved.

Description

Neural network data flow control method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a neural network data flow control method and device, electronic equipment and a storage medium.
Background
The neural network is an artificial intelligence machine learning technology, especially the deep convolution neural network has received wide attention, and the deep convolution neural network has achieved some remarkable achievements in the fields of speech recognition, natural language processing and intelligent image processing, especially image recognition. However, the computation amount of the common network model reaches 10 hundred million orders, and the parameter amount reaches hundreds of million orders, so that no matter training or identification of the neural network model is performed, a high-performance GPU, a large-capacity storage device or a high-power server cluster is generally required to provide hardware architecture support for computation and storage.
The existing hardware architecture usually uses a CPU and a GPU for calculation, on one hand, the architecture uses an instruction set architecture, which must be supported by the instruction set, but the operations of instruction acquisition, decoding, and the like are unrelated to calculation, which reduces the efficiency of calculating a large amount of data in a neural network. On the other hand, each computing module of such a hardware architecture is independent from each other, the logical relationship between the modules is fixed, such as a module specially responsible for convolution operation, a module solely responsible for activating functions, and the like, each module independently computes and writes the computation result into on-chip or off-chip storage, and then other modules read data, and repeatedly accessing data stored on-chip or off-chip causes a lot of time consumption and affects performance, and the sequence between the modules cannot be changed, so that the flexibility is greatly limited, and the universality of the hardware computing module is low.
Disclosure of Invention
The embodiment of the invention provides a neural network data flow control method, which can improve the universality of hardware, thereby improving the efficiency of calculating the neural network data flow.
In a first aspect, an embodiment of the present invention provides a data flow control method for a neural network, including:
acquiring a neural network data flow control instruction, wherein the neural network data flow control instruction comprises a data flow calculation direction control instruction, a first neural network control instruction and a second neural network control instruction, the first neural network control instruction is used for controlling a first neural network calculation module, and the second neural network control instruction is used for controlling a second neural network calculation module;
determining a calculation direction of a data stream between the first neural network calculation module and the second neural network calculation module according to the data stream calculation direction control instruction;
and controlling the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction.
Optionally, the determining a computation direction of the data flow between the first neural network computation module and the second neural network computation module according to the data flow computation direction control instruction includes:
if the data flow calculation direction control instruction accords with a preset first calculation direction value, determining that the calculation direction is from the first neural network calculation module to the second neural network calculation module;
and if the data flow calculation direction control instruction conforms to a preset second calculation direction value, determining that the calculation direction is from the second neural network calculation module to the first neural network calculation module.
Optionally, the controlling, by the first neural network control instruction and the second neural network control instruction, the first neural network computation module and the second neural network computation module to perform data flow computation based on the computation direction includes:
if the calculation direction is from the first neural network calculation module to the second neural network calculation module, controlling the first neural network calculation module to perform data calculation according to the first neural network control instruction to obtain a first calculation result;
and controlling the second neural network calculation module to perform data flow calculation according to the second neural network control command based on the first calculation result to obtain a second calculation result.
Optionally, the controlling, by the first neural network control instruction and the second neural network control instruction, the first neural network computing module and the second neural network computing module to perform data flow computation based on the computation direction further includes:
if the calculation direction is from the second neural network calculation module to the first neural network calculation module, controlling the second neural network calculation module to perform data calculation according to the second neural network control instruction to obtain a first calculation result;
and controlling the first neural network computing module to perform data flow computation according to the first neural network control instruction based on the first computing result to obtain a second computing result.
Optionally, the neural network data flow control instruction further includes an output control instruction, and after the step of controlling the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction, the method further includes:
if the output control instruction accords with a preset output control value, directly outputting the first calculation result;
otherwise, outputting the second calculation result.
Optionally, the controlling, according to the first neural network control instruction, the first neural network computation module to perform data computation to obtain a first computation result includes:
if the first neural network control instruction accords with a preset first control value, acquiring data of the first neural network, and calculating by the first neural network calculation module to obtain the first calculation result;
otherwise, acquiring the data of the first neural network as the first calculation result.
Optionally, the controlling, based on the first calculation result, the second neural network calculation module to perform data flow calculation according to the second neural network control instruction, and obtaining a second calculation result includes:
if the second neural network control instruction accords with a preset second control value, acquiring data of the second neural network, and calculating the first calculation result and the data of the second neural network through a second neural network calculation module to obtain a second calculation result;
otherwise, the first calculation result is used as the second calculation result.
In a second aspect, an embodiment of the present invention provides a data flow control apparatus for a neural network, including:
the device comprises an acquisition module, a data flow control module and a data flow control module, wherein the acquisition module is used for acquiring a data flow control instruction of a neural network, the data flow control instruction of the neural network comprises a data flow calculation direction control instruction, a first neural network control instruction and a second neural network control instruction, the first neural network control instruction is used for controlling a first neural network calculation module, and the second neural network control instruction is used for controlling a second neural network calculation module;
a determining module for determining a calculation direction of a data stream between the first neural network calculation module and the second neural network calculation module according to the data stream calculation direction control instruction;
and the control module is used for controlling the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction.
In a third aspect, an embodiment of the present invention provides an electronic device, including: the device comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the steps in the neural network data flow control method provided by the embodiment of the invention.
In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps in the neural network data flow control method provided by the present invention.
In the embodiment of the invention, a neural network data flow control instruction is obtained, wherein the neural network data flow control instruction comprises a data flow calculation direction control instruction, a first neural network control instruction and a second neural network control instruction, the first neural network control instruction is used for controlling a first neural network calculation module, and the second neural network control instruction is used for controlling a second neural network calculation module; determining a calculation direction of a data stream between the first neural network calculation module and the second neural network calculation module according to the data stream calculation direction control instruction; and controlling the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction. Through different instructions in the obtained neural network data flow control instructions, the calculation direction of the neural network data flow between the first neural network calculation module and the second neural network calculation module can be conveniently controlled by using the data flow calculation direction control instructions, and the calculation and flow of the neural network data flow between the first neural network calculation module and the second neural network calculation module are controlled by using the first neural network control instructions and the second neural network control instructions, so that the universality of the calculation modules is improved, and the calculation efficiency of the neural network data flow is improved at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a data flow control method for a neural network according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for determining a computation direction according to an embodiment of the present invention;
fig. 3 is a flowchart of a data flow calculation control method according to an embodiment of the present invention;
FIG. 4 is a flow chart of a first calculation control method according to an embodiment of the present invention;
FIG. 5 is a flowchart of a second calculation control method according to an embodiment of the present invention;
fig. 6 is a flowchart of another data flow calculation control method according to an embodiment of the present invention;
FIG. 7 is a flow chart of another method for controlling data flow in a neural network according to an embodiment of the present invention;
FIG. 8 is a diagram illustrating a hardware architecture of a neural network data flow control according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a data flow control apparatus of a neural network according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart of a data flow control method of a neural network according to an embodiment of the present invention, as shown in fig. 1, including the following steps:
101. and acquiring a data flow control instruction of the neural network.
The neural network data flow control instruction comprises a data flow calculation direction control instruction, a first neural network control instruction and a second neural network control instruction, wherein the first neural network control instruction is used for controlling the first neural network calculation module, and the second neural network control instruction is used for controlling the second neural network calculation module.
In the embodiment of the present invention, the data flow control instruction of the neural network may be obtained through a command line entry of an operating system, or may be obtained through other visual interfaces such as GUI or WEB pages, so as to control the data calculation and data transmission processes of each layer of the neural network. The neural network data flow control instruction can be in a binary form or in other binary instruction forms, such as 1010 binary instructions and 10 decimal instructions, and can be segmented, each segment or each bit instruction represents different meanings, and an object controlled by the instruction can realize corresponding functions.
Further, the neural network data flow control command includes a data flow calculation direction control command, a first neural network control command, and a second neural network control command, and specifically, the data flow calculation direction control command may be used to control a direction of data calculation, that is, whether the calculation is from the first neural network calculation module to the second neural network calculation module, or vice versa, the calculation direction may be represented by the highest bit of the binary neural network data flow control command, for example, 0 may represent the calculation direction from the first neural network calculation module to the second neural network calculation module, and 1 may represent the calculation direction from the second neural network calculation module to the first neural network calculation module. Similarly, the first neural network control command may be represented by the next highest bit of the binary neural network data flow control command, and is used to control the enabling of the first neural network computing module, such as 1 for activating the first neural network computing module, and 0 for deactivating the first neural network computing module; the second neural network control command can be represented by the 3 rd bit of the binary neural network data flow control command, and is used for controlling the enabling of the second neural network computing module, for example, the second neural network computing module is activated by representing 1, and the second neural network computing module is closed by representing 0.
It should be noted that, the first neural network computing module and the second neural network computing module may be hardware computing modules corresponding to a certain layer or a certain operation of the neural network model, such as convolutional layer or pooling operation, sampling operation, and the like, the structures and functions of the two computing modules may be implemented by field programming, and specifically may be implemented by using an FPGA (field programmable logic array), according to the computation or operation to be implemented by each module, the corresponding computing units are selected by configuration field programming of the FPGA to be combined to implement the corresponding functions, when computing, the input data stream may start to compute without a waiting process for fetching and translating instructions, thereby saving computing time; when other neural network calculation or operation is carried out at the next time, new functions can be realized only by reselecting and combining the calculation units, so that the universality of the hardware calculation modules of the first neural network and the second neural network can be improved.
102. And determining the calculation direction of the data flow between the first neural network calculation module and the second neural network calculation module according to the data flow calculation direction control instruction.
Further, referring to fig. 2, fig. 2 is a flowchart of a method for determining a calculation direction according to an embodiment of the present invention, and as shown in fig. 2, the step 102 specifically includes:
1021. if the data flow calculation direction control instruction accords with a preset first calculation direction value, determining that the calculation direction is from the first neural network calculation module to the second neural network calculation module;
1022. and if the data flow calculation direction control instruction conforms to a preset second calculation direction value, determining that the calculation direction is from the second neural network calculation module to the first neural network calculation module.
In an embodiment of the present invention, the data flow calculation direction control command may be represented by a highest bit of the binary neural network data flow control command, and the preset first calculation direction value and the preset second calculation direction value are respectively a certain value of the highest bit of the binary neural network data flow control command, for example, 0 may be used as the preset first calculation direction value, 1 may be used as the preset second calculation direction value, and vice versa. Specifically, when the data flow calculation direction control command matches the preset first calculation direction value (e.g. 0), determining that the calculation direction of the neural network starts from the first neural network calculation module and ends at the second neural network calculation module; when the data flow calculation direction control command meets the preset second calculation direction value (such as 1), the calculation direction of the neural network is determined to start from the second neural network calculation module and end to the first neural network calculation module. That is, the sequence among the calculation modules is not fixed, and can be selected as required, for example, when the calculation of convolution first and pooling second is required, the first neural network calculation module can be configured as convolution calculation, the second neural network calculation module can be configured as pooling operation, and when the calculation of convolution first and pooling second is required, only the binary data stream calculation direction control instruction needs to be inverted, so that the flexibility of the neural network calculation module is greatly improved.
103. And controlling the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction.
Further, referring to fig. 3, fig. 3 is a flowchart of a data flow calculation control method according to an embodiment of the present invention, and as shown in fig. 3, the step 103 includes:
1031. and if the calculation direction is from the first neural network calculation module to the second neural network calculation module, controlling the first neural network calculation module to perform data calculation according to the first neural network control instruction to obtain a first calculation result.
In an embodiment of the present invention, when the data flow calculation direction control command matches the preset first calculation direction value, the calculation direction of the neural network is determined to start from the first neural network calculation module and end to the second neural network calculation module; firstly, controlling the first neural network computing module to call a corresponding hardware computing unit to perform data computation according to the first neural network control instruction, and outputting a first computing result; and controlling the second neural network calculation module to perform corresponding calculation by combining the first calculation result according to the second neural network control instruction.
Further, referring to fig. 4, fig. 4 is a flowchart of a first calculation control method according to an embodiment of the present invention, and as shown in fig. 4, the step 1031 includes:
10311. and if the first neural network control instruction accords with a preset first control value, acquiring data of the first neural network, and calculating by the first neural network calculation module to obtain a first calculation result.
In an embodiment of the present invention, the preset first control value may be a certain value (e.g. 1) of the first neural network control command; and when the first neural network control instruction is binary 1 of a preset first control value, activating a first neural network calculation module, acquiring the input data stream and the corresponding weight data of the first neural network, and performing corresponding calculation (such as convolution calculation) through a hardware calculation unit of the first neural network calculation module to obtain the first calculation result, wherein the first calculation result comprises first neural network output data.
10312 otherwise, acquiring the data of the first neural network as the first calculation result.
In an embodiment of the present invention, when the first neural network control instruction is not a preset first control value, if the first neural network control instruction is not a binary 1, the first neural network calculation module is turned off, and an input data stream is obtained as the first calculation result.
1032. And controlling a second neural network calculation module to perform data flow calculation according to a second neural network control command based on the first calculation result to obtain a second calculation result.
Further, referring to fig. 5, fig. 5 is a flowchart of a second calculation control method according to an embodiment of the present invention, and as shown in fig. 5, the step 1032 includes:
10321. if the second neural network control command accords with a preset second control value, acquiring data of a second neural network, and calculating the first calculation result and the data of the second neural network through a second neural network calculation module to obtain a second calculation result;
in an embodiment of the present invention, the preset second control value may be a certain value (e.g. 1) of the second neural network control command; and when the second neural network control command is binary 1 with a preset second control value, activating a second neural network calculation module, acquiring first neural network output data and weight data corresponding to the second neural network included in the first calculation result, and performing corresponding calculation (such as pooling calculation) through a hardware calculation unit of the second neural network calculation module to obtain the second calculation result, wherein the second calculation result includes second neural network output data.
10322. Otherwise, the first calculation result is used as a second calculation result.
In an embodiment of the present invention, when the second neural network control command is not a preset second control value, if the second neural network control command is not a binary 1, the second neural network calculation module is turned off, and an input data stream (i.e., the first neural network output data included in the first calculation result) is obtained as the second calculation result.
Further, referring to fig. 6, fig. 6 is a flowchart of another data flow calculation control method according to an embodiment of the present invention, and as shown in fig. 6, the step 103 further includes:
1033. and if the calculation direction is from the second neural network calculation module to the first neural network calculation module, controlling the second neural network calculation module to perform data calculation according to the second neural network control instruction to obtain a first calculation result.
In the embodiment of the present invention, when the data flow calculation direction control command matches the preset second calculation direction value, the calculation direction of the neural network is determined to start from the second neural network calculation module and end at the first neural network calculation module; then, controlling the second neural network computing module to call a corresponding hardware computing unit to perform data computation according to the second neural network control instruction, and outputting a first computing result; and controlling the first neural network computing module to perform corresponding computation according to the first neural network control instruction and by combining the first computing result.
Furthermore, if the second neural network control command meets a preset second control value, data of the second neural network are obtained, and a first calculation result is obtained after calculation is carried out by the second neural network calculation module. In an embodiment of the present invention, the preset second control value may be a certain value (e.g. 1) of the second neural network control command; and when the second neural network control command is binary 1 with a preset second control value, activating a second neural network calculation module, acquiring the input data stream and the weight data corresponding to the second neural network, and inputting the weight data into a hardware calculation unit of the second neural network calculation module to perform corresponding calculation (such as convolution calculation) so as to obtain the first calculation result, wherein the first calculation result comprises output data of the second neural network. Otherwise, when the second neural network control command is not the preset second control value, if not the binary 1, the second neural network calculation module is closed, and the input data stream of the second neural network is obtained as the first calculation result.
1034. And controlling the first neural network computing module to perform data flow computation according to the first neural network control instruction based on the first computing result to obtain a second computing result.
In the embodiment of the invention, if the first neural network control instruction conforms to the preset first control value, the input data of the first neural network is acquired, and the first calculation result is input into the first neural network calculation module together for calculation to obtain the second calculation result.
Specifically, the preset first control value may be a certain value (e.g. 1) of the first neural network control command; and when the first neural network control command is binary 1 with a preset first control value, activating a first neural network calculation module, acquiring second neural network output data and weight data corresponding to the first neural network included in the first calculation result, and inputting the second neural network output data and the weight data into a hardware calculation unit of the first neural network calculation module to perform corresponding calculation (such as pooling calculation) so as to obtain the second calculation result, wherein the second calculation result includes the first neural network output data. Otherwise, when the first neural network control command is not the preset first control value, if not the binary 1, the first neural network computation module is closed, and an input data stream (i.e., second neural network output data included in the first computation result) is obtained as the second computation result.
Further, the neural network data flow control instruction further includes an output control instruction, please refer to fig. 7, fig. 7 is a flowchart of another neural network data flow control method according to an embodiment of the present invention, as shown in fig. 7, after the step 103, the method further includes:
104. if the output control instruction accords with a preset output control value, directly outputting a first calculation result;
105. otherwise, outputting the second calculation result.
In an embodiment of the present invention, the output control instruction may be the lowest bit of the neural network data flow control instruction, such as the last 1 in the binary 0101, which may be used to control the output of the calculation result of the entire neural network data flow. Specifically, when the output control command conforms to a preset output control value, if 1, the first neural network output data or the second neural network output data in the first calculation result is directly output regardless of the calculation direction; when the output control command does not conform to the preset output control value, such as 0, the second calculation result of the first neural network calculation module or the second calculation result of the second neural network calculation module needs to be output.
In summary, according to the embodiments of the present invention, through different instructions in the obtained neural network data flow control instruction, the data flow calculation direction control instruction can be used to conveniently control the calculation direction of the neural network data flow between the first neural network calculation module and the second neural network calculation module, and the first neural network control instruction and the second neural network control instruction are used to control the calculation and flow of the neural network data flow between the first neural network calculation module and the second neural network calculation module, so that the generality of the calculation modules is improved and the calculation efficiency of the neural network data flow is improved at the same time.
Referring to fig. 8, fig. 8 is a schematic diagram of a hardware structure for controlling data flow of a neural network according to an embodiment of the present invention, where the hardware structure for controlling data flow of the neural network is a calculation direction corresponding to the method for controlling data flow of the neural network, that is, from a module a to a module B, and another calculation direction is from the module B to the module a; in fig. 8, module a may be the first field programmable neural network computing module, module B may be the second field programmable neural network computing module, or vice versa; the control signal Op _ order _ reverse _ en is the above data stream calculation direction control instruction, the control signal a _ en is the above first neural network control instruction, the control signal B _ en is the above second neural network control instruction, and the control signal a _ to _ output _ en is the above output control instruction, and the above neural network data stream control instruction can be formed by combining the above four control signals, so that the calculation and flow of the neural network data stream between the two modules A, B can be flexibly controlled by different signal (instruction) combinations, and the efficiency of the neural network data stream calculation is improved while the universality of the calculation modules is improved. The DMUX in fig. 8 is a single-input multi-output selection module, and can control one input to output from one of two output paths through the Op _ order _ reverse _ en control signal; the MUX is a multi-input single-output selector module, and can control which one of two inputs serves as an output through the Op _ order _ reverse _ en control signal.
It should be noted that a data flow control module (i.e., Adapter in fig. 8) is disposed between the first neural network computing module and the second neural network computing module, and when the data bit width between the first neural network computing module and the second neural network computing module is not matched, the data flow control module may be used to adjust the data rate, so that the first neural network computing module and the second neural network computing module may work in coordination.
It should be noted that the neural network data flow control method provided in the embodiment of the present invention may be applied to devices such as a mobile phone, a monitor, a computer, and a server that can perform neural network data flow control.
Referring to fig. 9, fig. 9 is a schematic structural diagram of a data flow control apparatus for a neural network according to an embodiment of the present invention, as shown in fig. 9, the apparatus 900 includes:
an obtaining module 901, configured to obtain a neural network data flow control instruction, where the neural network data flow control instruction includes a data flow calculation direction control instruction, a first neural network control instruction, and a second neural network control instruction, the first neural network control instruction is used to control a first neural network computing module, and the second neural network control instruction is used to control a second neural network computing module;
a determining module 902, configured to determine a calculation direction of a data flow between the first neural network calculation module and the second neural network calculation module according to the data flow calculation direction control instruction;
and a control module 903, configured to control the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction.
It should be noted that the neural network data flow control device provided in the embodiment of the present invention may be applied to a device such as a mobile phone, a monitor, a computer, and a server that can perform neural network data flow control.
The neural network data flow control device provided by the embodiment of the invention can realize each process realized by the neural network data flow control method in the method embodiment, and can achieve the same beneficial effects. To avoid repetition, further description is omitted here.
Referring to fig. 10, fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, as shown in fig. 10, including: the device comprises a memory 1002, a processor 1001 and a computer program stored on the memory 1002 and executable on the processor 1001, wherein the processor 1001 implements the steps in the neural network data flow control method provided by the embodiment of the application when executing the computer program.
The electronic device may be a device that can be applied to a mobile phone, a monitor, a computer, a server, or the like that can perform data flow control in a neural network.
The electronic device provided by the embodiment of the invention can realize each process realized by the neural network data flow control method in the method embodiment, can achieve the same beneficial effects, and is not repeated here to avoid repetition.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the neural network data flow control method provided in the embodiment of the present invention, and can achieve the same technical effect, and is not described herein again to avoid repetition.
Illustratively, the computer program of the computer-readable storage medium comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, and the like. The computer-readable medium may include: capable of carrying said computer program code
Any entity or device, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random-Access Memory (RAM), electrical carrier signal, telecommunications signal, and software distribution medium, etc.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (10)

1. A neural network data flow control method, comprising the steps of:
acquiring a neural network data flow control instruction, wherein the neural network data flow control instruction comprises a data flow calculation direction control instruction, a first neural network control instruction and a second neural network control instruction, the first neural network control instruction is used for controlling a first neural network calculation module, and the second neural network control instruction is used for controlling a second neural network calculation module;
determining a calculation direction of a data stream between the first neural network calculation module and the second neural network calculation module according to the data stream calculation direction control instruction;
and controlling the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction.
2. The method of claim 1, wherein said determining a computational direction of a data flow between the first neural network computational module and the second neural network computational module from the data flow computational direction control instructions comprises:
if the data flow calculation direction control instruction accords with a preset first calculation direction value, determining that the calculation direction is from the first neural network calculation module to the second neural network calculation module;
and if the data flow calculation direction control instruction conforms to a preset second calculation direction value, determining that the calculation direction is from the second neural network calculation module to the first neural network calculation module.
3. The method of claim 2, wherein the controlling the first neural network computation module and the second neural network computation module by the first neural network control instruction and the second neural network control instruction for data flow computation based on the computation direction comprises:
if the calculation direction is from the first neural network calculation module to the second neural network calculation module, controlling the first neural network calculation module to perform data calculation according to the first neural network control instruction to obtain a first calculation result;
and controlling the second neural network calculation module to perform data flow calculation according to the second neural network control command based on the first calculation result to obtain a second calculation result.
4. The method of claim 3, wherein the controlling the first neural network computation module and the second neural network computation module to perform data flow computations by the first neural network control directive and the second neural network control directive based on the computation direction, further comprises:
if the calculation direction is from the second neural network calculation module to the first neural network calculation module, controlling the second neural network calculation module to perform data calculation according to the second neural network control instruction to obtain a first calculation result;
and controlling the first neural network computing module to perform data flow computation according to the first neural network control instruction based on the first computing result to obtain a second computing result.
5. The method of claim 4, wherein the neural network data flow control instructions further comprise output control instructions, the method further comprising, after the step of controlling the first neural network computation module and the second neural network computation module to perform data flow computations by the first neural network control instructions and the second neural network control instructions based on the computation direction:
if the output control instruction accords with a preset output control value, directly outputting the first calculation result;
otherwise, outputting the second calculation result.
6. The method of claim 5, wherein the controlling the first neural network computational module to perform data computations according to the first neural network control instructions to obtain a first computation result comprises:
if the first neural network control instruction accords with a preset first control value, acquiring data of the first neural network, and calculating by the first neural network calculation module to obtain the first calculation result;
otherwise, acquiring the data of the first neural network as the first calculation result.
7. The method of claim 6, wherein controlling the second neural network computational module to perform data flow computations according to the second neural network control directives based on the first computational results to obtain second computational results comprises:
if the second neural network control instruction accords with a preset second control value, acquiring data of the second neural network, and calculating the first calculation result and the data of the second neural network through a second neural network calculation module to obtain a second calculation result;
otherwise, the first calculation result is used as the second calculation result.
8. A neural network data flow control apparatus, comprising:
the device comprises an acquisition module, a data flow control module and a data flow control module, wherein the acquisition module is used for acquiring a data flow control instruction of a neural network, the data flow control instruction of the neural network comprises a data flow calculation direction control instruction, a first neural network control instruction and a second neural network control instruction, the first neural network control instruction is used for controlling a first neural network calculation module, and the second neural network control instruction is used for controlling a second neural network calculation module;
a determining module for determining a calculation direction of a data stream between the first neural network calculation module and the second neural network calculation module according to the data stream calculation direction control instruction;
and the control module is used for controlling the first neural network computing module and the second neural network computing module to perform data flow computation through the first neural network control instruction and the second neural network control instruction based on the computation direction.
9. An electronic device, comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps in the neural network data flow control method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the neural network data flow control method according to any one of claims 1 to 7.
CN202011640067.3A 2020-12-31 2020-12-31 Neural network data flow control method and device, electronic equipment and storage medium Pending CN112884139A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011640067.3A CN112884139A (en) 2020-12-31 2020-12-31 Neural network data flow control method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011640067.3A CN112884139A (en) 2020-12-31 2020-12-31 Neural network data flow control method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112884139A true CN112884139A (en) 2021-06-01

Family

ID=76046632

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011640067.3A Pending CN112884139A (en) 2020-12-31 2020-12-31 Neural network data flow control method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112884139A (en)

Similar Documents

Publication Publication Date Title
CN109840589A (en) A kind of method, apparatus and system running convolutional neural networks on FPGA
CN111831355B (en) Weight precision configuration method, device, equipment and storage medium
CN112799726A (en) Data processing device, method and related product
CN111831359B (en) Weight precision configuration method, device, equipment and storage medium
CN115880132A (en) Graphics processor, matrix multiplication task processing method, device and storage medium
CN111831354B (en) Data precision configuration method, device, chip array, equipment and medium
CN113238989A (en) Apparatus, method and computer-readable storage medium for quantizing data
CN109885406B (en) Operator calculation optimization method, device, equipment and storage medium
US20220067495A1 (en) Intelligent processor, data processing method and storage medium
CN111831356B (en) Weight precision configuration method, device, equipment and storage medium
CN111813721B (en) Neural network data processing method, device, equipment and storage medium
CN113238987A (en) Statistic quantizer, storage device, processing device and board card for quantized data
CN109740730B (en) Operation method, device and related product
CN112884139A (en) Neural network data flow control method and device, electronic equipment and storage medium
CN111124490A (en) Precision-loss-free low-power-consumption MFCC extraction accelerator using POSIT
CN113238976B (en) Cache controller, integrated circuit device and board card
CN113591031A (en) Low-power-consumption matrix operation method and device
CN114327639A (en) Accelerator based on data flow architecture, and data access method and equipment of accelerator
CN111026445A (en) Intelligent identification method and chip
CN112991382A (en) PYNQ frame-based heterogeneous visual target tracking system and method
CN116663516B (en) Table machine learning model training method and device, electronic equipment and storage medium
JP2501186B2 (en) Digital signal processing method and apparatus thereof
CN109948785B (en) High-efficiency neural network circuit system and method
CN114692847B (en) Data processing circuit, data processing method and related products
TWI768497B (en) Intelligent processor, data processing method and storage medium

Legal Events

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