Instruction-based data processing device and method, terminal equipment and storage medium

By using multiple data lines in the neural network accelerator to process data in parallel and distinguish boundary instructions from non-boundary instructions, the problem of slow data processing speed is solved, and the efficiency of data handling and the sequence of upper-layer control logic are improved.

CN118567718APending Publication Date: 2024-08-30上海思特威集成电路有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310181863.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-28
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

The neural network accelerator is limited by the bandwidth of the data bus during data processing, resulting in low data transfer speed and affecting the running speed.

Method used

By using multiple data lines between the data processing module and the data module for parallel processing, boundary instructions and non-boundary instructions are distinguished, and boundary instructions are processed when all data lines are idle to improve data processing efficiency and ensure the order of the upper-layer control logic implement.

Benefits of technology

The data processing speed and data handling efficiency of the neural network accelerator are improved, ensuring the accuracy and correctness of the upper-layer control logic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567718A
    Figure CN118567718A
Patent Text Reader

Abstract

The invention belongs to the technical field of neural networks, and particularly relates to an instruction-based data processing device and method, terminal equipment and a storage medium. In the device, an instruction sequence module comprises a plurality of data processing instructions; the data module is used for storing data; the data processing module is connected with the data module through a plurality of data lines, and is configured to perform data processing based on the plurality of data processing instructions in the instruction sequence module and communicate with the data module; wherein when the data processing instruction at the preset position in the plurality of data processing instructions is a boundary instruction, the data processing instruction at the preset position is read under the condition that the plurality of data lines are idle. The device not only has a high data carrying speed, but also can ensure that the neural network accelerator does not disorder the upper layer control logic of the data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of neural network technology, and in particular, relates to an instruction-based data processing device, method, terminal equipment and storage medium. Background Art

[0002] During the calculation process, the neural network accelerator usually needs to perform several instruction-based data processing, such as data transfer processing or data calculation based on the computing core. During the data processing process, the neural network accelerator usually needs to execute several instructions to transfer data to the target location through the data bus, for example, transferring data from the external storage module to the internal cache module so that the computing module can read data from the internal cache. Alternatively, transfer data from the input end of the internal cache module to the computing module so that the computing module can perform calculations, etc. However, due to the bandwidth of the data bus, the data transfer speed is often low, and the data transfer processing between modules with multiple instruction repetition execution units is slow, which affects the operating speed of the neural network accelerator. Summary of the invention

[0003] The embodiments of the present application provide an instruction-based data processing apparatus, method, terminal device, and storage medium for solving the problem of low data processing speed of current neural network accelerators.

[0004] In a first aspect, an embodiment of the present application provides an instruction-based data processing device, which is applied to a neural network accelerator, including:

[0005] The instruction sequence module includes a plurality of data processing instructions.

[0006] Data module, used to store data.

[0007] The data processing module is connected to the data module via multiple data lines and is configured to perform data processing based on multiple data processing instructions in the instruction sequence module and communicate with the data module; wherein, when a data processing instruction at a preset position among the multiple data processing instructions is a boundary instruction, the data processing instruction at the preset position is read when all data lines are idle.

[0008] In this embodiment, the data module and the data processing module are connected through multiple data lines. The data processing module can process multiple non-boundary instructions in parallel through the multiple data lines to improve data processing efficiency. In addition, the data processing module can also control the multiple data lines to be in an idle state, and select one of them to process the boundary instruction to ensure the upper-level control logic of the neural network accelerator.

[0009] In a first possible implementation of the first aspect, a data processing module performs data processing based on a plurality of data processing instructions and communicates with a data module, including: when there is an idle data line among the plurality of data lines, determining whether a data processing instruction located at a preset position among the plurality of data processing instructions is a boundary instruction. If the data processing instruction is not a boundary instruction, reading the data processing instruction. If the data processing instruction is a boundary instruction, reading the data processing instruction at the preset position when all data lines are idle. Communication is performed between the data module and the data processing module according to the data processing instruction through a selected idle data line among the idle data lines.

[0010] In a second possible implementation of the first aspect, after the data processing module reads the data processing instruction at the preset position when all data lines are idle, it is further configured to: obtain the next data processing instruction after the data processing instruction at the preset position is executed.

[0011] In this embodiment, the data processing device can ensure that after processing an upper-level control logic boundary instruction, it will process the related instructions of the next control logic, ensuring that the upper-level control logic is executed in a preset order without confusion.

[0012] In a third possible implementation of the first aspect, the data module includes a first data module and a second data module, and the first data module and the second data module are communicatively connected via M data links formed based on multiple data lines, where M≥2, wherein:

[0013] Communication is performed between a data module and a data processing module according to a data processing instruction through a selected idle data line among the idle data lines, including: a selected idle data link is formed through a selected idle data line among the idle data lines, so that the data processing module communicates between a first data module and a second data module according to the data processing instruction.

[0014] In a fourth possible implementation of the first aspect, the data processing module communicates between the first data module and the second data module according to the data processing instruction, including:

[0015] Reading data from a first data module according to a data processing instruction and sending the read data to a second data module through a selected idle data link specifically includes: reading data from the first data module in sequence according to the data processing instruction by selecting an idle data link, and sending the read data to the second data module in sequence, wherein the multiple data processing instructions do not include boundary instructions.

[0016] And / or, the data processing module communicates between the first data module and the second data module according to the data processing instruction, including:

[0017] Acquire data from the second data module according to the data processing instruction and write the acquired data into the first data module through the selected idle data link, which specifically includes: by selecting the idle data link, acquire data from the second data module in sequence according to the data processing instruction, and write the acquired data into the first data module in sequence, wherein the multiple data processing instructions do not include boundary instructions.

[0018] In a fifth possible implementation of the first aspect, the data link includes a first sub-link and a second sub-link, and the obtaining of data from the second data module in sequence according to the data processing instruction through the selected idle data link, and writing the obtained data into the first data module in sequence, including: obtaining data from the second data module in sequence according to the data processing instruction through the first sub-link, and writing the obtained data into the first data module in sequence through the second sub-link; reading data from the first data module in sequence according to the data processing instruction through the selected idle data link, and sending the read data to the second data module in sequence, including: obtaining data from the first data module in sequence according to the data processing instruction through the second sub-link, and sending the obtained data to the second data module in sequence through the first sub-link.

[0019] In a sixth possible implementation of the first aspect, the data processing module is a data transfer module, the data processing instruction is a data transfer instruction, the first data module is an external storage module, the second data module is an internal cache module, and a plurality of cache units are provided in the internal cache module, and the data transfer instruction corresponds to a target cache unit among the plurality of cache units, wherein: the data processing module communicates between the first data module and the second data module according to the data processing instruction, including performing data transfer, which specifically includes: reading data from the external storage module according to the data transfer instruction, and sending the read data to the target cache unit through the selected idle data link; or, obtaining data from the target cache unit according to the data transfer instruction and writing the obtained data into the external storage module through the selected idle data link.

[0020] In a seventh possible implementation of the first aspect, the instruction processing device also includes an arbitration module, which is connected between the external storage module and the internal cache module, corresponding to M data links, to achieve matching between instructions in the instruction sequence module and the target cache unit.

[0021] In an eighth possible implementation of the first aspect, the data handling module reads data from the external storage module to the target cache unit based on the arbitration module, or obtains data from the target cache unit and writes it to the external storage module, which specifically includes: the data handling module obtains the data handling instruction from the instruction sequence module; wherein the data handling instruction includes a location identification field; the data handling module determines the corresponding target cache unit according to the location identification field, and connects the external storage module and the target cache unit through the arbitration module to form a data link; the data handling module controls reading data from the external storage module to the internal cache unit or obtaining data from the target cache unit and writing it to the external storage module.

[0022] In a ninth possible implementation of the first aspect, the data processing module is a computing module, the data processing instruction is a computing instruction, the first data module is the first part of the internal cache, and the second data module is the second part of the internal cache, wherein: the data processing module communicates between the first data module and the second data module according to the data processing instruction, including performing data calculation, which specifically includes: reading data from the first part of the internal cache according to the data calculation instruction, and sending the read data to the second part of the internal cache through a selected idle data link; or, obtaining data from the second part of the internal cache according to the data calculation instruction, and writing the obtained data to the first part of the internal cache through a selected idle data link.

[0023] In a tenth possible implementation of the first aspect, the computing module includes at least a first computing submodule and a second computing submodule, and the first computing submodule and the second computing submodule perform calculations based on different data links among the M data links and implement corresponding communication connections.

[0024] In an eleventh possible implementation of the first aspect, determining that a data processing instruction located at a preset position among multiple data processing instructions is a boundary instruction includes: when there is an idle data line in the data line, pre-reading a boundary identification field of the data processing instruction at the preset position, wherein the data processing instruction at the preset position includes a boundary identification field; and determining whether the data processing instruction is a boundary instruction according to the boundary identification field.

[0025] In a twelfth possible implementation of the first aspect, the boundary identification field is a reused field of a field in a data processing instruction; and / or, a plurality of data processing instructions in the instruction sequence module form an instruction queue, and the preset position is the head of the instruction queue.

[0026] In a second aspect, an embodiment of the present application provides an instruction-based data processing method, which is applied to the device as shown in the first aspect above, and the method includes: determining whether there are idle data lines among multiple data lines; when there are idle data lines among the multiple data lines, determining whether the data processing instruction at a preset position in the instruction sequence module is a boundary instruction; if the data processing instruction is a boundary instruction, reading the data processing instruction when all data lines are idle; if it is not a boundary instruction, reading the data processing instruction; and communicating between the data module and the instruction-based data processing module through a selected idle data link formed by selected idle data lines among the idle data lines.

[0027] In a first possible implementation of the first aspect, a data processing instruction is read when all data lines are idle, which specifically includes: if the data handling instruction is a boundary instruction, the data processing instruction is read when all data lines are idle, and is executed in one of the multiple data links formed by multiple data lines; and / or, when the data processing instruction at the preset position is allocated to the idle data link formed by the idle data line, the loop for the data processing instruction at the preset position is immediately ended; and / or, when the data processing instruction at the preset position is allocated to the idle data link formed by the idle data line and after the data processing instruction at the preset position is executed, communication is performed between the data module and the data processing module based on the multiple data links formed by the multiple data lines, and / or, for the data link formed by a single data line, communication is performed based on a method of sequentially obtaining instructions.

[0028] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method shown in the second aspect above when executing the computer program.

[0029] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method shown in the first aspect above.

[0030] It can be understood that the beneficial effects of the second to fourth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0032] Figure 1 is a structural diagram of an instruction-based data processing device provided by an embodiment of the present application;

[0033] Figure 2 is a schematic flow chart of a data processing module reading a data processing instruction provided by an embodiment of the present application;

[0034] Figure 3 is a schematic diagram of a process for determining a boundary instruction provided by an embodiment of the present application;

[0035] Figure 4 is a logic diagram of instruction reading provided by an embodiment of the present application;

[0036] Figure 5 is a schematic diagram of a data processing device provided by another embodiment of the present application;

[0037] Figure 6 is a schematic diagram of a data processing scenario in a neural network accelerator provided in an embodiment of the present application;

[0038] Fig. 7A is a schematic diagram of a data processing device provided by an embodiment of the present application for scenario 1;

[0039] Figure 7B is a schematic diagram of a data processing device provided for scenario 1 according to another embodiment of the present application;

[0040] Figure 8 It is a schematic diagram of a data processing device provided for scenario 2 in an embodiment of the present application. DETAILED DESCRIPTION

[0041] The technical solution provided in the embodiments of the present application is described below with reference to the accompanying drawings.

[0042] It should be understood that in the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is merely a way to describe the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0043] In this embodiment, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.

[0044] Figure 1FIG. 1 is a schematic diagram of a data processing device based on instructions provided by an embodiment of the present application. Figure 1 As shown, the instruction-based data processing device (hereinafter referred to as the data processing device) is applied to a neural network accelerator, and includes: an instruction sequence module, a data module, and an instruction-based data processing module (hereinafter referred to as the data processing module). The instruction sequence module is connected to the data processing module, and the data processing module is connected to the data module via M data lines (such as a data bus), where M≥2.

[0045] The instruction sequence module stores a plurality of data processing instructions in a preset manner. The data processing instructions may be data transfer instructions or calculation instructions, etc., which are not limited in this embodiment.

[0046] It is worth noting that, according to whether the data processing instruction is a control boundary of the logic control layer, the present embodiment divides the data processing instruction into boundary instructions and non-boundary instructions. Among them, the boundary instruction is the boundary line of different upper-level control logics, and is the last instruction of multiple data processing instructions corresponding to each upper-level control logic, that is, the boundary instruction is executed later than other instructions in the logic layer to which it belongs, wherein the setting of the logic control layer is set according to the computing task performed. In order to facilitate the distinction between the types of data processing instructions, a boundary identifier is set on the field of the boundary instruction, while a boundary identifier is not set on the field of the non-boundary instruction. Exemplarily, the field for setting the boundary identifier can be a reused field of an original field in the data processing instruction or an additionally set field, and the present embodiment does not limit this.

[0047] In some embodiments, the instruction sequence module stores the multiple data processing instructions in a queue as an example, and stores data processing instructions B.1, B.2, B.3, (B.4), B.5, B.6, B.7, B.8, B.9, (B.10) in order from the head of the queue to the tail of the queue. Among these instructions, (B.4) and (B.10) are boundary instructions, and the remaining instructions are non-boundary instructions. Among them, B.1, B.2, B.3, (B.4) belong to the same upper-level control logic, and (B.4) is the last data processing instruction corresponding to the upper-level control logic. B.5, B.6, B.7, B.8, B.9, (B.10) belong to the same upper-level control logic, and (B.10) is the last data processing instruction corresponding to the upper-level control logic.

[0048] By setting boundary instructions in multiple data processing instructions arranged in sequence, it is possible to ensure that the upper-level control logic of the neural network accelerator is not confused and the accuracy of the calculation results is guaranteed.

[0049] The data module, which may also be referred to as a data storage module, is used to store data, including data to be transferred to the data processing module and data transferred back from the data processing module. The data processing device provided in this embodiment may include only one or more data modules.

[0050] The data processing module is configured to perform data processing based on multiple data processing instructions in the instruction sequence module and communicate with the data module. During operation, the data processing module will cyclically read and execute the data processing instructions when there is an idle bus between the data module and the data processing module. The details are as follows.

[0051] Figure 2 This is a schematic flow chart of a data processing module reading a data processing instruction provided by an embodiment of the present application. The flow chart relates to a process in which the data processing module reads the i-th data processing instruction in a cycle, and specifically includes the following steps S201 to S205.

[0052] S201, the data processing module determines whether there is an idle data line among the M data lines.

[0053] In this embodiment, the data module and the data processing module are connected through M data lines, M≥2, so when there is an idle data line among the M data lines, the data processing module can perform data transmission between the data module and the data processing module according to the data processing instruction. Therefore, before the data processing module reads the data processing instruction from the instruction sequence module, it is necessary to first determine whether there is an idle data line among the M data lines. If there is, the next step S202 is executed. If not, the cycle of reading the data processing instruction in this round ends.

[0054] S202: The data processing module determines whether the i-th data processing instruction is a boundary instruction.

[0055] In this embodiment, if the data processing instructions are stored in a queue, the “i-th data processing instruction” is usually a data processing instruction at a preset position (such as the head) of the queue.

[0056] In one possible implementation, see Figure 3 As shown in S301 to S304 in , the data processing module can pre-read the boundary identification field of the i-th data processing instruction and identify whether the boundary identification field includes a boundary identification. If the boundary identification field includes a boundary identification, the i-th data processing instruction is determined to be a boundary instruction. If the boundary identification field does not include a boundary identification, the i-th data processing instruction is determined to be a non-boundary instruction, that is, not a boundary instruction.

[0057] S203-S204, if the ith data processing instruction is a boundary instruction, the data processing module waits for all M data lines to be idle before reading the ith data processing instruction. In one implementation, the continuous transmission command logic implemented by a single data link based on multiple sub-links and the multi-channel transmission instruction logic implemented by multiple data links are closed to wait for all instructions to be completed. If the ith data processing instruction is not a boundary instruction, the data processing module directly reads the ith data processing instruction. In one implementation, when the continuous transmission command logic is turned on, after executing the instruction to sending the read / write request to the data bus, the current cycle can be ended immediately without waiting for the instruction to be fully executed; in one implementation, after the execution of this instruction, the continuous transmission command logic and the multi-channel transmission instruction logic will be reopened (if they were closed before).

[0058] S205: The data processing module uses any idle bus to process the i-th data processing instruction.

[0059] For example, according to the i-th data processing instruction, the corresponding data in the data module is transferred to the data processing module for further processing, and the further processing includes transferring to other data modules, or performing data calculations to obtain calculation results, etc.

[0060] It can be understood that when the data processing module executes multiple data processing instructions through multiple data lines at the same time, the data processing device can transfer data in parallel through the data lines, thereby improving the data transfer efficiency of the neural network accelerator.

[0061] It should be noted that in the process of the data processing module using multiple data lines to execute multiple data processing instructions in parallel, the execution order of the data processing instructions on each bus cannot be guaranteed due to factors such as bus bandwidth and processing speed. Therefore, in a further example, in order to ensure the upper-level control logic of the neural network accelerator, when the i-th data processing instruction is a boundary instruction, the data processing module needs to start the next round of instruction reading process (i.e., read the i+1-th data processing instruction) after executing the i-th data processing instruction. And when the i-th data processing instruction is a non-boundary instruction, the data processing module can start the next round of instruction reading process after successfully reading the i-th data processing instruction, that is, there is no need to wait for the i-th data processing instruction to be executed.

[0062] The following is a detailed description of the process in which the data processing module reads the data processing instructions from the instruction sequence module with reference to a specific example.

[0063] Figure 4 FIG. 1 is a schematic diagram of an instruction reading logic provided by an embodiment of the present application. Figure 4As shown, the data processing instructions arranged in sequence in the instruction sequence module include B.1, B.2, B.3, (B.4), B.5, and B.6, and B.1, B.2, B.3, B.5, and B.6 are non-boundary instructions, and (B.4) is a boundary instruction. The data module and the data processing module are connected simultaneously through bus 0 and bus 1.

[0064] In different instruction reading and processing stages t0 to t6, the remaining data processing instructions in the instruction sequence module and the instructions occupying the data lines are usually different.

[0065] In the t0 stage, that is, before the data processing module starts to read the data processing instructions, the remaining data processing instructions in the instruction sequence module include B.1, B.2, B.3, (B.4), B.5, and B.6 in order from the head of the team to the end of the team, and bus 0 and bus 1 are temporarily not occupied to process any data processing instructions.

[0066] In stage t1, since both bus 0 and bus 1 are idle, and the data processing instruction determines that B.1 and B.2 are non-boundary instructions by pre-reading the boundary identification field, the data processing module can read the data processing instruction B.1 and occupy bus 1 to process the instruction; and read the data processing instruction B.2 and occupy bus 0 to process the instruction.

[0067] At stage t2, the data processing module has processed the data processing instruction B.2, and bus 0 is idle. The data processing module determines that the next data processing instruction B.3 to be read is a non-boundary instruction by pre-reading the boundary identification field, so the data processing module reads the data processing instruction B.3 and occupies bus 0 to process the instruction.

[0068] At stage t3, the data processing module has processed the data processing instruction B.1, and bus 1 is idle. However, the data processing module determines that the next data processing instruction to be processed (B.4) is a boundary instruction by pre-reading the boundary identification field. Therefore, the data processing module needs to wait until all buses are idle, that is, when both bus 0 and bus 1 are idle, to read and process the boundary instruction (B.4) to ensure the upper control logic of the neural network accelerator.

[0069] At stage t4, the data processing module has processed the data processing instruction B.3, and both bus 0 and bus 1 are idle. The data processing module reads the data processing instruction (B.4) and occupies any bus (such as bus 0) to process the instruction. It should be noted that in this design example, (B.4) is a boundary instruction. After processing (B.4), the data processing module starts to read the data processing instruction B.5.

[0070] At stage t5, after the data processing module processes the data processing instruction (B.4), both bus 0 and bus 1 are idle. The data processing module determines that the next data processing instruction B.5 to be processed is a non-boundary instruction by pre-reading the boundary identification field. Therefore, the data processing module reads the data processing instruction B.5 and occupies any bus (such as bus 0) to process the instruction.

[0071] At stage t6, while the data processing module occupies bus 0 to process B.5, bus 1 is idle. The data processing module determines that the next data processing instruction B.5 to be processed is a non-boundary instruction by pre-reading the boundary identification field, so the data processing module reads B.6 and occupies bus 1 to process the instruction.

[0072] Finally, after the data processing module has processed the data processing instructions B.5 and B.6, the processing of the instructions in the instruction sequence module is completed.

[0073] To summarize, in the data processing device provided in the embodiment of the present application, the data module and the data processing module are connected through multiple data lines. Based on this, the data processing module can process multiple non-boundary instructions in parallel through the multiple data lines to improve data processing efficiency; in addition, the data processing module can also control the multiple data lines to be in an idle state, and select one of them to process the boundary instruction to ensure the upper-level control logic of the neural network accelerator.

[0074] In other words, the data processing device provided in the embodiment of the present application can not only ensure that the upper-level control logic of the neural network accelerator is not chaotic, but also has a high data transfer speed and data transfer accuracy.

[0075] based on Figure 1 In the data processing device shown, in some implementations, the data module may specifically include multiple submodules, for example, a first data module and a second data module. After the data processing module reads the data processing instruction from the instruction sequence module, the data processing module communicates with the first data module and the second data module according to the data processing instruction. The details are as follows.

[0076] Figure 5 is a schematic diagram of a data processing device provided by another embodiment of the present application. Figure 5 As shown, the data processing device includes an instruction sequence module, a first data module, a second data module and a data processing module. The instruction sequence module is connected to the data processing module, and the first data module, the data processing module and the second data module are connected in sequence through the M data lines, M≥2.

[0077] The instruction sequence module stores a plurality of data processing instructions in a preset manner. For details, please refer to the above description, which will not be described in detail in this embodiment.

[0078] The first data module and the second data module are used to store data, including data to be transferred to the data processing module and data transferred back from the data processing module.

[0079] The data processing module is used to communicate with the first data module and the second data module according to the data processing instruction read from the instruction sequence module to realize data processing and transmission. For example, the data processing module moves data from the first data module to the second data module according to the data processing instruction; or moves data from the second data module to the first data module.

[0080] In this embodiment, the manner in which the data handling module reads the data processing instructions from the sequence module is specifically as shown above, and this embodiment will not be repeated here.

[0081] Next, we will combine the specific data processing scenarios of neural network accelerators to Figure 5 The working process of the data processing device provided in the illustrated embodiment is exemplarily described.

[0082] See also Figure 6 As shown, the neural network accelerator involves the following two data processing scenarios during data calculation.

[0083] Scenario 1: Data transfer scenario before / after calculation. That is, before the neural network accelerator performs data calculation, it first transfers the data to be calculated from the external storage module to the internal cache module according to the data transfer instructions in the first instruction sequence module. And, after the calculation is completed, the calculation result is transferred from the internal cache module to the external storage module.

[0084] Scenario 2: Data transfer scenario during the calculation process. That is, during the calculation process of the neural network accelerator, according to the calculation instructions in the second instruction sequence module, the data to be calculated is read from the first part of the internal cache module to the calculation module for calculation, and the calculation result is written into the second part of the internal cache module; of course, in other embodiments, the data to be calculated can also be read from the second part of the internal cache module to the calculation module for calculation, and the calculation result is written into the first part of the internal cache module. It should be noted that in an application, when the data source and output source of a batch of calculations are determined, for example, from the second part to the first part, the second part can be called the input end and the first part can be called the output end, and vice versa.

[0085] It can be understood that in different data processing scenarios (ie, the above-mentioned scenario 1 and scenario 2), the data processing device has different specific implementation forms, as shown below.

[0086] Fig. 7AFIG. 1 is a schematic diagram of a data processing device provided by an embodiment of the present application for scenario 1. Fig. 7A As shown, in this embodiment, the data processing instructions stored in the instruction sequence module are specifically data transfer instructions. The data processing module is specifically a data transfer module. The first data module is specifically an external storage module. The second data module is specifically an internal cache module. In addition, a Bank arbitration module is also provided between the first data module and the second data module. Furthermore, the external storage module, the data transfer module, the Bank arbitration module and the internal cache module are sequentially connected through the M data lines.

[0087] The instruction sequence module stores data transfer instructions, and a data transfer instruction can usually instruct to write or read data to a bank. The data transfer instruction carries bank indication information, and the bank indication information is used to indicate the location of the data in the internal cache module, that is, the target bank. If the data transfer instruction is used to instruct to transfer the data of the external storage module to the internal cache module, then the bank indication information is used to indicate the target bank for writing data in the internal cache module. In addition, if the data transfer instruction is used to instruct to transfer the data of the internal cache module to the external storage module, then the bank indication information is used to indicate the target bank for reading data from the internal cache module.

[0088] The data handling module specifically includes an instruction distribution unit, state machine 0 and state machine 1, etc. State machine 0 and state machine 1 are respectively used to manage different data lines. State machine 0 or state machine 1 performs calculations based on different data links in the M data links and realizes corresponding communication connections. Usually, the state machine and the state of the data line it manages are the same, that is, they are both in an idle state or in a non-idle state. The instruction distribution unit is used to read the data handling instructions from the instruction sequence module one by one, and distribute the read data handling instructions to an idle state machine, such as state machine 0 or state machine 1.

[0089] The external storage module is used to store data to be sent to the internal cache module or data returned by the internal cache module.

[0090] The internal cache module is provided with a plurality of physical cache units (Banks) for storing data, such as Bank0, Bank1, Bank2...Bankm-1, etc., where m is an integer greater than or equal to 1.

[0091] The bank arbitration module is used to determine the target bank for reading or writing data according to the bank indication information carried in the location identification field of the data transfer instruction.

[0092] Based on this, the process of the data handling module reading and executing the data handling instruction specifically includes:

[0093] When there is an idle data line among the M data lines sequentially connected between the external storage module, the data handling module, the Bank arbitration module and the internal cache module, the instruction distribution unit pre-reads the boundary identification field of the next data handling instruction to be read.

[0094] If the boundary identification field does not include a boundary identification, the data transfer instruction is determined to be a non-boundary instruction, and the data transfer instruction is formally read and assigned to an idle state machine so that the idle state machine uses the corresponding idle data line to process the data transfer instruction.

[0095] If the boundary identification field includes a boundary identification, the instruction distribution unit determines that the data handling instruction is a boundary instruction, and waits until the M data lines are all idle, formally reads the data handling instruction, and assigns the data handling instruction to an idle state machine, so that the idle state machine uses the corresponding idle data line to process the data handling instruction. In addition, the instruction distribution unit can read the next data handling instruction only after the boundary instruction is processed.

[0096] Regardless of whether the data transfer instruction is a boundary instruction or a non-boundary instruction, after the state machine obtains the data transfer instruction, the processing process of the instruction is the same. The details are as follows:

[0097] If the data transfer instruction indicates that the data is to be transferred from the external storage module to the internal cache module, the target state machine sends the data in the external storage module (such as the data to be calculated) to the Bank arbitration module through the corresponding idle data line, so that the Bank arbitration module transfers it to the target Bank of the internal cache module according to the Bank indication information carried in the data transfer instruction.

[0098] Alternatively, if the data transfer instruction indicates that the data is to be transferred from the internal cache module to the external storage module, the target state machine sends the data transfer instruction to the Bank arbitration module through the selected idle data line. The Bank arbitration module reads data (such as calculation results) from the target Bank of the internal cache module according to the Bank indication information carried in the data transfer instruction, and sends the read data to the external storage module for storage through the idle state machine (that is, the selected idle bus).

[0099] It should be noted that in the following scenario, for multiple continuous non-boundary instructions, the data processing module can use continuous transmission logic to carry out data transfer. That is, by selecting an idle data link, read data from the external storage module in sequence according to multiple data transfer instructions, and send the read data to the target banks corresponding to the multiple data transfer instructions in sequence; or, obtain data from the target banks corresponding to the multiple data transfer instructions in sequence according to the multiple data transfer instructions, and write the obtained data to the external storage module in sequence.

[0100] In one possible implementation, see Figure 7B As shown, a selected idle data link includes a first sub-link and a second sub-link, for example, Figure 7B In the example shown in , state machine 0-1 corresponds to the first sub-link, and state machine 0-2 corresponds to the second sub-link, wherein during data processing:

[0101] When selecting an idle data link, reading data from the first data module in sequence according to the data processing instruction, and sending the read data to the second data module in sequence, it specifically includes: obtaining data from the first data module in sequence according to the data processing instruction through the second sub-link corresponding to the state machine 0-2, and sending the obtained data to the second data module in sequence through the first sub-link corresponding to the state machine 0-1. When selecting an idle data link, obtaining data from the second data module in sequence according to the data processing instruction, and writing the obtained data to the first data module in sequence, it specifically includes: obtaining data from the second data module in sequence according to the data processing instruction through the first sub-link corresponding to the state machine 0-1, and writing the obtained data to the first data module in sequence through the second sub-link corresponding to the state machine 0-2.

[0102] Through the above method, it is possible to realize the continuous transmission of commands, continuously transmit requests for data transfer instructions on a data bus, and then continuously receive or send the corresponding data in sequence. Compared with sending a request only once each time and then receiving or sending data, the continuous transmission of command logic will: significantly reduce the average waiting time between requests and data transmission and reception, and improve the bandwidth utilization of the bus. The above design method can make each bus carry data in sequence according to the order of the data transfer instructions assigned to this bus, that is, the data bus will not be disordered. In a further implementation method, each sub-link included in a data link corresponds to an instruction distribution unit, for example, the first sub-link corresponding to the state machine 0-1 corresponds to the first instruction distribution unit, and the second sub-link corresponding to the state machine 0-2 corresponds to the second instruction distribution unit.

[0103] In one possible implementation, see Figure 7BAs shown, in the data processing device, the instruction distribution unit of the data handling module includes a first instruction distribution unit and a second instruction distribution unit. State machine 0 includes state machine 0-1 and state machine 0-2, and state machine 1 includes state machine 1-1 and state machine 1-2.

[0104] In the instruction distribution unit, the first instruction distribution unit is used to distribute data processing instructions (such as data handling instructions) to state machine 0-1, and the second instruction distribution unit is used to distribute data processing instructions (such as data handling instructions) to state machine 0-2. Similarly, the first instruction distribution unit is used to distribute data processing instructions to state machine 1-1, and the second instruction distribution unit is used to distribute data processing instructions to state machine 1-2.

[0105] In one example, the data link formed by the external storage module, state machine 0 and the Bank arbitration module includes a first sub-link and a second sub-link, wherein the first sub-link is a data link between the external storage module, state machine 0-1 and the Bank arbitration module, and the second sub-link is a data link between the external storage module, state machine 0-2 and the Bank arbitration module. Similarly, the data link formed by the external storage module, state machine 1 and the Bank arbitration module also includes a first sub-link and a second sub-link, wherein the first sub-link is a data link between the external storage module, state machine 1-1 and the Bank arbitration module, and the second sub-link is a data link between the external storage module, state machine 1-2 and the Bank arbitration module.

[0106] Based on this, when the external storage module and the internal cache module communicate through the selected idle data line, the first sub-link and the second sub-link of the data link corresponding to the data line can be used to realize continuous reading of instructions and data transfer. For example, the data transfer device can sequentially obtain data from the internal cache module according to the acquired data processing instructions through the first sub-link, and sequentially write the acquired data into the external storage module through the second sub-link; sequentially obtain data from the external storage module according to the acquired data processing instructions through the second sub-link, and sequentially write the acquired data into the internal cache module through the first sub-link.

[0107] The data processing device provided in the embodiment of the present application can not only quickly transfer data between the external storage module and the internal cache module through multiple data lines, but also the data transfer from the outside to the inside and from the inside to the outside can be carried out simultaneously, and the two transfer directions can be handled by 2M independent modules. It can also ensure that the upper-level control logic of the neural network accelerator is not chaotic, and has a high data transfer speed and data transfer accuracy.

[0108] Figure 8 Schematic diagram of a data processing device provided by an embodiment of the present application for scenario 2. Figure 8As shown, in this embodiment, the data processing instructions stored in the instruction sequence module are specifically calculation instructions. The data processing module is specifically a calculation module. The first data module is specifically the first part of the internal cache module, and the second data module is specifically the second part of the internal cache module. The details are as follows.

[0109] An instruction sequence module stores calculation instructions. The calculation instruction is used to instruct the data to be moved from the first part of the internal cache module to the calculation module for calculation, and then the calculation result is moved to the second part of the internal cache module for storage. The calculation instruction carries the first Bank indication information and the second Bank indication information. The first Bank indication information is used to indicate the storage location of the data in the first part of the internal cache module, that is, the first target Bank; the second indication information is used to indicate the storage location of the data in the second part of the internal cache module, that is, the second target Bank.

[0110] The computing module includes an instruction distribution unit, a first computing submodule and a second computing submodule. The instruction distribution unit is used to read computing instructions from the instruction sequence module, and distribute the read computing instructions to an idle computing submodule, such as the first computing submodule or the second computing submodule. The first computing submodule and the second computing submodule perform calculations based on different data links in the M data links and realize corresponding communication connections. In one implementation, the first computing submodule and the second computing submodule are set to be the same. Of course, in other examples, computing submodules of different numbers and uses can also be designed.

[0111] The first part of the internal cache module (referred to as the first part of the internal cache) includes a first storage area and a second storage area, wherein two storage areas are shown in the figure as an example for illustration, and there may be multiple storage areas in other examples, which can be set according to actual needs. Exemplarily, the first storage area specifically includes P banks, such as Bank0 to BankP-1; the second storage area also includes P banks, such as BankP to Bank2P-1. In one example, the number of banks in the first storage area and the second storage area is set to be the same, and P is an integer greater than or equal to 1.

[0112] The second part of the internal cache module (referred to as the second part of the internal cache) includes a first storage area and a second storage area, wherein two storage areas are shown in the figure as an example for illustration, and there may be multiple storage areas in other examples, which can be set according to actual needs. Exemplarily, the first storage area specifically includes P banks, such as Bank0 to BankP-1; the second storage area also includes P banks, such as BankP to Bank2P-1. In one example, the number of banks in the first storage area and the second storage area is set to be the same.

[0113] In one embodiment, the number of banks in the storage area corresponding to a computing submodule is the same. For example, for a first computing submodule, the number of banks in the first storage area of ​​the first part of the internal cache module corresponding to the first computing submodule is consistent with the number of banks in the first storage area of ​​the second part of the internal cache module corresponding to the first computing submodule, which is beneficial to the calculation based on the first computing submodule.

[0114] Based on this, the specific process of the data processing device reading and processing computing instructions includes: when there are idle data lines among the M data lines that sequentially connect the first part of the internal cache module, the computing unit and the second part of the internal cache, the instruction distribution unit pre-reads the boundary identification field of the next computing instruction to be read.

[0115] If the boundary identification field does not include a boundary identification, the calculation instruction is determined to be a non-boundary instruction, and the calculation instruction is formally read and assigned to an idle calculation submodule so that the idle calculation submodule uses the corresponding idle data line to process the calculation instruction.

[0116] If the boundary identification field includes a boundary identification, the instruction distribution unit determines that the calculation instruction is a boundary instruction, and waits until the M data lines are all idle, formally reads the calculation instruction, and assigns the calculation instruction to an idle state machine, so that the idle state machine uses the corresponding idle data line to process the calculation instruction. In addition, the instruction distribution unit can read the next data handling instruction only after the boundary instruction is processed.

[0117] Regardless of whether the calculation instruction is a boundary instruction or a non-boundary instruction, after the calculation submodule obtains the calculation instruction, the processing process of the instruction is the same. The details are as follows:

[0118] The target calculation submodule (such as the first calculation submodule) reads data from the first target Bank of the first part of the internal cache module and performs calculations according to the first Bank indication information in the calculation instruction to obtain the calculation result. Subsequently, according to the second Bank indication information in the calculation instruction, the calculation result is written into the second target Bank of the second part of the internal cache.

[0119] It should be noted that in one implementation, for a certain computing sub-module, such as the first computing sub-module, its data transmission is performed in two directions in a time-sharing manner, that is, one of the first storage area of ​​the first part of the internal cache module corresponding to the first computing sub-module to the first storage area of ​​the second part of the internal cache module corresponding to the first computing sub-module and the first storage area of ​​the second part of the internal cache module corresponding to the first computing sub-module to the first storage area of ​​the first part of the internal cache module corresponding to the first computing sub-module is selected to be performed. The design method based on the present application can reduce the number of data transfer instructions.

[0120] The data processing device provided in the embodiment of the present application can quickly transfer data from the internal cache module to the computing module through multiple data lines for calculation during the calculation of the neural network accelerator, and then transfer the calculation results back to the internal cache module, while ensuring that the upper-level control logic of the neural network accelerator is not confused, and has a high data transfer speed and data transfer accuracy.

[0121] Based on the same concept, an embodiment of the present application provides a data processing method, which corresponds to the embodiment of the aforementioned data processing device. For ease of reading, the present method embodiment will no longer repeat the details of the aforementioned device embodiment one by one, but it should be clear that the method in this embodiment can correspond to all the contents in the aforementioned device embodiment.

[0122] An embodiment of the present application also provides a neural network accelerator, which includes the data processing device shown in the above embodiments.

[0123] The embodiment of the present application further provides a terminal device, the terminal device includes a memory and a processor, the memory stores a computer program, when the computer program is executed by the processor, the processor can implement the data processing method executed by the data processing device in each of the above embodiments. Alternatively, the terminal device includes the above neural network accelerator.

[0124] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the data processing method performed by the data processing device in the above-mentioned embodiments.

[0125] It should be understood that the processor mentioned in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The memory mentioned in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories.

[0126] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0127] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0128] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A data processing device based on instructions, characterized in that: Applied to a neural network accelerator, the data processing device comprises: An instruction sequence module, including a plurality of data processing instructions; Data module, used to store data; A data processing module is connected to the data module via a plurality of data lines and is configured to perform data processing based on the plurality of data processing instructions in the instruction sequence module and to communicate with the data module; wherein, when a data processing instruction at a preset position among the plurality of data processing instructions is a boundary instruction, the data processing instruction at the preset position is read when all data lines are idle.

2. The device according to claim 1, characterized in that The data processing module performs data processing based on the multiple data processing instructions and communicates with the data module, including: When there is an idle data line among the plurality of data lines, determining whether the data processing instruction located at the preset position among the plurality of data processing instructions is a boundary instruction; If the data processing instruction is not the boundary instruction, reading the data processing instruction; If the data processing instruction is the boundary instruction, reading the data processing instruction at the preset position when all data lines are idle; Communication is performed between the data module and the data processing module according to the data processing instruction through selected ones of the idle data lines.

3. The device according to claim 1, characterized in that After the data processing module reads the data processing instruction at the preset position when all data lines are idle, the data processing module is further configured to: obtain the next data processing instruction after the data processing instruction at the preset position is executed.

4. The device according to claim 2, characterized in that The data module includes a first data module and a second data module, and the first data module and the second data module are communicatively connected via M data links formed based on the multiple data lines, M≥2, wherein: Through selected idle data lines among the idle data lines, communication is performed between the data module and the data processing module according to the data processing instruction, including: a selected idle data link is formed through selected idle data lines among the idle data lines, so that the data processing module communicates between the first data module and the second data module according to the data processing instruction.

5. The device according to claim 4, characterized in that The data processing module communicates between the first data module and the second data module according to the data processing instruction, including: Reading data from the first data module according to the data processing instruction and sending the read data to the second data module through the selected idle data link, which specifically includes: reading data from the first data module according to the data processing instruction in sequence through the selected idle data link, and sending the read data in sequence to the second data module, wherein the plurality of data processing instructions do not include the boundary instruction; And / or, the data processing module communicates between the first data module and the second data module according to the data processing instruction, including: Acquiring data from the second data module according to the data processing instruction and writing the acquired data into the first data module through the selected idle data link, which specifically includes: acquiring data from the second data module according to the data processing instruction in sequence through the selected idle data link, and writing the acquired data in sequence into the first data module, wherein the multiple data processing instructions do not include the boundary instruction.

6. The device according to claim 5, characterized in that The data link comprises a first sub-link and a second sub-link, The step of acquiring data from the second data module according to the data processing instructions in sequence through the selected idle data link, and writing the acquired data in sequence into the first data module includes: sequentially acquiring data from the second data module according to the data processing instruction through the first sub-link, and sequentially writing the acquired data into the first data module through the second sub-link; The method of reading data from the first data module according to the data processing instruction in sequence through the selected idle data link, and sending the read data to the second data module in sequence, comprises: The data is acquired from the first data module in sequence according to the data processing instruction through the second sub-link, and the acquired data is sent to the second data module in sequence through the first sub-link.

7. The device according to claim 5, characterized in that The data processing module is a data handling module, the data processing instruction is a data handling instruction, the first data module is an external storage module, the second data module is an internal cache module, and the internal cache module is provided with a plurality of cache units, the data handling instruction corresponds to a target cache unit among the plurality of cache units, wherein: The data processing module communicates between the first data module and the second data module according to the data processing instruction, including data transfer, which specifically includes: Read data from the external storage module according to the data transfer instruction, and send the read data to the target cache unit through the selected idle data link; or obtain data from the target cache unit according to the data transfer instruction and write the obtained data into the external storage module through the selected idle data link.

8. The device according to claim 7, characterized in that It also includes an arbitration module, which is connected between the external storage module and the internal cache module, corresponds to the M data links, and realizes the matching of instructions in the instruction sequence module and the target cache unit.

9. The device according to claim 8, characterized in that The data handling module reads data from the external storage module to the target cache unit based on the arbitration module, or obtains data from the target cache unit and writes it into the external storage module, which specifically includes: The data handling module obtains the data handling instruction from the instruction sequence module; Wherein, the data handling instruction includes a location identification field; The data handling module determines the corresponding target cache unit according to the location identification field, and connects the external storage module and the target cache unit through the arbitration module to form a data link; The data handling module controls reading data from the external storage module to the internal cache unit or obtains data from the target cache unit and writes it into the external storage module.

10. The device according to claim 4, characterized in that The data processing module is a calculation module, the data processing instruction is a calculation instruction, the first data module is a first part of the internal cache, and the second data module is a second part of the internal cache, wherein: The data processing module performs communication between the first data module and the second data module according to the data processing instruction, including performing data calculation, which specifically includes: Read data from the first part of the internal cache according to the data calculation instruction, and send the read data to the second part of the internal cache through the selected idle data link; or obtain data from the second part of the internal cache according to the data calculation instruction, and write the obtained data to the first part of the internal cache through the selected idle data link.

11. The device according to claim 10, characterized in that The calculation module includes at least a first calculation submodule and a second calculation submodule, and the first calculation submodule and the second calculation submodule perform calculations based on different data links among the M data links and realize corresponding communication connections.

12. The device according to any one of claims 1 to 11, characterized in that Determining a data processing instruction located at a preset position among the plurality of data processing instructions as a boundary instruction includes: When there is an idle data line among the data lines, pre-reading a boundary identification field of the data processing instruction at the preset position, wherein the data processing instruction at the preset position includes the boundary identification field; Determine whether the data processing instruction is the boundary instruction according to the boundary identification field.

13. The device according to claim 12, characterized in that The boundary identification field is a reused field of the fields in the data processing instruction; and / or, the multiple data processing instructions in the instruction sequence module form an instruction queue, and the preset position is the head of the instruction queue.

14. A data processing method based on instructions, characterized in that: Applied to the device according to any one of claims 1 to 13, the method comprises: Determining whether there is an idle data line among the plurality of data lines; When there is an idle data line among the plurality of data lines, determining whether the data processing instruction at the preset position in the instruction sequence module is a boundary instruction; If the data processing instruction is the boundary instruction, reading the data processing instruction when all data lines are idle; if it is not the boundary instruction, reading the data processing instruction; Communication is performed between the data module and the instruction-based data processing module via a selected idle data link formed by selected ones of the idle data lines.

15. The method according to claim 14, characterized in that The data processing instruction is read when all data lines are idle, which specifically includes: If the data handling instruction is the boundary instruction, reading the data processing instruction when all data lines are idle, and executing the instruction in one of the plurality of data links formed by the plurality of data lines; and / or, when the data processing instruction at the preset position is allocated to an idle data link formed by an idle data line, immediately terminating the loop of the data processing instruction at the preset position; And / or, when the data processing instruction at the preset position is allocated to an idle data link formed by an idle data line and after the data processing instruction at the preset position is executed, communication is performed between the data module and the data processing module based on the multiple data links formed by the multiple data lines, and / or, communication is performed based on the data link formed by a single data line in a manner of sequentially obtaining instructions.

16. A terminal device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to claim 14 or 15 when executing the computer program.

17. A computer-readable storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the method according to claim 14 or 15 is implemented.