Data reading method and device
By setting multiple loop counting structures in the chip and selecting the corresponding structure according to the data reading mode for counting, the problem of hardware design complexity and area increase caused by different data reading methods of different artificial intelligence models is solved, and more efficient data reading and hardware design.
Patent Information
- Application Number
- CN202411217446.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-22
AI Technical Summary
In the prior art, the data reading methods of artificial intelligence models such as CNN, Transformer and sparse Transformer are different, resulting in the need to set up a variety of different circuits within the chip, which increases the hardware design complexity and chip area.
By determining the data reading mode of the data array to be read, setting up multiple loop counting structures, and selecting the corresponding loop counting structure for counting according to the data reading mode, reading data of different models is realized, reducing the complexity of the circuit and take up space.
Through the multiplexing of the cyclic counting structure, data reading of different data reading modes is realized, which reduces the complexity and area of the circuit in the chip and improves the efficiency of hardware design.
Smart Images

Figure CN119007769A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a data reading method and device. Background Art
[0002] Artificial intelligence models are built using a variety of network models. For example, when using a matrix approach to calculate the convolutional neural network model CNN, the attention-based deep learning model Transformer, and the sparse Transformer, the three models have different ways of reading data. Three different circuits need to be set up in the chip to read data from different models, which increases the complexity of the hardware design in the chip and increases the chip area. Summary of the invention
[0003] In view of this, the present application provides a data reading method and device, and its specific scheme is as follows:
[0004] A data reading method, comprising:
[0005] Determine a data reading mode of a data array to be read, where data arrays to be read corresponding to different models have different data reading modes;
[0006] Determine, based on the data reading mode, an acquisition order of data in different directions in the to-be-read data array, and a plurality of loop counting structures for acquiring the data in different directions;
[0007] According to the acquisition order of data in different directions in the data array to be read, the corresponding circular counting structure is used to count in turn, and the position of the data to be read in the data array to be read is determined by the counting of the circular counting structure.
[0008] Further, the method of counting in sequence through corresponding loop counting structures according to the acquisition order of data in different directions in the to-be-read data array, and determining the position of the to-be-read data in the to-be-read data array through the counting of the loop counting structure, comprises:
[0009] Determine the configuration value of the loop counting structure corresponding to each direction data when the to-be-read data array is acquired;
[0010] According to the acquisition order of data in different directions in the data array to be read, based on the configuration value of each loop counting structure, counting is performed in sequence through the corresponding loop counting structure, and the position of the data to be read in the data array to be read is determined by the counting of the loop counting structure.
[0011] Further, according to the acquisition order of data in different directions in the data array to be read, based on the configuration value of each loop counting structure, counting is performed in sequence by the corresponding loop counting structure, and the position of the data to be read in the data array to be read is determined by the counting of the loop counting structure, including:
[0012] Determine a first loop counting structure according to the acquisition order of data in different directions in the to-be-read data array;
[0013] Counting by the first loop counting structure based on the step value of the first loop counting structure to determine to acquire data in a direction corresponding to the first loop counting structure;
[0014] If the count value of the first loop counting structure reaches the maximum value of the first loop counting structure, determining a second loop counting structure based on the acquisition sequence, and adjusting the count value of the second loop counting structure;
[0015] If the count values of the plurality of cyclic counting structures for acquiring the data in different directions all reach the maximum value, it is determined that the acquisition of a portion of the data in the to-be-read data array is completed.
[0016] Further, the method of counting in sequence through corresponding loop counting structures according to the acquisition order of data in different directions in the to-be-read data array, and determining the position of the to-be-read data in the to-be-read data array through the counting of the loop counting structure, comprises:
[0017] According to the reading order of the data in different directions in the data array to be read, counting is performed by reading the corresponding loop counting structures in sequence;
[0018] If it is determined that the count value of the read corresponding loop counting structure meets the condition, it is determined that the reading of the first unit data in the data array to be read is completed, and counting is performed in sequence by receiving the corresponding loop counting structure according to the receiving order of the data in different directions in the data array to be read;
[0019] If it is determined that the count value of the receiving corresponding loop count structure meets the condition, it is determined that the reception of the first unit data in the to-be-read data array is completed.
[0020] Furthermore, it also includes:
[0021] If it is determined that the reading of the first unit data in the to-be-read data array is completed, storing the count value of the loop count structure corresponding to the reading into a storage structure;
[0022] If it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop count structure corresponding to the reading, and the loop count structure corresponding to the reading is controlled to start counting from the count value stored in the specific position to determine the reading of the second unit data in the data array to be read.
[0023] Furthermore, it also includes:
[0024] If it is determined that the data array to be read is a specific type of data, when it is determined that the reading of the first unit data in the data array to be read is completed, the count value of the loop counting structure corresponding to the reading is stored in the storage structure, and when it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop counting structure corresponding to the reading.
[0025] A data reading device, comprising:
[0026] Multiple loop counting structures;
[0027] The processor is used to determine a data reading mode of a data array to be read, wherein the data arrays to be read corresponding to different models have different data reading modes; determine an acquisition order of data in different directions in the data array to be read based on the data reading mode, and a plurality of loop counting structures for acquiring the data in different directions; count the data in different directions in the data array to be read in turn through the corresponding loop counting structures, and determine the position of the data to be read in the data array to be read through the counting of the loop counting structures.
[0028] Furthermore, it also includes:
[0029] A plurality of switching switches are respectively arranged between the plurality of the cycle counting structures, and the switching switches between different cycle counting structures are controlled to be in an on or off state based on the data reading mode and the acquisition sequence.
[0030] Furthermore, it also includes:
[0031] The storage structure is used to store the count value of each loop counting structure.
[0032] Furthermore, the storage structure is used for:
[0033] If it is determined that the reading of the first unit data in the to-be-read data array is completed, storing the count value of the loop count structure corresponding to the reading into a storage structure;
[0034] If it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop count structure corresponding to the reading, and the loop count structure corresponding to the reading is controlled to start counting from the count value stored in the specific position to determine the reading of the second unit data in the data array to be read. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are 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 work.
[0036] Figure 1 A flowchart of a data reading method disclosed in an embodiment of the present application;
[0037] Figure 2a This is a schematic diagram of the data reading method corresponding to the Transformer, a deep learning model based on the attention mechanism;
[0038] Figure 2b This is a schematic diagram of the data reading method corresponding to the sparse Transformer model;
[0039] Figure 2c A schematic diagram of a data reading method corresponding to a convolutional neural network model CNN;
[0040] Figure 3 A flowchart of a data reading method disclosed in an embodiment of the present application;
[0041] Figure 4 A flowchart of a data reading method disclosed in an embodiment of the present application;
[0042] Figure 5a A schematic diagram of data acquisition corresponding to a deep learning model Transformer based on an attention mechanism disclosed in an embodiment of the present application;
[0043] Figure 5b A schematic diagram of data acquisition corresponding to a sparse Transformer model disclosed in an embodiment of the present application;
[0044] Figure 5c A schematic diagram of data acquisition corresponding to a convolutional neural network model CNN disclosed in an embodiment of the present application;
[0045] Figure 6A schematic diagram of the structure of a data reading device disclosed in an embodiment of the present application;
[0046] Figure 7a A circuit diagram for obtaining data of a deep learning model Transformer based on an attention mechanism disclosed in an embodiment of the present application;
[0047] Figure 7b A circuit diagram for obtaining data corresponding to a sparse Transformer model disclosed in an embodiment of the present application;
[0048] Figure 7c A circuit diagram for obtaining data of a convolutional neural network model CNN disclosed in an embodiment of the present application;
[0049] Figure 7d A circuit diagram of a data reading device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0051] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0052] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0053] The present application discloses a data reading method, and its flow chart is as follows: Figure 1 As shown, including:
[0054] Step S11, determining a data reading mode of a data array to be read, where data arrays to be read corresponding to different models have different data reading modes;
[0055] Step S12, determining the acquisition order of data in different directions in the data array to be read based on the data reading mode, and multiple loop counting structures for acquiring data in different directions;
[0056] Step S13, according to the acquisition order of data in different directions in the data array to be read, counting is performed in sequence through the corresponding circular counting structure, and the position of the data to be read in the data array to be read is determined by the counting of the circular counting structure.
[0057] Artificial intelligence models are built using a variety of network models. For example, when using a matrix approach to calculate the convolutional neural network model CNN, the attention-based deep learning model Transformer, and the sparse Transformer, the three models have different ways of reading data.
[0058] In order to read data from multiple different models using different modes, circuits corresponding to each model need to be set up in the chip. In this way, multiple different circuits need to be set up in the chip to realize the reading of data from multiple different models. This leads to high complexity of the hardware design inside the chip and increased chip area.
[0059] Based on this, in this scheme, multiple loop counting structures are set in the loop counter. When determining the data reading mode corresponding to the data to be read, the corresponding loop counting structure is selected from the multiple loop counting structures according to the data reading mode, so as to finally realize the reading of the data to be read. The reading of the data corresponding to any data reading mode is realized through multiple loop counting structures. By reusing the loop counting structure, the occupied space of the circuit in the loop counter is reduced. There is no need to set a circuit for each data reading mode, thereby reducing the complexity of the circuit structure inside the loop counting structure.
[0060] Specifically, when it is determined that there is data to be read, the data to be read is in the form of a data array. It is necessary to first determine the array corresponding to the data to be read, that is, the data reading mode corresponding to the data array to be read. Data arrays to be read corresponding to different models have different data reading modes.
[0061] For example: the convolutional neural network model CNN corresponds to the first data reading mode, the deep learning model Transformer based on the attention mechanism corresponds to the second data reading mode, and the sparse Transformer corresponds to the third data reading mode. The first data reading mode, the second data reading mode and the third data reading mode read data in different ways. Other models also have corresponding data reading modes, which are not listed here one by one.
[0062] Take the Transformer deep learning model based on the attention mechanism as an example to illustrate its data reading method. Figure 2a As shown, in the data array, in the order of rows and columns, the smallest granularity of data is Tile, and then the entire Block is taken; for sparse Transformer, the data reading method can be as follows Figure 2b As shown, in the data array, the minimum granularity of data is Mac in row and column order, and after transposition, it is stored in the dynamic random access memory DRAM. After a tile is filled, the entire block is filled. For the convolutional neural network model CNN, the data reading method can be as follows Figure 2c As shown, in the data array, first take Cin and fill an Entry, then continue to take Kernelh, and then take BlockW to get Tileh row data, and then form a Tile to start calculation, and the entire Block data needs to be filled.
[0063] When it is determined that the data to be read needs to be read, it is determined which model the data to be read corresponds to. Different models correspond to different data reading modes, so as to determine which data reading mode is required for the current data to be read.
[0064] Different data reading modes use different loop counting structures when reading data. Therefore, after determining the data reading mode corresponding to the data array of the data to be read, the order of acquiring data in different directions in the data array when reading data under the data reading mode is determined, such as: first acquiring data in the Cin direction, then acquiring data in the KernelH direction, then acquiring data in the BlockW direction, and then acquiring data in the BlockH direction; or, first acquiring data in the BlockW direction, then acquiring data in the BlockH direction, etc.
[0065] While determining the order of acquiring data in different directions in the data array, it is also necessary to determine the loop counting structure corresponding to the data in each direction that needs to be acquired, that is, the acquisition of data in each direction corresponds to a loop counting structure, and different data reading modes need to acquire data in different directions. Therefore, after determining the data reading mode, it is determined which directions of data need to be acquired in the data reading mode, and the corresponding loop counting structure is acquired for the data in each direction that needs to be acquired, so as to determine the position of the data currently to be read in the data array through the count of the loop counting structure, thereby realizing the reading of data in different directions in the data array to be read.
[0066] Multiple loop counting structures can be pre-set, and after determining the data reading mode required for the data array corresponding to the data to be read, the direction of the data in the data array to be read is determined, and the required loop counting structure is obtained from the pre-set multiple loop counting structures based on the determined direction, and according to the acquisition order of data in different directions in the data array, counting is performed in sequence through the corresponding loop counting structures, so as to realize the reading of data in different directions in the data array to be read.
[0067] For example: a first loop counting structure, a second loop counting structure, a third loop counting structure, a fourth loop counting structure, a fifth loop counting structure and a sixth loop counting structure are pre-set, the model corresponding to the data array currently to be read is the first model, the directions in the data array to be read in the data reading mode corresponding to the first model are the first direction, the third direction and the fourth direction, the first loop counting structure corresponding to the first direction, the third loop counting structure corresponding to the third direction, and the fourth loop counting structure corresponding to the fourth direction are determined, and the acquisition order of data in different directions in the data array is determined to be: first direction→third direction→fourth direction, then the loop counting structures are arranged according to the acquisition order, as: first loop counting structure→third loop counting structure→fourth loop counting structure, and the three loop counting structures determined above are counted in turn in this order until the counting of the three loop counting structures determined above is completed, thereby realizing the reading of data in the first direction, the third direction and the fourth direction in the data array.
[0068] For different data to be read, since the corresponding models are different, the corresponding data reading modes are different, so the loop counting structures to be called are also different. Therefore, when reading different data to be read, it is possible to reuse the pre-set multiple loop counting structures in different directions. There is no need to set a circuit dedicated to loop counting when reading data for each data reading mode, which saves space in the circuit.
[0069] The data reading method disclosed in the present embodiment determines the data reading mode of the data array to be read, and the data array to be read corresponding to different models has different data reading modes; based on the data reading mode, the acquisition order of data in different directions in the data array to be read and multiple loop counting structures for acquiring data in different directions are determined; according to the acquisition order of data in different directions in the data array to be read, the corresponding loop counting structures are counted in sequence, and the position of the data to be read in the data array to be read is determined by the counting of the loop counting structures. The scheme sets multiple loop counting structures, and when it is necessary to read the data in the data array to be read, the corresponding loop counting structures are acquired based on the data reading mode of the data array to be read, and the corresponding loop counting structures are counted in sequence to determine the position of the data to be read in the data array to be read, so as to realize the reading of data in different data reading modes by reusing the loop counting structures, and by reusing the loop counting structures, there is no need to set a complete data reading process composed of multiple loop counting structures for each data reading mode, thereby reducing the space occupied by the circuit of the loop counter composed of multiple loop counting structures and reducing the hardware design complexity inside the loop counter.
[0070] This embodiment discloses a data reading method, and its flow chart is as follows: Figure 3 As shown, including:
[0071] Step S31, determining a data reading mode of a data array to be read, where data arrays to be read corresponding to different models have different data reading modes;
[0072] Step S32, determining the acquisition order of data in different directions in the data array to be read based on the data reading mode, and multiple loop counting structures for acquiring data in different directions;
[0073] Step S33, determining the configuration value of the loop counting structure corresponding to each direction data when the data array to be read is acquired;
[0074] Step S34, according to the acquisition order of data in different directions in the data array to be read, based on the configuration value of each loop counting structure, count the corresponding loop counting structures in turn, and determine the position of the data to be read in the data array to be read by counting the loop counting structures.
[0075] After determining the data reading mode of the data array to be read, multiple cycle counting structures of data in different directions in the data array to be read are determined based on the data reading mode, and configuration values are set for the cycle counting structure of each direction of data respectively.
[0076] Among them, the configuration value may include: maximum value, step value, etc., and may also include initial value and other configuration values, which are not specifically limited here. The maximum value is: the maximum value that the count value of the loop counting structure can reach. When the maximum value is reached, the current loop counting structure will carry forward to the next loop counting structure, and the current loop counting structure will be reset at the same time; the step value is: the value by which the count value increases each time the loop counting structure counts; the initial value is: the value from which the loop counting structure starts counting.
[0077] According to the different data arrays to be read, the maximum count value of the loop counting structure of each direction data will be different, and the counting step value will also be different. Therefore, after determining the multiple loop counting structures corresponding to the data array to be read, it is necessary to first set the corresponding configuration value for each loop counting structure so that the counting based on the configured loop counting structure can meet the data reading requirements of the data array to be read.
[0078] The configuration values of the loop counting structures of data in different directions corresponding to the same data array to be read may be the same or different. For example, for the same data array to be read, the maximum value of the first loop counting structure corresponding to the first direction is value 1, and the maximum value of the second loop counting structure corresponding to the second direction is value 2, and value 1 is different from value 2. The step value of the first loop counting structure is step value 1, and the step value of the second loop counting structure is step value 2, and step value 1 is the same as step value 2.
[0079] Alternatively, for the same data array to be read, the maximum value of the first loop counting structure corresponding to the first direction is value 1, the maximum value of the third loop counting structure corresponding to the third direction is value 3, value 3 is the same as value 1, the step value of the first loop counting structure is step value 1, the step value of the third loop counting structure is step value 3, and step value 3 is different from step value 1;
[0080] Alternatively, for the same data array to be read, the maximum value of the first loop counting structure corresponding to the first direction is value 1, the maximum value of the fourth loop counting structure corresponding to the fourth direction is value 4, value 4 is different from value 1, the step value of the first loop counting structure is step value 1, the step value of the fourth loop counting structure is step value 4, step value 4 is different from step value 1.
[0081] Specifically, according to the order of acquiring data in different directions in the data array to be read, based on the configuration value of each loop counting structure, counting is performed in sequence through the corresponding loop counting structure, and the position of the data to be read in the data array to be read is determined by the counting of the loop counting structure, which can be specifically as follows:
[0082] A first loop counting structure is determined according to the order of acquiring data in different directions in the data array to be read; the first loop counting structure is counted based on the step value of the first loop counting structure to determine the acquisition of data in the direction corresponding to the first loop counting structure; if the count value of the first loop counting structure reaches the maximum value of the first loop counting structure, a second loop counting structure is determined based on the acquisition order, and the count value of the second loop counting structure is adjusted; if the count values of multiple loop counting structures that acquire data in different directions all reach the maximum value, it is determined that the acquisition of a part of the data array to be read has been completed.
[0083] In the process of using multiple loop counting structures to implement data reading according to the data reading mode, the corresponding loop counting structures are called in sequence according to the acquisition order of data in different directions in the data array to be read.
[0084] If the first loop counting structure and the second loop counting structure are determined according to the order of acquiring data in different directions, the first loop counting structure is first counted to determine the acquisition of data in the direction corresponding to the first loop counting structure, and then the second loop counting structure is counted to determine the acquisition of data in the direction corresponding to the second loop counting structure.
[0085] To count through the first loop counting structure, it is necessary to first set the configuration value of the first loop counting structure, determine the initial value, maximum value, step value, etc. of the first loop counting structure, and then count through the first loop counting structure according to the step value, starting from the initial value. For example, if the initial value is 0 and the step value is 3, the first loop counting structure starts counting from 0, and each count adds 3 to the count value, that is, the first count is 3, the second count is 6, and the third count is 9, until the count value reaches the maximum value.
[0086] When the count value of the first loop counting structure reaches a maximum value, counting is started through the second loop counting structure in the order of acquiring data in different directions. When counting through the second loop counting structure, it is first determined whether the configuration value of the second loop counting structure is set. The configuration value of the second loop counting structure can be set at the same time as the configuration value of the first loop counting structure, or the second loop counting structure can be configured after the count value of the first loop counting structure reaches a maximum value. Of course, preferably, the configuration value of the second loop counting structure can be set at the same time as the configuration value of the first loop counting structure. In this way, after the counting of the first loop counting structure starts, there is no need to wait for other loop counting structures to set the configuration values, but the counting can be kept uninterrupted at all times.
[0087] After determining that the configuration value of the second loop counting structure has been set, count according to the step value starting from the initial value of the second loop counting structure. For example, if the initial value is 4 and the step value is 1, the second loop counting structure starts counting from 4, and each count is based on the count value plus 1, that is, the first count is 5, the second count is 6, and the third count is 7, until the count value reaches the maximum value set by the second loop counting structure.
[0088] When the count value of the second loop counting structure reaches the maximum value, the loop counting structures following the second loop counting structure continue to be counted according to the order of acquiring data in different directions, until the count values of all loop counting structures required by the order of acquiring data in different directions have reached the maximum value, it can be determined that the acquisition of a part of the data array to be read is completed, and then when there is a demand for data acquisition, the acquisition of the next part of the data is achieved by continuing to count the loop counting structures.
[0089] Taking the Transformer, a deep learning model based on the attention mechanism, as an example, based on its corresponding data reading mode, it can be determined that the data in the BlockW direction and the BlockH direction in the data array to be read need to be obtained. Therefore, at least the loop counting structure BlockW Loop corresponding to the BlockW direction data and the loop counting structure BlockH Loop corresponding to the BlockH direction data need to be determined. In addition, the unit loop counting structure Send Loop needs to be determined, wherein the unit loop counting structure Send Loop is used for unit counting to read the data of a Tile unit.
[0090] When it is determined that the data in the data array to be read needs to be read, a data read request is input to the unit loop counting structure Send Loop to start counting. The Send Loop starts counting according to its step value. When the count reaches the maximum value of the Send Loop, a carry signal is output to the loop counting structure BlockWLoop corresponding to the BlockW direction data. If the step value of the BlockW Loop is 1, the BlockW Loop is incremented by 1. At the same time, the count value of the Send Loop is restored to its initial value. After that, the Send Loop continues to count according to its step value. When the count reaches the maximum value of the Send Loop, a carry signal is output to the loop counting structure BlockW Loop corresponding to the BlockW direction data. The BlockW Loop is incremented by 1 again until the count value of the BlockW Loop reaches the maximum value set for the BlockW Loop. The BlockW Loop outputs a carry signal to the loop counting structure BlockH Loop corresponding to the BlockH direction data. If the step value of the BlockH Loop is 1, the BlockH Loop is incremented by 1. At the same time, the Send Loop is restored to its initial value. The count value of the Send Loop and the count value of the BlockW Loop are restored to their initial values, and then continue to count from the initial value of the Send Loop until the count value of the BlockH Loop reaches the maximum value set for the BlockHLoop. The loop counting structure stops counting, and the counting of the Send Loop, BlockW Loop and BlockHLoop is completed.
[0091] In addition, if the convolutional neural network model CNN is taken as an example, based on its corresponding data reading mode, it can be determined that the data in the Cin direction, KernelH direction, BlockW direction and BlockH direction in the data array to be read need to be obtained. Therefore, at least the loop counting structure Cin Loop corresponding to the Cin direction, the loop counting structure KernelH Loop corresponding to the KernelH direction, the loop counting structure BlockW Loop corresponding to the BlockW direction data and the loop counting structure BlockH Loop corresponding to the BlockH direction data need to be determined. In addition, the unit loop counting structure Send Loop needs to be determined, wherein the unit loop counting structure Send Loop is used for unit counting to read the data of a Tile unit.
[0092] When it is determined that the data in the data array to be read needs to be read, a data read request is input to the unit cycle counting structure Send Loop to start counting. The Send Loop starts counting according to its step value. When the count reaches the maximum value of the Send Loop, a carry signal is output to the Cin Loop. If the step value of the Cin Loop is a, the Cin Loop is increased by a. At the same time, the count value of the Send Loop is restored to its initial value. After that, the Send Loop continues to count according to its step value. When the count reaches the maximum value of the Send Loop, a carry signal is output to the cycle counting structure Cin Loop corresponding to the Cin direction data. Cin Loop is increased by a again until the count value of the Cin Loop reaches the maximum value set for the Cin Loop. CinLoop outputs a carry signal to the KernelH Loop. If the step value of the KernelH Loop is b, the count value of the KernelH Loop is increased by b. At the same time, the count values of the Send Loop and the Cin Loop are restored to their initial values. After that, the Send Loop continues to count according to its step value. When the count reaches the maximum value of the Send Loop, a carry signal is output to the cycle counting structure Cin Loop corresponding to the Cin direction data. The Cin Loop is increased by a again. When the count value of the Cin Loop reaches the maximum value set for the Cin Loop, the CinLoop outputs a carry signal to the KernelH Loop. If the step value of the KernelH Loop is b, the count value of the KernelH Loop is increased by b. At the same time, the count values of the Send Loop and the Cin Loop are restored to their initial values. Loop continues to count according to its step value until the count value of KernelH Loop reaches the maximum value set for it. KernelH Loop outputs a carry signal to BlockW Loop. If the step value of BlockW Loop is c, the count value of BlockW Loop is increased by c until the count value of BlockW Loop reaches the maximum value set for it. BlockW Loop outputs a carry signal to BlockH Loop. If the step value of BlockH Loop is d, the count value of BlockH Loop is increased by d until the count value of BlockHLoop reaches the maximum value set for it. The cyclic counting structure stops counting, and the counting of Send Loop, CinLoop, KernelH Loop, BlockW Loop and BlockH Loop is completed.
[0093] The present embodiment discloses a data reading method, which determines a data reading mode of a data array to be read, wherein the data arrays to be read corresponding to different models have different data reading modes; based on the data reading mode, determines the acquisition order of data in different directions in the data array to be read, and multiple loop counting structures for acquiring data in different directions; determines the configuration value of the loop counting structure corresponding to each direction of data when acquiring the data array to be read; according to the acquisition order of data in different directions in the data array to be read, based on the configuration value of each loop counting structure, counts are performed in sequence through the corresponding loop counting structure, and the position of the data to be read in the data array to be read is determined through the counting of the loop counting structure. After determining the multiple loop counting structures corresponding to the data array to be read, the present embodiment also needs to set a corresponding configuration value for each loop counting structure, so as to realize setting different configuration values for loop counting structures in different directions when reading data from different data arrays to be read, so that different data can be acquired through the pre-set multiple loop counting structures.
[0094] This embodiment discloses a data reading method, and its flow chart is as follows: Figure 4 As shown, including:
[0095] Step S41, determining a data reading mode of a data array to be read, where data arrays to be read corresponding to different models have different data reading modes;
[0096] Step S42, determining the acquisition order of data in different directions in the data array to be read based on the data reading mode, and multiple loop counting structures for acquiring data in different directions;
[0097] Step S43, counting is performed by reading the corresponding loop counting structures in sequence according to the reading order of the data in different directions in the data array to be read;
[0098] Step S44: if it is determined that the count value of the corresponding loop counting structure satisfies the condition, it is determined that the reading of the first unit data in the data array to be read is completed, and counting is performed in sequence by receiving the corresponding loop counting structure according to the order of receiving data in different directions in the data array to be read;
[0099] Step S45 : if it is determined that the count value of the corresponding loop count structure meets the condition, it is determined that the reception of the first unit data in the to-be-read data array is completed.
[0100] When acquiring data in the data array to be read, it is usually divided into two steps, that is, firstly, part of the data is read, and after the reading is completed, this part of the data is received again. At this time, the acquisition of this part of the data is completed.
[0101] The multiple loop counting structures required for obtaining the data in the to-be-read data array are also divided into the loop counting structure required for the data reading process and the loop counting structure required for the data receiving process.
[0102] The loop counting structure required for data reading may include at least the following parts: Send Loop, Cin Loop, KernelH Loop, BlockW Loop and BlockH Loop; the loop counting structure required for data receiving may include at least the following parts: Mac Loop, Entry Loop and Tile Loop.
[0103] Taking the Transformer, a deep learning model based on the attention mechanism, as an example, the loop counting structures needed in the data reading process include: Send Loop, BlockW Loop and BlockH Loop, and the loop counting structures needed in the data receiving process include: Entry Loop and Tile Loop;
[0104] For sparse Transformer, the loop counting structures needed in the data reading process include: SendLoop, BlockW Loop and BlockH Loop, and the loop counting structures needed in the data receiving process include: MacLoop, Entry Loop and Tile Loop;
[0105] For the convolutional neural network model CNN, the loop counting structures needed in the data reading process include: Send Loop, Cin Loop, KernelH Loop, BlockW Loop and BlockH Loop, and the loop counting structures needed in the data receiving process include: Mac Loop, Entry Loop and Tile Loop.
[0106] Based on this, for a data reading device that can obtain the data to be read of the deep learning model Transformer based on the attention mechanism, the sparse Transformer and the convolutional neural network model CNN, its pre-set loop counting structure only needs to include one of the following: Send Loop, Cin Loop, KernelH Loop, BlockWLoop, BlockH Loop, Mac Loop, Entry Loop and Tile Loop, and there is no need to set a group of loop counters for acquiring data for the deep learning model Transformer based on the attention mechanism, set a group of loop counters for acquiring data for the sparse Transformer, and set a group of loop counters for acquiring data for the convolutional neural network model CNN. By reusing the above-mentioned loop counting structures, the data to be read corresponding to different models can be acquired, thereby saving the area occupied by the circuit corresponding to the loop counter for reading the data to be read.
[0107] Take the Transformer, a deep learning model based on the attention mechanism, as an example:
[0108] like Figure 5a The figure shows a schematic diagram of data acquisition, which determines the data array to be read corresponding to the deep learning model Transformer based on the attention mechanism, selects the corresponding loop counting structure, namely: Send Loop, BlockW Loop, BlockH Loop, Entry Loop and Tile Loop, generates a data acquisition request to trigger the Send Loop to start counting, and when the Send Loop count reaches the maximum value, triggers the BlockW Loop to start counting. At the same time, outputs a data request to request to read the data of a Tile (parallel data block), and then counts the BlockW direction in the data array to be read through the BlockW Loop count, and counts the BlockH direction in the data array to be read through the BlockH Loop count, until the Send Loop, BlockW Loop and BlockH Loop all reach the set maximum value, and the counting of the loop counting structure for reading data is completed.
[0109] Among them, Send Loop sends a data request every time it jumps. Sliding in the direction of BlockW traverses the data in the direction of BlockW, and sliding in the direction of BlockH traverses the data in the direction of BlockH, so as to realize the traversal of all data that need to be read.
[0110] Based on the output of the data request, the data reading device receives the data, and the cyclic counting structure for receiving the data starts counting. In the process of receiving data, the Entry Loop starts counting. When the count value of the Entry Loop reaches the maximum value, one Entry data is received, that is, one row of data is recorded. At this time, the Entry Loop outputs a carry signal to the Tile Loop, and the Tile Loop starts counting until the Tile Loop count reaches the maximum value, and then a column of data is received through the Tile Loop. When the Entry Loop and Tile Loop counts both reach the maximum value, it indicates that one Tile data is received, that is, the reception of the first unit data is completed.
[0111] After the data reception of a Tile is completed, the loop counting structure used to read the data will be triggered to continue to send a Tile data Data request. After the data array to be read is divided into multiple Tiles and the data reception of each Tile is completed, the received data of each Tile is spliced to obtain the received complete data array, thereby realizing the complete acquisition of the data array to be read.
[0112] Take sparse Transformer as an example:
[0113] like Figure 5b As shown, the data array to be read corresponding to the sparse Transformer is determined, and the corresponding loop counting structure is selected, namely: Send Loop, BlockW Loop, BlockH Loop, Mac Loop, Entry Loop and Tile Loop, and a data acquisition request is generated to trigger the Send Loop to start counting. When the Send Loop count reaches the maximum value, it is carried to the BlockW Loop to start counting the BlockW Loop, and when the BlockW Loop count reaches the maximum value, it is carried to the BlockH Loop to make the BlockH Loop count reach the maximum value. When the BlockH Loop count reaches the maximum value, the counting of the data reading process is completed. During the counting process, when the sliding reaches the data amount of a Tile, a data request is output to request to read the data of a Tile.
[0114] What is different from the Transformer, a deep learning model based on the attention mechanism, in the process of data reading and receiving is that a data transposition step is added during the data receiving process, while the other steps are the same as the above example.
[0115] Among them, Mac Loop is responsible for receiving data, transposing the data, and then outputting it to Entry Loop and TileLoop to realize the reception of a Tile data.
[0116] Take the convolutional neural network model CNN as an example:
[0117] like Figure 5c As shown, the data array to be read corresponding to the convolutional neural network model CNN is determined, and the corresponding loop counting structure is selected, namely: Send Loop, Cin Loop, KernelH Loop, BlockW Loop, BlockH Loop, MacLoop, Entry Loop and Tile Loop, and a data acquisition request is generated to trigger the Send Loop to start counting. When the SendLoop count reaches a maximum value, the Cin Loop is triggered to start counting. Through the count of the Cin Loop, it slides in the Cin direction of the data array to be read. When the count of the Cin Loop reaches a maximum value, it is carried to the KernelH Loop, and the KernelH Loop starts counting. Through the count of the KernelH Loop, it slides in the KernelH direction of the data array to be read. When the count of the KernelHLoop reaches a maximum value, it is carried to the BlockW Loop, and the BlockW Loop starts counting. Through the count of the BlockW Loop, it slides in the BlockW direction of the data array to be read. When the count of the BlockW Loop reaches a maximum value, it is carried to the BlockH Loop, and the BlockH Loop starts counting, and slides in the BlockH direction of the data array to be read through the counting of BlockH Loop. When the count of BlockH Loop reaches the maximum value, the counting of the data reading process is completed. During the counting process, when the sliding reaches the data amount of one Tile, a data request is output to request to read the data of one Tile.
[0118] Based on the output of the data request, the data reading device receives the data, and the loop counting structure for receiving the data starts counting. In the process of receiving data, the weight data is read through Mac Loop for data splicing. The data can also be transposed through MacLoop, that is, the different functions in the data receiving process are realized through the multiplexing of Mac Loop. Afterwards, as in the above example, the Entry Loop and Tile Loop are counted to realize the reception of a Tile data.
[0119] Specifically, in the process of reading the to-be-read data array of the convolutional neural network model CNN, the following steps may also be included:
[0120] If it is determined that the reading of the first unit data in the data array to be read is completed, the count value of the corresponding loop counting structure is stored in the storage structure; if it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop counting structure corresponding to the reading, and the loop counting structure corresponding to the reading is controlled to start counting from the count value stored at a specific position to determine the reading of the second unit data in the data array to be read.
[0121] That is, in the process of reading the data array to be read of the convolutional neural network model CNN, it is now necessary to store the count values corresponding to the read and received data to facilitate the accuracy of the data reading position.
[0122] When sending a data request, the position of the tile data requested in each direction when sending the data request is recorded, that is, the count value of each loop count structure when sending the data request is stored, such as: the count value index of the Cin Loop, the count value index of the KernelH Loop, the count value index of the BlockW Loop and the count value index of the BlockH Loop when sending the data request are stored in the storage structure, and then the data is received based on the data request;
[0123] After the data reception is completed, Send Loop is triggered to continue counting to continue reading the data in the data array to be read. At this time, the loop counting structure is triggered to read the count value from the storage structure to determine from which position to start reading the data, that is: Cin Loop is triggered to read the count value index of Cin Loop recorded from the storage structure, so that Cin Loop starts counting from the count value index of Cin Loop stored in the storage structure; KernelH Loop is triggered to read the count value index of KernelH Loop recorded from the storage structure, so that KernelH Loop starts counting from the count value index of KernelH Loop stored in the storage structure; BlockW Loop is triggered to read the count value index of BlockW Loop recorded from the storage structure, so that BlockW Loop starts counting from the count value index of BlockW Loop stored in the storage structure; BlockH Loop is triggered to read the count value index of BlockH Loop recorded from the storage structure, so that BlockH Loop starts counting from the count value index of BlockH Loop stored in the storage structure.
[0124] Specifically, if it is determined that the data array to be read is a specific type of data, when it is determined that the reading of the first unit data in the data array to be read is completed, the count value of the corresponding loop counting structure is stored in the storage structure, and when it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop counting structure corresponding to the reading.
[0125] Among them, the data array to be read of the convolutional neural network model CNN is a specific type of data, that is, only when the data array to be read is the data corresponding to the convolutional neural network model CNN, the corresponding count value will be stored, and when the data array to be read is the data corresponding to the sparse Transformer, or the deep learning model Transformer based on the attention mechanism, this step is not required.
[0126] The data reading method disclosed in the present embodiment determines the data reading mode of the data array to be read, and the data arrays to be read corresponding to different models have different data reading modes; based on the data reading mode, the acquisition order of data in different directions in the data array to be read and multiple loop counting structures for acquiring data in different directions are determined; according to the reading order of data in different directions in the data array to be read, the corresponding loop counting structures are read in sequence to count; if it is determined that the count value of the corresponding loop counting structure is read to meet the conditions, it is determined that the reading of the first unit data in the data array to be read is completed, according to the receiving order of data in different directions in the data array to be read, the corresponding loop counting structure is received in sequence to count; if it is determined that the count value of the corresponding loop counting structure is received to meet the conditions, it is determined that the reception of the first unit data in the data array to be read is completed. When acquiring data through the loop counting structure, the first unit data is first read by reading the corresponding loop counting structure, and after the reading is completed, the first unit data is received by receiving the corresponding loop counting structure, so as to realize the acquisition of the first unit data in the data array to be read, and ensure the acquisition of data corresponding to different models.
[0127] This embodiment discloses a data reading device, and its structural diagram is shown in FIG. Figure 6 As shown, including:
[0128] A plurality of cycle counting structures 61 and a processor 62 .
[0129] Among them, the processor 62 is used to determine the data reading mode of the data array to be read, and the data arrays to be read corresponding to different models have different data reading modes; based on the data reading mode, the acquisition order of data in different directions in the data array to be read and multiple loop counting structures 61 for acquiring data in different directions are determined; according to the acquisition order of data in different directions in the data array to be read, counting is performed in turn through the corresponding loop counting structures 61, and the position of the data to be read in the data array to be read is determined by the counting of the loop counting structure 61.
[0130] Furthermore, the data reading device disclosed in this embodiment may also include:
[0131] A plurality of switching switches are respectively arranged between the cycle counting structures, and the switching switches between different cycle counting structures are controlled to be in an on or off state based on a data reading mode and an acquisition sequence.
[0132] Furthermore, the data reading device disclosed in this embodiment may also include:
[0133] The storage structure is used to store the count value of each loop counting structure.
[0134] Furthermore, the storage structure in the data reading device disclosed in this embodiment is used for:
[0135] If it is determined that the reading of the first unit data in the data array to be read is completed, the count value of the corresponding loop counting structure is stored in the storage structure; if it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop counting structure corresponding to the reading, and the loop counting structure corresponding to the reading is controlled to start counting from the count value stored at a specific position to determine the reading of the second unit data in the data array to be read.
[0136] If the data array to be read is the data corresponding to the deep learning model Transformer based on the attention mechanism, then its circuit diagram consisting of multiple loop counting structures and storage structures can be as follows: Figure 7a As shown (the processor is not shown in the figure), it includes: Send Loop, BlockW Loop, BlockH Loop, Entry Loop and Tile Loop, wherein en in each loop counting structure is an enable interface, cen is an enable interface for outputting a carry signal, and intiv is an interface for outputting a count value;
[0137] If the data array to be read is the data corresponding to the sparse Transformer model, then its circuit diagram consisting of multiple loop counting structures and storage structures can be as follows: Figure 7bAs shown (the processor is not shown in the figure), including: Send Loop, BlockW Loop, BlockH Loop, Mac Loop, Entry Loop and Tile Loop;
[0138] If the data array to be read is data corresponding to the convolutional neural network model CNN, the circuit diagram consisting of multiple loop counting structures and storage structures can be as follows: Figure 7c As shown (the processor is not shown in the figure), it includes: Send Loop, CinLoop, KernelH Loop, BlockW Loop, BlockH Loop, Mac Loop, Entry Loop, Tile Loop, storage structure 1 and storage structure 2, wherein storage structure 1 and storage structure 2 can be different parts of the same storage structure or different storage structures, which is not specifically limited here.
[0139] Specifically, the circuit diagram of the data reading device disclosed in this embodiment can be specifically as follows: Figure 7d As shown (the processor is not shown in the figure), it includes: Send Loop, Cin Loop, KernelH Loop, BlockW Loop, BlockH Loop, MacLoop, Entry Loop, Tile Loop, a first switching switch K1, a second switching switch K2, a storage structure 1 and a storage structure 2, wherein the first switching switch K1 is a single-pole double-throw switch, whose input end is connected to the cen interface of the Send Loop, the first output end is connected to the en interface of the Cin Loop, and the second output end is connected to the en interface of the BlockW Loop; the second switching switch K2 is a single-pole single-throw switch, one end of which is connected to the cen interface of the Mac Loop, and the other end is connected to the en interface of the Entry Loop.
[0140] When the data array to be read is data corresponding to the deep learning model Transformer based on the attention mechanism, the first switch K1 and the second switch K2 are switched to enable Figure 7d The corresponding circuit diagram is transformed into Figure 7a As shown; if the data array to be read is data corresponding to the sparse Transformer model, the first switch K1 and the second switch K2 are switched to make Figure 7d The corresponding circuit diagram is transformed into Figure 7b As shown; if the data array to be read is data corresponding to the convolutional neural network model CNN, the first switch K1 and the second switch K2 are switched to make Figure 7d The corresponding circuit diagram is transformed into Figure 7c shown.
[0141] The data reading device disclosed in this embodiment is implemented based on the data reading method disclosed in the above embodiment, which will not be described in detail here.
[0142] The data reading device disclosed in the embodiment determines the data reading mode of the data array to be read, and the data arrays to be read corresponding to different models have different data reading modes; based on the data reading mode, the acquisition order of data in different directions in the data array to be read and multiple loop counting structures for acquiring data in different directions are determined; according to the acquisition order of data in different directions in the data array to be read, the corresponding loop counting structures are counted in sequence, and the position of the data to be read in the data array to be read is determined by the counting of the loop counting structures. The scheme sets multiple loop counting structures, and when it is necessary to read the data in the data array to be read, the corresponding loop counting structures are acquired based on the data reading mode of the data array to be read, and the corresponding loop counting structures are counted in sequence to determine the position of the data to be read in the data array to be read, so as to realize the reading of data in different data reading modes by reusing the loop counting structures, and by reusing the loop counting structures, it is not necessary to set a complete data reading process composed of multiple loop counting structures for each data reading mode, thereby reducing the space occupied by the circuit of the small loop counter composed of multiple loop counting structures.
[0143] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0144] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0145] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0146] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A data reading method, comprising: Determine a data reading mode of a data array to be read, where data arrays to be read corresponding to different models have different data reading modes; Determine, based on the data reading mode, an acquisition order of data in different directions in the to-be-read data array, and a plurality of loop counting structures for acquiring the data in different directions; According to the acquisition order of data in different directions in the data array to be read, the corresponding circular counting structure is used to count in turn, and the position of the data to be read in the data array to be read is determined by the counting of the circular counting structure.
2. The method according to claim 1, wherein the steps of counting the data in different directions in the to-be-read data array in sequence using a corresponding loop counting structure and determining the position of the data to be read in the to-be-read data array using the count of the loop counting structure include: Determine the configuration value of the loop counting structure corresponding to each direction data when the to-be-read data array is acquired; According to the acquisition order of data in different directions in the data array to be read, based on the configuration value of each loop counting structure, counting is performed in sequence through the corresponding loop counting structure, and the position of the data to be read in the data array to be read is determined by the counting of the loop counting structure.
3. The method according to claim 2, wherein according to the acquisition order of data in different directions in the data array to be read, based on the configuration value of each loop counting structure, counting is performed in sequence by the corresponding loop counting structure, and the position of the data to be read in the data array to be read is determined by the count of the loop counting structure, comprising: Determine a first loop counting structure according to the acquisition order of data in different directions in the to-be-read data array; Counting by the first loop counting structure based on the step value of the first loop counting structure to determine to acquire data in a direction corresponding to the first loop counting structure; If the count value of the first loop counting structure reaches the maximum value of the first loop counting structure, determining a second loop counting structure based on the acquisition sequence, and adjusting the count value of the second loop counting structure; If the count values of the plurality of cyclic counting structures for acquiring the data in different directions all reach the maximum value, it is determined that the acquisition of a portion of the data in the to-be-read data array is completed.
4. The method according to claim 1, wherein the steps of counting the data in different directions in the to-be-read data array in sequence using a corresponding loop counting structure and determining the position of the data to be read in the to-be-read data array using the count of the loop counting structure include: According to the reading order of the data in different directions in the data array to be read, counting is performed by reading the corresponding loop counting structures in sequence; If it is determined that the count value of the read corresponding loop counting structure meets the condition, it is determined that the reading of the first unit data in the data array to be read is completed, and counting is performed in sequence by receiving the corresponding loop counting structure according to the receiving order of the data in different directions in the data array to be read; If it is determined that the count value of the receiving corresponding loop count structure meets the condition, it is determined that the reception of the first unit data in the to-be-read data array is completed.
5. The method according to claim 4, further comprising: If it is determined that the reading of the first unit data in the to-be-read data array is completed, storing the count value of the loop count structure corresponding to the reading into a storage structure; If it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop count structure corresponding to the reading, and the loop count structure corresponding to the reading is controlled to start counting from the count value stored in the specific position to determine the reading of the second unit data in the data array to be read.
6. The method according to claim 5, further comprising: If it is determined that the data array to be read is a specific type of data, when it is determined that the reading of the first unit data in the data array to be read is completed, the count value of the loop counting structure corresponding to the reading is stored in the storage structure, and when it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop counting structure corresponding to the reading.
7. A data reading device, comprising: Multiple loop counting structures; The processor is used to determine a data reading mode of a data array to be read, wherein the data arrays to be read corresponding to different models have different data reading modes; determine an acquisition order of data in different directions in the data array to be read based on the data reading mode, and a plurality of loop counting structures for acquiring the data in different directions; count the data in different directions in the data array to be read in turn through the corresponding loop counting structures, and determine the position of the data to be read in the data array to be read through the counting of the loop counting structures.
8. The apparatus according to claim 7, further comprising: A plurality of switching switches are respectively arranged between the plurality of the cycle counting structures, and the switching switches between different cycle counting structures are controlled to be in an on or off state based on the data reading mode and the acquisition sequence.
9. The apparatus according to claim 7, further comprising: The storage structure is used to store the count value of each loop counting structure.
10. The device according to claim 9, wherein the storage structure is used for: If it is determined that the reading of the first unit data in the to-be-read data array is completed, storing the count value of the loop count structure corresponding to the reading into a storage structure; If it is determined that the reception of the first unit data in the data array to be read is completed, the count value stored in the storage structure is updated to the loop count structure corresponding to the reading, and the loop count structure corresponding to the reading is controlled to start counting from the count value stored in the specific position to determine the reading of the second unit data in the data array to be read.
