Data rearrangement method and device, electronic equipment and storage medium
By splitting the rearrangement instructions into the first and second instructions and performing two rearrangements, the problem of low data reordering efficiency in the prior art is solved, and more efficient data dimension adjustment is achieved.
Patent Information
- Application Number
- CN202510257403.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-06-20
AI Technical Summary
Existing data reordering methods are inefficient when adjusting data dimensions, resulting in excessive consumption of computing resources and storage resources.
By obtaining input data, determining sub-instructions that comply with preset rules, calculating multiple dimension values of sub-data, obtaining first position information of sub-data, and splitting the rearrangement instructions into the first and second instructions based on the sub-instruction, performing two rearrangements to adjust the data dimensions.
It reduces the computational complexity of a single data reordering, reduces the amount of computing resources, and improves the efficiency of data reordering.
Smart Images

Figure CN120179206A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data rearrangement, and in particular, to a data rearrangement method, apparatus, electronic device, and storage medium. Background Art
[0002] With the development of artificial intelligence technology, more and more organizations or individuals tend to use artificial intelligence models for data analysis to assist production, thereby improving productivity. To improve the accuracy of the results output by the model, it is necessary to train the artificial intelligence model using training data. To ensure that the dimensions of the training data match the dimensions of the input data of the artificial intelligence model, it is usually necessary to adjust the dimensions of the training data.
[0003] Currently, the position of sub-data in the original data is usually determined according to a preset rearrangement instruction, and the position of the sub-data is transformed to adjust the dimension of the original data. However, due to the relatively complex and irregular operation logic of the rearrangement instruction, this data rearrangement method usually requires additional consumption of computing resources and storage resources, resulting in low data rearrangement efficiency. Summary of the Invention
[0004] In view of the above, it is necessary to provide a data rearrangement method, apparatus, electronic device, and storage medium to solve the technical problem of low efficiency in rearranging data.
[0005] The present application provides a data rearrangement method applied to an electronic device. The method includes: obtaining input data, where the input data includes sub-data of multiple dimensions; determining, from pre-stored rearrangement instructions, sub-instructions that meet a preset rule; calculating, using the sub-instructions, values of the sub-data corresponding to the multiple dimensions to obtain first position information of the sub-data in the input data; splitting the rearrangement instruction based on the sub-instructions to obtain a first instruction and a second instruction; performing a first rearrangement operation on the sub-data based on the first instruction according to the first position information to obtain cached data; the first instruction is used to indicate a mapping relationship between the first position information and a second position information of the sub-data in the cached data; performing a second rearrangement operation on the sub-data in the cached data based on the second instruction according to the second position information to obtain output data; the second instruction is used to indicate a mapping relationship between the second position information and a third position information of the sub-data in the output data.
[0006] An embodiment of the present application further provides a data rearrangement device, which includes: an acquisition module for acquiring input data, where the input data includes sub-data of multiple dimensions; a determination module for determining, from pre-stored rearrangement instructions, sub-instructions that meet a preset rule; the determination module is further configured to calculate, using the sub-instructions, numerical values of the sub-data corresponding to the multiple dimensions to obtain first position information of the sub-data in the input data; a splitting module for splitting the rearrangement instruction based on the sub-instruction to obtain a first instruction and a second instruction; a first rearrangement module for performing a first rearrangement operation on the sub-data based on the first instruction according to the first position information to obtain cached data; the first instruction is used to indicate a mapping relationship between the first position information and second position information of the sub-data in the cached data; a second rearrangement module for performing a second rearrangement operation on the sub-data in the cached data based on the second instruction according to the second position information to obtain output data; the second instruction is used to indicate a mapping relationship between the second position information and third position information of the sub-data in the output data.
[0007] An embodiment of the present application further provides an electronic device, which includes: a memory storing at least one instruction; a processor for executing the instruction stored in the memory to implement the data rearrangement method described above.
[0008] An embodiment of the present application further provides a computer-readable storage medium, in which at least one instruction is stored, and the at least one instruction is executed by a processor in an electronic device to implement the data rearrangement method described above.
[0009] It can be seen from the above technical solutions that the embodiment of the present application can split the rearrangement instruction based on a preset non-divisible rule to obtain a first instruction and a second instruction, thereby simplifying the logic of data rearrangement during the data rearrangement process and improving the efficiency of data rearrangement. Map the first position information of the sub-data in the input data according to the first instruction to determine the second position information of the sub-data in the cached data, and map the second position information according to the second instruction to determine the third position information of the sub-data in the output data. Thus, the sub-data of the input data is mapped twice to obtain the output data, and the sub-data in the input data can be rearranged at least twice to obtain the output data that meets the input requirements of the artificial intelligence model, thereby reducing the computational complexity of a single data rearrangement, reducing the occupancy of computing resources, and improving the efficiency of data rearrangement. Description of the Drawings
[0010] Figure 1 It is an application scenario diagram of a data rearrangement method provided by an embodiment of the present application.
[0011] Figure 2 It is a flowchart of a data rearrangement method provided by an embodiment of the present application.
[0012] Figure 3 It is a schematic diagram of input data provided by an embodiment of the present application.
[0013] Figure 4 It is a flowchart of a method for determining a first instruction and a second instruction provided by an embodiment of the present application.
[0014] Figure 5 It is a flowchart of a method for determining cached data provided by an embodiment of the present application.
[0015] Figure 6 It is a schematic diagram of cached data provided by an embodiment of the present application.
[0016] Figure 7 It is a flowchart of a method for determining output data provided by an embodiment of the present application.
[0017] Figure 8 It is a schematic diagram of output data provided by an embodiment of the present application.
[0018] Figure 9 It is a functional module diagram of a data rearrangement device provided by an embodiment of the present application.
[0019] Figure 10 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0020] In order to more clearly understand the purpose, features, and advantages of the present application, the present application will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present application and the features in the embodiments may be combined with each other. Many specific details are set forth in the following description in order to fully understand the present application. The described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments.
[0021] In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of the described features. In the description of the present application, "a plurality" means two or more, unless otherwise specifically defined.
[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terms used in the specification of this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0023] An embodiment of this application provides a data rearrangement method, which can be applied to one or more electronic devices. An electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.
[0024] An electronic device can be any electronic product that can perform human-computer interaction with a customer. For example, a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an Internet Protocol Television (IPTV), a smart wearable device, etc.
[0025] The electronic device may further include a network device and / or a client device. Among them, the network device includes, but is not limited to, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing.
[0026] The network where the electronic device is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.
[0027] As Figure 1 shown, a data rearrangement method provided by this application can be applied to an electronic device 100, and the electronic device 100 is communicatively connected to a database 200. Among them, the electronic device 100 can be an edge computing device. Specifically, the electronic device 100 is used to train an artificial intelligence model. Among them, the artificial intelligence model can be an object detection model for detecting human targets in images, can also be a natural language model for analyzing text, and can also be a speech recognition model for analyzing speech data. This application does not make any limitations in this regard.
[0028] Among them, the database 200 is used to store pre-collected input data. Specifically, the input data is used to train the data of the artificial intelligence model. Exemplarily, if the artificial intelligence model is an object detection model for detecting human objects in images, the input data can be pre-collected image data; if the artificial intelligence model is a natural language model for analyzing text, the input data can be pre-collected text data; if the artificial intelligence model is a speech recognition model for analyzing speech, the input data can be pre-collected speech data. Among them, the input data includes sub-data of multiple dimensions. When training the artificial intelligence model according to the input data in the database 200, in order to ensure that the dimensions of the data input into the artificial intelligence model meet the input requirements of the model, it is necessary to rearrange multiple sub-data in the input data to obtain output data that meets the model input requirements.
[0029] Specifically, the electronic device 100 can traverse the sub-instructions in the preset rearrangement instruction, determine the sub-instructions that meet the preset indivisibility rule, and update the sub-instructions according to the indivisibility rule to obtain a first instruction and a second instruction. Among them, the computing resources occupied by the first instruction and the second instruction are less than the computing resources occupied by the rearrangement instruction. Determine the first index corresponding to the sub-data in the input data according to the first instruction to represent the first position information of the sub-data in the input data, and determine the cache index corresponding to the first index according to the mapping relationship indicated by the first instruction to determine the second position information of the sub-data in the cached data, and then perform a first rearrangement operation on the sub-data according to the cache index to obtain cached data, thereby performing the first rearrangement on the sub-data in the input data to achieve the first dimensional transformation.
[0030] The electronic device 100 also determines a second index corresponding to the cache index to determine the third position information of the sub-data in the output data, and then performs a second rearrangement operation on the sub-data in the cached data according to the second index to obtain output data. In this way, according to two index conversions, the input data can be converted into output data that meets the input dimension of the artificial intelligence model, reducing the computational complexity of the single rearrangement process, thereby improving the efficiency of data rearrangement.
[0031] As Figure 2 shown, it is a flowchart of a data rearrangement method provided by an embodiment of the present application. According to different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted. A data rearrangement method provided by an embodiment of the present application includes the following steps.
[0032] S20, obtain input data, where the input data includes sub-data of multiple dimensions.
[0033] In an embodiment of the present application, the input data may be data for training an artificial intelligence model. Exemplarily, if the artificial intelligence model is an object detection model for detecting human targets in images, the input data may be image data pre-collected for training the object detection model. If the artificial intelligence model is a natural language model for analyzing text, the input data may be text data pre-collected for training the natural language model.
[0034] In an embodiment of the present application, the input data includes sub-data of multiple dimensions. For example, when the artificial intelligence model is an object detection model for processing image data, the dimension of the input data of the artificial intelligence model may be (8526, 96, 8). This dimension is used to represent that the input data of the artificial intelligence model has three dimensions, and each dimension includes multiple sub-data. Specifically, the first dimension includes 8526 sub-data, the second dimension includes 96 sub-data, and the third dimension includes 8 sub-data, indicating that the artificial intelligence model can receive and process data with 96 rows, 8 columns, and 8526 channels. When the dimension of the pre-collected input data is (3, 1392, 32, 64), it indicates that the input data is data with 32 rows, 64 columns, 3 channels, and 1392 batches. Specifically, the input data may be 1392 batches of image data, where each batch of image data includes pixel points with 32 rows and 64 columns, and each pixel point includes numerical values of 3 channels. The numerical values of the three channels may be the pixel values of the RGB three channels of each pixel point in the image. To ensure that this input data can be used to train the object detection model, it is necessary to convert the input data with 3 channels, 1392 batches, 32 rows, and 64 columns into input data with 96 rows, 8 columns, and 8526 channels.
[0035] As Figure 3 shown is a schematic diagram of the input data 300. Among them, the input data 300 may be multiple image data, and the input data 300 has four dimensions. Among them, the first original dimension 310 is used to represent the number of channels of the pixel points in the image data, and the number of channels may be 3; the second original dimension 320 represents the number of batches when multiple image data are used to train the artificial intelligence model, and the number of batches may be 1392; the third original dimension 330 represents the number of rows of the image data in each batch, and the number of rows may be 32; the fourth original dimension 340 represents the number of columns of the image data in each batch, and the number of columns may be 64.
[0036] S21, determine sub-instructions that conform to the preset rules from the pre-stored rearrangement instructions.
[0037] In an embodiment of the present application, in order to ensure that the artificial intelligence model can receive and process the information in the input data, it is necessary to ensure that the dimension of the data input into the artificial intelligence model conforms to the architecture of the artificial intelligence model. Specifically, in order to ensure that the artificial intelligence model can be trained according to the input data, the sub-data of multiple dimensions in the input data can be rearranged by using a pre-written rearrangement instruction to obtain output data, so as to ensure that the dimension of the output data meets the requirements of the artificial intelligence model. Among them, the rearrangement instruction can be a program written in a preset programming language, which is used to indicate the mapping relationship between the first index and the second index. Among them, the first index is used for the first position information of the sub-data in the input data, and the second index is used to indicate the position of the sub-data in the output data that meets the input requirements of the artificial intelligence model. Among them, the preset programming language can be Python language, Java language, or C language, and the present application does not limit this.
[0038] For example, when the preset programming language is Python language, the content included in the rearrangement instruction can be "for i0,i1,i2 in T.grid(8526,96,8):
[0039] with T.block("Input data"):
[0040] a,b,c = T.axis.remap("SSS",[i0,i1,i2]);
[0041] Output data[a,b,c] = Input data[b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]".
[0042] Among them, the rearrangement instruction includes multiple sub-instructions, and the sub-instructions are used to determine the first position information of the sub-data in the input data according to the multiple dimension values of the sub-data. For example, "Input data[b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]" in the rearrangement instruction is used to indicate the first index of any sub-data in the input data. Among them, the sub-instruction "b / / 32" is used to represent the value of the first original dimension in the first index, the sub-instruction "(a*8+c) / / 49" is used to represent the value of the second original dimension in the first index, the sub-instruction "b%32" is used to represent the value of the third original dimension in the first index, and the sub-instruction "(a*8+c)%49" is used to represent the value of the fourth original dimension in the first index.
[0043] In an embodiment of the present application, since the calculation logic of the sub-instructions is relatively complex, the efficiency of determining the first position information of the sub-data in the input data according to the dimensional value of the sub-data is low, which in turn leads to low efficiency of data rearrangement. To improve the efficiency of data rearrangement, multiple sub-instructions in the rearrangement instruction can be filtered according to a preset rule to determine the sub-instructions that meet the preset rule. Specifically, multiple sub-instructions can be traversed according to the arrangement order of the sub-instructions in the rearrangement instruction; it is judged whether the traversed sub-instruction meets the preset rule; when the traversed sub-instruction meets the preset rule, it is determined that the calculation logic of the sub-instruction cannot be simplified again. Among them, the preset rule is an indivisibility rule. When any one of the sub-instructions in the rearrangement instruction cannot be decomposed by the preset operation, it is determined that the any one of the sub-instructions is a sub-instruction that meets the preset rule.
[0044] In an embodiment of the present application, the preset operation includes a division operation and / or a modulo operation. When any one of the sub-instructions can no longer be simplified by the division operation and / or the modulo operation, it indicates that the calculation logic of the sub-instruction can no longer be simplified. Therefore, it can be determined that the sub-instruction is a sub-instruction that meets the preset indivisibility rule. Exemplarily, when the sub-instruction is "a*16 + c*2 / / 2", the sub-instruction can be simplified to "a*8 + c" by the division operation. Therefore, the sub-instruction does not meet the preset indivisibility rule; when the sub-instruction is "a*8 + c / / 1", the sub-instruction can no longer be simplified by the division operation and / or the modulo operation, indicating that the sub-instruction is a sub-instruction that meets the preset indivisibility rule.
[0045] In an embodiment of the present application, to improve the efficiency of determining the sub-instructions that meet the preset rule, the method further includes: simplifying the rearrangement instruction based on a preset simplification rule to obtain a simplified rearrangement instruction; when any one of the sub-instructions in the simplified rearrangement instruction cannot be decomposed by the preset operation, it is determined that the any one of the sub-instructions is a sub-instruction that meets the preset rule.
[0046] Among them, the preset simplification rules include: the characters in the sub-instruction satisfy the preset arrangement order, and the characters satisfy the first quantization relationship. Exemplarily, the arrangement order of multiple characters in the sub-instruction can be "constant character, multiplication character, variable character, addition character, constant character, multiplication character, variable character, addition character", and the first quantization relationship can be that multiple constant characters have the greatest common divisor. Exemplarily, a sub-instruction that meets this first condition can be "2*a+4*b+6*c / / 7". In order to rewrite the form of the sub-instruction, while retaining the calculation logic of the sub-instruction, and reducing the calculation complexity of the sub-instruction, when the sub-instruction includes preset characters and multiple characters in the sub-instruction have the greatest common divisor, the simplified rearrangement instruction can be determined according to the greatest common divisor and the sub-instruction. Specifically, the coefficient of each character can be divided by the greatest common divisor to obtain a new coefficient, and the simplified rearrangement instruction can be determined according to the new coefficient and multiple characters. Among them, the preset character can be a division character. Exemplarily, when the sub-instruction is "2*a+4*b+6*c / / 7", it can be determined that the sub-instruction includes a division character, and multiple characters in the sub-instruction have the greatest common divisor 2. Then, the coefficient of each character can be divided by the greatest common divisor to obtain a new coefficient, and the simplified rearrangement instruction determined according to the new coefficient and multiple characters can be "a+2*b+3*c / / 7".
[0047] In an embodiment of the present application, the preset simplification rule can also be that the sub-instruction satisfies the form of "(x / / c1*c2+x%c1)%y" and "(c1-c2)%b=0", where x and y are variable characters, and c1 and c2 are constant characters. Then, after simplifying the rearrangement instruction based on the preset simplification rule, the simplified rearrangement instruction obtained is "x%y".
[0048] In an embodiment of the present application, the preset simplification rule can also be that the sub-instruction satisfies the form of "(x%c1*c2-x)%c1" and "c2=1", where x is a variable character, and c1 and c2 are constant characters. Then, after simplifying the rearrangement instruction based on the preset simplification rule, the simplified rearrangement instruction obtained is "0".
[0049] In an embodiment of the present application, the preset simplification rule can also be that the sub-instruction satisfies the form of "(x*c1+y) / / (k*c1)" and "y<1", where x, y, and k are all variable characters, and c1 is a constant character. Then, after simplifying the rearrangement instruction based on the preset simplification rule, the simplified rearrangement instruction obtained is "x / / k".
[0050] S22. Use the sub-instruction to calculate the values of the sub-data corresponding to the multiple dimensions, and obtain the first position information of the sub-data in the input data.
[0051] In an embodiment of the present application, in order to adjust the positions of sub - data in the input data to change the dimension of the obtained output data, the first position information of each sub - data in the input data can be determined first. Specifically, each sub - data in the input data can be traversed to determine the values of multiple dimensions corresponding to the traversed sub - data; multiple sub - instructions in the rearrangement instruction are used to calculate the values of the multiple dimensions corresponding to the sub - data to obtain the first index corresponding to each sub - data; based on the first index indicating the first position information of the traversed sub - data in the input data, the position of the sub - data after the rearrangement operation on the input data can be determined subsequently.
[0052] Exemplarily, when the preset programming language is Python, the content included in the rearrangement instruction can be "for i0,i1,i2 in T.grid(8526,96,8):
[0053] with T.block(\"Input data\"):
[0054] a,b,c=T.axis.remap(\"SSS\",[i0,i1,i2]);
[0055] Output data[a,b,c]=Input data[b / / 32,(a*8 + c) / / 49,b%32,(a*8 + c)%49]".
[0056] Among them, \"Input data[b / / 32,(a*8 + c) / / 49,b%32,(a*8 + c)%49]\" is used to represent the first index in the input data. Among them, the sub - instruction \"b / / 32\" is used to represent the value of the first original dimension in the first index, the sub - instruction \"(a*8 + c) / / 49\" is used to represent the value of the second original dimension in the first index, the sub - instruction \"b%32\" is used to represent the value of the third original dimension in the first index, and the sub - instruction \"(a*8 + c)%49\" is used to represent the value of the fourth original dimension in the first index.
[0057] Exemplarily, when the value of a is 8526, the value of b is 96, and the value of c is 8, the value of the first original dimension in the first index is 3, the value of the second original dimension in the first index is 1392, the value of the third original dimension in the first index is 0, and the value of the fourth original dimension in the first index is 8. If the input data is image data of multiple batches, the sub - data corresponding to this first index belongs to the image data of the 1392nd batch in the input data, and this sub - data is the pixel value of the 3rd channel of the pixel point in the 0th row and 8th column of the image data of this batch.
[0058] S23, split the rearrangement instruction based on the sub - instruction to obtain a first instruction and a second instruction.
[0059] In an embodiment of the present application, since the computational amount of multiple sub-instructions implementing the rearrangement logic in the rearrangement instruction is large, the form of the sub-instructions can be edited, so that the rearrangement instruction is split into a first instruction and a second instruction based on the sub-instructions. In this way, the rearrangement logic in the rearrangement instruction can be simplified to obtain the first instruction and the second instruction with smaller computational amounts, thereby reducing the occupancy of computing resources during the data rearrangement process and improving the efficiency of data rearrangement. Specifically, the sub-instructions that meet the preset rules can be replaced according to the preset variables to obtain updated instructions. The preset variable can be used to represent the cache index of the sub-data in the cached data and is used to indicate the second position information of the sub-data in the cached data. Then, based on the updated instruction, the correspondence between the first index and the cache index is determined to indicate the mapping relationship between the first position information and the second position information of the sub-data, and the first instruction is obtained. And based on the updated instruction, the correspondence between the cache index and the second index is determined to indicate the mapping relationship between the second position information and the third position information of the sub-data, and the second instruction is obtained.
[0060] Among them, the programming languages corresponding to the first instruction and the second instruction are the same as the programming language for writing the rearrangement instruction. For example, the programming languages corresponding to the first instruction and the second instruction can be the Python language, can also be the Java language, or can also be the C language. The present application does not limit this. Specifically, for the method of determining the first instruction and the second instruction, please refer to Figure 4 the corresponding detailed description.
[0061] S24, based on the first position information, perform a first rearrangement operation on the sub-data according to the first instruction to obtain cached data; the first instruction is used to indicate the mapping relationship between the first position information and the second position information of the sub-data in the cached data.
[0062] In an embodiment of the present application, the first instruction is used to indicate the mapping relationship between the first position information and the second position information of the sub-data in the cached data. Among them, this mapping relationship is used to represent the correspondence between the first index and the cache index, and the data dimension indicated by the cache index is less than or equal to the data dimension indicated by the first index. Specifically, process the first index used to represent the first position information of the sub-data based on the first instruction to obtain the value of the cache index; determine the second position information of the corresponding sub-data in the cached data according to the value of the cache index; arrange all sub-data according to the second position information of each sub-data to obtain cached data.
[0063] For example, when the preset programming language is the Python language, the content included in the first instruction can be: "for ax0,ax1 in T.grid(96,68216):
[0064] with T.block("Initial data"):
[0065] a, b = T.axis.remap("SS", [ax0, ax1]);
[0066] The cached data [b, a * 8 + c] = the input data [b / / 32, (a * 8 + c) / / 49, b % 32, (a * 8 + c) % 49]".
[0067] Among them, "the cached data [b, a * 8 + c]" is used to represent the value of the cache index and can indicate the second position information of the sub - data in the cached data. Specifically, "b" is used to represent the value of the first dimension in the cache index, and "a * 8 + c" is used to represent the value of the second dimension in the cache index. When the value of a is 8526, the value of b is 96, and the value of c is 8, the first index of the input data can be [1392, 3, 0, 8], and the corresponding cache index can be [96, 68216]. The sub - data indicated by this cache index is the sub - data in the input data with the first index [1392, 3, 0, 8], and this sub - data is in the 96th row and 68216th column of the cached data. Specifically, for the method of determining the cached data, please refer to Figure 5 the corresponding detailed description.
[0068] In this way, it is possible to determine the first position information of the sub - data in the high - dimensional input data according to the first index, and determine the cache index corresponding to the first index according to the first instruction, so as to determine the second position information of the sub - data in the cached data, providing data support for the subsequent rearrangement of the sub - data in the input data into the cached data.
[0069] In an embodiment of the present application, the cache index is used to represent the second position information of the sub - data in the cached data. After determining the cache index corresponding to the sub - data, the corresponding sub - data can be arranged according to the cache index, and a first rearrangement operation can be performed on the sub - data according to the cache index to obtain the cached data. Specifically, the first rearrangement operation includes: filling each sub - data in the input data to the position indicated by the corresponding cache index in the cached data.
[0070] Exemplarily, when the pixel value of the third channel in the pixel at the 8th column of the 0th row in the image data of the 1392nd batch in the input data is 255, the first index corresponding to this pixel value is [3, 1392, 0, 8]. According to the mapping relationship indicated by the first instruction, the cache index corresponding to this first index can be determined as [96, 68216]. Then, the pixel value 255 can be filled into the position at the 96th row and the 68216th column in the cache data. After filling all the sub-data in the input data into the positions indicated by the corresponding cache indices in the cache data, the cache data is obtained. Since the cache index indicates that the cache data includes two dimensions, the cache data obtained by rearranging the corresponding sub-data according to the cache index is two-dimensional data.
[0071] Exemplarily, as Figure 6 shown is a schematic diagram of the cache data 600. The cache data 600 is two-dimensional data obtained by rearranging the sub-data in the input data. Among them, the cache data 600 includes two dimensions: the first cache dimension 610 and the second cache dimension 620. For any sub-data in the cache data 600, the first cache dimension 610 of this sub-data can be used to represent the row where this sub-data is located in the cache data 600, and the second cache dimension 620 of this sub-data can be used to represent the column where this sub-data is located in the cache data 600. Among them, the value range of the first cache dimension 610 can be from 0 to 95, and the value range of the second cache dimension 620 can be from 0 to 68215. The value range of the first cache dimension 610 is used to represent that the cache data includes 96 rows of data, and the value range of the second cache dimension 620 is used to represent that the cache data includes 68216 columns of data.
[0072] S25. According to the second position information, based on the second instruction, perform a second rearrangement operation on the sub-data in the cache data to obtain output data; the second instruction is used to indicate the mapping relationship between the second position information and the third position information of the sub-data in the output data.
[0073] In an embodiment of the present application, the second instruction is used to determine the second index corresponding to the sub-data in the output data according to the cache index corresponding to the sub-data in the cache data, which can indicate the mapping relationship between the second position information and the third position information of the sub-data in the output data, and the data dimension of the output data is different from that of the input data. Among them, the output data can be data for training an artificial intelligence model. Since the data dimension indicated by the second index is different from the data dimension indicated by the first index, when rearranging the sub-data in the input data according to the second index, the dimension of the obtained output data is also different from that of the input data. Specifically, based on the second instruction, the cache index for characterizing the second position information of the sub-data is processed to obtain the value of the second index; the third position information of the corresponding sub-data is determined according to the value of the second index; all sub-data are arranged according to the third position information of each sub-data to obtain the output data.
[0074] Specifically, for the method of performing a second rearrangement operation on the sub-data in the cache data based on the second instruction to obtain the output data, please refer to Figure 7 the corresponding detailed description.
[0075] For example, when the preset programming language is the Python language, the content included in the second instruction can be: "for ax0,ax1,ax2 in T.grid(8526,96,8):
[0076] with T.block("cache data"):
[0077] a,b,c=T.axis.remap("SS",[ax0,ax1,ax2]);
[0078] output data[a,b,c]=cache data[b,a*8+c]".
[0079] Among them, "output data[a,b,c]" is used to characterize the second index in the output data, which can indicate the third position information of the sub-data in the output data. Among them, "a" is used to characterize the value of the first output dimension in the second index, "b" is used to characterize the value of the second output dimension in the second index, and "c" is used to characterize the value of the third output dimension in the second index. When the value of a is 8526, the value of b is 96, and the value of c is 8, the cache index can be [96, 68216], and the corresponding second index of the output data can be [8526, 96, 8], representing that the sub-data with the cache index [96, 68216] in the cache data is in the 8526th row, 96th column, and 8th channel in the output data.
[0080] In an embodiment of the present application, the second index is used to represent the position of the sub-data in the output data. After determining the second index corresponding to the sub-data according to the cache index, the corresponding sub-data can be arranged according to the second index, and a first rearrangement operation can be performed on the sub-data according to the second index to obtain the output data. Specifically, the second rearrangement operation includes: filling each sub-data in the cache data to the position indicated by the corresponding second index in the output data. Among them, the output data meets the format requirements of the input data of the artificial intelligence model to be trained. For example, when the input data of the artificial intelligence model is three-dimensional data, the output data is also three-dimensional data.
[0081] In an embodiment of the present application, the output data includes one or more of image data, text data, and voice data. Specifically, the information in the output data is the same as the information in the input data. For example, if the input data is image data pre-collected for training an object detection model, the output data includes image data; if the input data is text data pre-collected for training a natural language model, the output data includes text data; if the input data is voice data pre-collected for training a speech recognition model, the output data includes voice data.
[0082] Exemplarily, when the input data is multiple batches of image data, the output data can be obtained by rearranging the sub-data in the multiple batches of image data. If a certain sub-data belongs to the image data of the 1392nd batch in the input data, and this sub-data is the pixel value of the 3rd channel in the pixel at the 0th row and 8th column of the image data of this batch, then this sub-data is the data at the 96th row and 68216th column in the cache data, and this sub-data is the data at the 8526th row, 96th column, and 8th channel in the output data. For example, when the pixel value of the 3rd channel in the pixel at the 0th row and 8th column of the image data of the 1392nd batch in the input data is 255, the first index corresponding to this pixel value is [3, 1392, 0, 8]. The cache index corresponding to this first index can be determined as [96, 68216]. According to the mapping relationship indicated by the second instruction, the second index corresponding to this cache index can be determined as [8526, 96, 8]. Then, the pixel value 255 can be filled to the position at the 8526th row, 96th column, and 8th channel in the output data. After filling all the sub-data in the cache data to the positions indicated by the corresponding second indexes in the output data, the output data is obtained. Since the second index indicates that the output data includes three dimensions, the output data obtained by rearranging the sub-data in the corresponding cache data according to the second index is three-dimensional data.
[0083] Exemplarily, such as Figure 8The following is a schematic diagram of the output data 800. The output data 800 is two-dimensional data obtained by rearranging sub-data in the cached data, and this output data meets the format requirements of the input data of the artificial intelligence model to be trained. Among them, the output data 800 includes two dimensions: the first output dimension 810 and the second output dimension 820. For any sub-data in the output data 800, the first output dimension 810 of this sub-data can be used to represent the row where this sub-data is located in the output data 800, and the second output dimension 820 of this sub-data can be used to represent the column where this sub-data is located in the cached data 800. Among them, the value range of the first cached dimension 810 can be from 0 to 95, and the value range of the second cached dimension 820 can be from 0 to 68215. The value range of the first cached dimension 810 is used to represent that the cached data includes 96 rows of data, and the value range of the second cached dimension 820 is used to represent that the cached data includes 68216 columns of data.
[0084] It can be seen from the above technical solutions that the embodiment of the present application can split the rearrangement instruction based on a preset indivisible rule to obtain a first instruction and a second instruction, thereby simplifying the logic of data rearrangement during the data rearrangement process, and improving the efficiency of data rearrangement. Map the first position information of the sub-data in the input data according to the first instruction to determine the second position information of the sub-data in the cached data, and map the second position information according to the second instruction to determine the third position information of the sub-data in the output data. Thus, the sub-data of the input data is mapped twice to obtain the output data, and the sub-data in the input data can be rearranged at least twice to obtain the output data that meets the input requirements of the artificial intelligence model, thereby reducing the computational complexity of a single data rearrangement, reducing the occupancy of computing resources, and improving the efficiency of data rearrangement.
[0085] As Figure 4 shown, it is a flowchart of a method for determining the first instruction and the second instruction provided by an embodiment of the present application. According to different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted. The method for determining the first instruction and the second instruction provided by the embodiment of the present application includes the following steps.
[0086] S30, update the sub-instruction according to the preset rule to obtain an updated instruction.
[0087] In an embodiment of the present application, multiple sub-instructions in the rearrangement instruction can be used to determine a corresponding second index according to a first index in the input data, and rearrange sub-data in the input data according to the second index to obtain output data. Among them, the rearrangement instruction can be a program written in a preset programming language, and the preset programming language can be the Python language, or the Java language, or the C language. The present application does not limit this. For example, when the preset programming language is the Python language, the content included in the rearrangement instruction can be "for i0,i1,i2 in T.grid(8526,96,8):
[0088] with T.block("Input data"):
[0089] a,b,c=T.axis.remap("SSS",[i0,i1,i2]);
[0090] Output data[a,b,c]=Input data[b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]".
[0091] Among them, the rearrangement instruction includes multiple sub-instructions, and the multiple sub-instructions are used to determine the first position information of the sub-data in the input data according to the numerical values of multiple dimensions of the sub-data. For example, "Input data[b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]" in the rearrangement instruction is used to indicate the first index of any sub-data in the input data. Among them, the sub-instruction "b / / 32" is used to represent the value of the first original dimension in the first index, the sub-instruction "(a*8+c) / / 49" is used to represent the value of the second original dimension in the first index, the sub-instruction "b%32" is used to represent the value of the third original dimension in the first index, and the sub-instruction "(a*8+c)%49" is used to represent the value of the fourth original dimension in the first index.
[0092] In an embodiment of the present application, since a large amount of calculation in the sub-instruction may cause the mapping relationship between the first index and the second index to occupy more computing resources, thereby resulting in low efficiency of data rearrangement, the form of the sub-instruction can be rewritten based on a preset indivisibility rule to obtain a first instruction and a second instruction. Specifically, multiple sub-instructions in the rearrangement instruction can be traversed, and the sub-instructions that meet the indivisibility rule are replaced with preset variables, so as to update the sub-instructions according to the preset rule. Exemplarily, the sub-instruction "a*8+c" is a sub-instruction that meets the indivisibility rule, and this sub-instruction can be replaced with B. Then the form of the updated instruction is: "for i0,i1,i2 in T.grid(8526,96,8):
[0093] with T.block("Input data"):
[0094] a, b, c = T.axis.remap("SSS", [i0, i1, i2]);
[0095] Output data[a, b, c] = Input data[b / / 32, B / / 49, b % 32, B % 49]".
[0096] S31. Determine the mapping relationship between the first position information and the second position information based on the updated instruction to obtain the first instruction.
[0097] In an embodiment of the present application, the first instruction is used to indicate the mapping relationship between the first position information and the second position information of the sub-data in the cached data. Specifically, this mapping relationship is used to represent the correspondence between the first index and the cache index, and the data dimension indicated by the cache index is less than or equal to the data dimension indicated by the first index. For example, when the preset programming language is Python, the content included in the first instruction may be: "for ax0, ax1 in T.grid(96, 68216):
[0098] with T.block("Initial data"):
[0099] a, b, = T.axis.remap("SS", [ax0, ax1]);
[0100] Cached data[b, B] = Input data[b / / 32, B / / 49, b % 32, B % 49]".
[0101] Wherein, the value of the preset variable B is equal to the value of the sub-instruction "a * 8 + c", that is, B = a * 8 + c.
[0102] S32. Determine the mapping relationship between the second position information and the third position information based on the updated instruction to obtain the second instruction.
[0103] In an embodiment of the present application, the second instruction is used to determine the second index corresponding to the sub-data in the output data according to the cache index corresponding to the sub-data in the cache data, which can indicate the mapping relationship between the second position information and the third position information of the sub-data in the output data, and the data dimension of the output data is different from that of the input data. Wherein, the output data can be data for training an artificial intelligence model. Since the data dimension indicated by the second index is different from the data dimension indicated by the first index, when the sub-data in the input data is rearranged according to the second index, the dimension of the obtained output data is also different from that of the input data. For example, when the preset programming language is Python, the content included in the second instruction can be: "for ax0, ax1, ax2 in T.grid(8526, 96, 8):
[0104] with T.block("Cache data"):
[0105] a, b, c = T.axis.remap("SS", [ax0, ax1, ax2]);
[0106] output_data[a, b, c] = cache_data[b, B]".
[0107] Wherein, the value of the preset variable B is equal to the value of the sub-instruction "a * 8 + c", that is, B = a * 8 + c; "output_data[a, b, c]" is used to represent the second index in the output data, which can indicate the third position information of the sub-data in the output data. Wherein, "a" is used to represent the value of the first output dimension in the second index, "b" is used to represent the value of the second output dimension in the second index, and "c" is used to represent the value of the third output dimension in the second index. When the value of a is 8526, the value of b is 96, and the value of c is 8, the cache index can be [96, 68216], and the corresponding second index of the output data can be [8526, 96, 8], representing the sub-data with the cache index [96, 68216] in the cache data, at the 8526th row, 96th column, and 8th channel in the output data.
[0108] As Figure 5 shown, it is a flowchart of a method for determining cache data provided by an embodiment of the present application. According to different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted. The method for determining cache data provided by the embodiments of the present application includes the following steps.
[0109] S40, based on the first instruction, respectively determine the corresponding second position information according to the first position information of each sub-data in the input data.
[0110] In an embodiment of the present application, the first instruction is used to indicate the mapping relationship between the first position information and the second position information of the sub-data in the cached data. This mapping relationship is used to represent the correspondence between the first index and the cache index, and the data dimension indicated by the cache index is less than or equal to the data dimension indicated by the first index. Specifically, the cache index is used to represent the second position information of the sub-data in the cached data. For example, when the preset programming language is Python, the content included in the first instruction may be: "for ax0,ax1 in T.grid(96,68216):
[0111] with T.block("Initial data"):
[0112] a,b,=T.axis.remap("SS",[ax0,ax1]);
[0113] cached_data[b,B] = input_data[b / / 32,B / / 49,b%32,B%49]".
[0114] Among them, the value of the preset variable B is equal to the value of the sub-instruction "a*8 + c", that is, B = a*8 + c; "cached_data[b,a*8 + c]" is used to represent the value of the cache index, which can indicate the second position information of the sub-data in the cached data. Specifically, "b" is used to represent the value of the first dimension in the cache index, and "a*8 + c" is used to represent the value of the second dimension in the cache index. When the value of a is 8526, the value of b is 96, and the value of c is 8, the first index of the input data can be [1392, 3, 0, 8], and the corresponding cache index can be [96, 68216]. The sub-data indicated by this cache index is the sub-data in the input data with the first index [1392, 3, 0, 8], and this sub-data is in the 96th row and 68216th column of the cached data. In this way, the first position information of the sub-data in the high-dimensional input data can be determined according to the first index in the input data, and the cache index corresponding to the first index can be determined according to the first instruction, so as to determine the second position information of the sub-data in the cached data.
[0115] S41. Arrange all sub-data according to the second position information of each sub-data to obtain the cached data.
[0116] In an embodiment of the present application, after determining the cache index corresponding to the sub-data, the corresponding sub-data can be arranged according to the cache index, and a first rearrangement operation can be performed on the sub-data according to the cache index to obtain the cached data. Specifically, the first rearrangement operation includes: filling each sub-data in the input data to the position indicated by the corresponding cache index in the cached data.
[0117] Exemplarily, when the pixel value of the third channel in the pixel at the 8th column of the 0th row in the image data of the 1392nd batch in the input data is 255, the first index corresponding to this pixel value is [3, 1392, 0, 8]. According to the mapping relationship in the first instruction, the cache index corresponding to this first index can be determined as [96, 68216]. Then, the pixel value 255 can be filled into the position at the 96th row and the 68216th column in the cache data. After filling all the sub-data in the input data into the positions indicated by the corresponding cache indices in the cache data, the cache data is obtained. Since the cache index indicates that the cache data includes two dimensions, the cache data obtained by rearranging the corresponding sub-data according to the cache index is two-dimensional data.
[0118] As Figure 7 shown, it is a flowchart of a method for determining output data provided by an embodiment of the present application. According to different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted. The method for determining output data provided by the embodiments of the present application includes the following steps.
[0119] S50, based on the second instruction, respectively determine the corresponding third position information according to the second position information of each sub-data in the cache data.
[0120] In an embodiment of the present application, the second instruction is used to determine the second index corresponding to the sub-data in the output data according to the cache index corresponding to the sub-data in the cache data. Among them, the mapping relationship between the cache index and the second index can indicate the mapping relationship between the second position information and the third position information of the sub-data in the output data, and the data dimension of the output data is different from that of the input data. Among them, the output data can be data for training an artificial intelligence model. Since the data dimension indicated by the second index is different from the data dimension indicated by the first index, when rearranging the sub-data in the input data according to the second index, the dimension of the obtained output data is also different from that of the input data. For example, when the preset programming language is the Python language, the content included in the second instruction can be: "for ax0, ax1, ax2 in T.grid(8526, 96, 8):
[0121] with T.block("cache data"):
[0122] a, b, c = T.axis.remap("SS", [ax0, ax1, ax2]);
[0123] output data[a, b, c] = cache data[b, B]".
[0124] Among them, the value of the preset variable B is equal to the value of the sub-instruction "a*8 + c", that is, B = a*8 + c; "output data [a, b, c]" is used to represent the second index in the output data, and can indicate the third position information of the sub-data in the output data. Among them, "a" is used to represent the value of the first output dimension in the second index, "b" is used to represent the value of the second output dimension in the second index, and "c" is used to represent the value of the third output dimension in the second index. When the value of a is 8526, the value of b is 96, and the value of c is 8, the cache index can be [96, 68216], and the corresponding second index of the output data can be [8526, 96, 8], representing the sub-data in the cache data with the cache index [96, 68216], at the 8526th row, 96th column, and 8th channel in the output data.
[0125] S51. Arrange all sub-data according to the third position information of each sub-data to obtain the output data.
[0126] In an embodiment of the present application, the second index is used to represent the position of the sub-data in the output data. After determining the second index corresponding to the sub-data according to the cache index, the corresponding sub-data can be arranged according to the second index, and a first rearrangement operation can be performed on the sub-data according to the second index to obtain the output data. Specifically, the second rearrangement operation includes: filling each sub-data in the cache data to the position indicated by the corresponding second index in the output data. Among them, the output data meets the format requirements of the input data of the artificial intelligence model to be trained. For example, when the input data of the artificial intelligence model is three-dimensional data, the output data is also three-dimensional data.
[0127] Please refer to Figure 9 , Figure 9 which is a functional module diagram of a data rearrangement device provided in an embodiment of the present application. A data rearrangement device 91 includes an acquisition module 910, a determination module 911, a splitting module 912, a first rearrangement module 913, and a second rearrangement module 914. The module / unit referred to in the present application means a series of computer-readable instruction segments that can be executed by a processor 13 and can complete fixed functions, and are stored in a memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0128] The acquisition module 910 is used to acquire input data, and the input data includes sub-data in multiple dimensions.
[0129] The determination module 911 is used to determine sub-instructions that meet preset rules from pre-stored rearrangement instructions.
[0130] The determining module 911 is further configured to calculate, by using the sub-instruction, the values of the sub-data corresponding to the multiple dimensions, so as to obtain first position information of the sub-data in the input data.
[0131] The splitting module 912 is configured to split the rearrangement instruction based on the sub-instruction, so as to obtain a first instruction and a second instruction.
[0132] The first rearrangement module 913 is configured to perform a first rearrangement operation on the sub-data based on the first instruction according to the first position information, so as to obtain cached data; the first instruction is used to indicate a mapping relationship between the first position information and second position information of the sub-data in the cached data.
[0133] The second rearrangement module 914 is configured to perform a second rearrangement operation on the sub-data in the cached data based on the second instruction according to the second position information, so as to obtain output data; the second instruction is used to indicate a mapping relationship between the second position information and third position information of the sub-data in the output data.
[0134] In some embodiments, the preset rule is an indivisibility rule, and the determining module 911 is further configured to: in a case where any one of the sub-instructions in the rearrangement instruction cannot be decomposed by the preset operation, determine that the any one of the sub-instructions is a sub-instruction that conforms to the preset rule.
[0135] In some embodiments, the determining module 911 is further configured to: simplify the rearrangement instruction based on a preset simplification rule, so as to obtain a simplified rearrangement instruction; in a case where any one of the sub-instructions in the simplified rearrangement instruction cannot be decomposed by the preset operation, determine that the any one of the sub-instructions is a sub-instruction that conforms to the preset rule.
[0136] In some embodiments, the splitting module 912 is further configured to: update the sub-instruction according to the preset rule, so as to obtain an updated instruction; determine a mapping relationship between the first position information and the second position information based on the updated instruction, so as to obtain the first instruction; determine a mapping relationship between the second position information and the third position information based on the updated instruction, so as to obtain the second instruction.
[0137] In some embodiments, the first rearrangement module 913 is further configured to: respectively determine corresponding second position information according to the first position information of each sub-data in the input data based on the first instruction; arrange all the sub-data according to the second position information of each sub-data, so as to obtain the cached data.
[0138] In some embodiments, the second rearrangement module 914 is further configured to: based on the second instruction, respectively determine corresponding third position information according to the second position information of each sub-data in the cached data; and arrange all the sub-data according to the third position information of each sub-data to obtain the output data.
[0139] Please refer to Figure 10 , which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. The electronic device 100 includes a memory 12 and a processor 13. The memory 12 is used to store computer-readable instructions, and the processor 13 is configured to execute the computer-readable instructions stored in the memory to implement the data rearrangement method described in any of the above embodiments.
[0140] In an embodiment of the present application, the electronic device 100 further includes a bus and a computer program stored in the memory 12 and executable on the processor 13, such as a data rearrangement program.
[0141] Figure 10 Only the electronic device 100 having the memory 12 and the processor 13 is shown. Those skilled in the art can understand that Figure 10 the shown structure does not limit the electronic device 100, and it may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0142] In combination with Figure 2 , the memory 12 in the electronic device 100 stores multiple computer-readable instructions to implement a data rearrangement method. The processor 13 can execute the multiple instructions to implement: obtaining input data, where the input data includes sub-data in multiple dimensions; determining, from pre-stored rearrangement instructions, sub-instructions that meet a preset rule; using the sub-instructions to calculate numerical values of the sub-data corresponding to the multiple dimensions to obtain first position information of the sub-data in the input data; splitting the rearrangement instructions based on the sub-instructions to obtain a first instruction and a second instruction; performing a first rearrangement operation on the sub-data based on the first instruction according to the first position information to obtain cached data; the first instruction is used to indicate a mapping relationship between the first position information and second position information of the sub-data in the cached data; performing a second rearrangement operation on the sub-data in the cached data based on the second instruction according to the second position information to obtain output data; the second instruction is used to indicate a mapping relationship between the second position information and third position information of the sub-data in the output data.
[0143] Specifically, for the specific implementation method of the above instructions by the processor 13, reference may be made to Figure 2 the description of the relevant steps in the corresponding embodiments, which will not be elaborated here.
[0144] Those skilled in the art can understand that the schematic diagram is only an example of the electronic device 100, and does not constitute a limitation on the electronic device 100. The electronic device 100 can be a bus structure or a star structure. The electronic device 100 can also include more or fewer other hardware or software than shown in the figure, or different component arrangements. For example, the electronic device 100 can also include input and output devices, network access devices, etc.
[0145] It should be noted that the electronic device 100 is only an example. Other existing or future electronic products that can be adapted to this application should also be included within the protection scope of this application and are hereby incorporated by reference.
[0146] Among them, the memory 12 includes at least one type of readable storage medium. The readable storage medium can be non-volatile or volatile. The readable storage medium includes flash memory, mobile hard disks, multimedia cards, card-type memories (such as SD or DX memories, etc.), magnetic memories, magnetic disks, optical disks, etc. The memory 12 can be an internal storage unit of the electronic device 100 in some embodiments, such as the mobile hard disk of the electronic device 100. The memory 12 can also be an external storage device of the electronic device 100 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the electronic device 100. The memory 12 can not only be used to store application software installed in the electronic device 100 and various types of data, such as the code of a data rearrangement program, etc., but also be used to temporarily store data that has been output or will be output.
[0147] The processor 13 can be composed of integrated circuits in some embodiments. For example, it can be composed of a single packaged integrated circuit, or can be composed of multiple integrated circuits with the same or different functions, including the combination of one or more Central Processing Units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips, etc. The processor 13 is the control core (Control Unit) of the electronic device 100, connecting various components of the entire electronic device 100 through various interfaces and circuits, and by running or executing programs or modules stored in the memory 12 (such as executing a data rearrangement program, etc.), and calling data stored in the memory 12, to perform various functions of the electronic device 100 and process data.
[0148] The processor 13 executes the operator system of the electronic device 100 and various installed application programs. The processor 13 executes the application programs to implement the steps in each of the above-described embodiments of the data rearrangement method, such as Figure 2 the steps shown.
[0149] Exemplarily, the computer program may be divided into one or more modules / units, and the one or more modules / units are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units may be a series of computer-readable instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program in the electronic device 100. For example, the computer program may be divided into an acquisition module 910, a determination module 911, a splitting module 912, a first rearrangement module 913, and a second rearrangement module 914.
[0150] The integrated units implemented in the form of software function modules as described above may be stored in a computer-readable storage medium. The above software function modules are stored in a storage medium and include several instructions for causing a computer device (which may be a personal computer, a computer device, or a network device, etc.) or a processor (Processor) to execute a part of the data rearrangement method described in each embodiment of the present application.
[0151] If the modules / units integrated in the electronic device 100 are implemented in the form of software function units and sold or used as independent products, they may be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above-described embodiment methods of the present application, it may also be completed by a computer program instructing relevant hardware devices. The computer program may be stored in a computer-readable storage medium, and when the computer program is executed by the processor, the steps of each of the above method embodiments may be implemented.
[0152] Among them, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disc, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory, and other memories, etc.
[0153] Further, the computer-readable storage medium mainly includes a program storage area and a data storage area. Among them, the program storage area may store the operator system, application programs required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0154] The bus can be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, in Figure 10 it is only represented by a single arrow, but it does not mean that there is only one bus or one type of bus. The bus is arranged to implement the connection and communication between the memory 12 and at least one processor 13, etc.
[0155] The embodiment of the present application also provides a computer-readable storage medium (not shown in the figure). Computer-readable instructions are stored in the computer-readable storage medium, and the computer-readable instructions are executed by a processor in the electronic device to implement the data rearrangement method described in any of the above embodiments.
[0156] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0157] The modules described as separate components may or may not be physically separated. The components shown as modules may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0158] In addition, in each embodiment of the present application, the functional modules can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware, or in the form of a combination of hardware and software functional modules.
[0159] In addition, obviously, the word "including" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or devices described in the specification can also be implemented by one unit or device through software or hardware. Words such as first and second are used to represent names and do not indicate any specific order.
[0160] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit them. Although the present application has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present application can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present application.
Claims
1. A data rearrangement method, applied to an electronic device, characterized in that: The method comprises: Acquire input data, wherein the input data includes sub-data of multiple dimensions; Determining a sub-instruction that complies with a preset rule from pre-stored rearrangement instructions; Calculate the values of the sub-data corresponding to the multiple dimensions using the sub-instruction to obtain first position information of the sub-data in the input data; Splitting the reorder instruction based on the sub-instructions to obtain a first instruction and a second instruction; According to the first position information, a first rearrangement operation is performed on the sub-data based on the first instruction to obtain cache data; the first instruction is used to indicate a mapping relationship between the first position information and second position information of the sub-data in the cache data; According to the second position information, a second rearrangement operation is performed on the sub-data in the cache data based on the second instruction to obtain output data; the second instruction is used to indicate a mapping relationship between the second position information and third position information of the sub-data in the output data.
2. The data rearrangement method according to claim 1, characterized in that: The preset rule is an indivisible rule, and determining a sub-instruction that meets the preset rule from the pre-stored rearrangement instructions includes: In the case that any one of the sub-instructions in the rearrangement instruction cannot be decomposed by a preset operation, the any one of the sub-instructions is determined to be a sub-instruction that complies with a preset rule.
3. The data rearrangement method according to claim 1, characterized in that: The step of determining a sub-instruction that complies with a preset rule from the pre-stored rearrangement instructions includes: Simplifying the rearrangement instruction based on a preset simplification rule to obtain a simplified rearrangement instruction; In the case that any one of the sub-instructions in the simplified rearrangement instruction cannot be decomposed by the preset operation, the any one of the sub-instructions is determined to be a sub-instruction that complies with the preset rule.
4. The data rearrangement method according to claim 2 or 3, characterized in that: The preset operation includes an integer division operation and / or a modulo operation.
5. The data rearrangement method according to claim 1, characterized in that: The step of splitting the reordering instruction based on the sub-instruction to obtain the first instruction and the second instruction comprises: updating the sub-instruction according to the preset rule to obtain an updated instruction; Determine a mapping relationship between the first location information and the second location information based on the updated instruction to obtain the first instruction; A mapping relationship between the second location information and the third location information is determined based on the updated instruction to obtain the second instruction.
6. The data rearrangement method according to claim 1, characterized in that: The performing a first rearrangement operation on the sub-data based on the first instruction according to the first location information to obtain cache data includes: Based on the first instruction, determine the corresponding second position information respectively according to the first position information of each sub-data in the input data; All sub-data are arranged according to the second position information of each sub-data to obtain the cache data.
7. The data rearrangement method according to claim 1, characterized in that: The performing a second rearrangement operation on the sub-data in the cache data based on the second instruction according to the second position information to obtain output data comprises: Based on the second instruction, respectively determine corresponding third position information according to the second position information of each sub-data in the cache data; All the sub-data are arranged according to the third position information of each sub-data to obtain the output data.
8. A data rearrangement device, characterized in that: The device comprises: An acquisition module, used for acquiring input data, wherein the input data includes sub-data of multiple dimensions; A determination module, used to determine a sub-instruction that meets a preset rule from pre-stored rearrangement instructions; The determination module is further configured to calculate the values of the sub-data corresponding to the multiple dimensions using the sub-instruction to obtain first position information of the sub-data in the input data; A splitting module, used for splitting the reordering instruction based on the sub-instruction to obtain a first instruction and a second instruction; A first rearrangement module, configured to perform a first rearrangement operation on the sub-data based on the first instruction according to the first position information to obtain cache data; the first instruction is configured to indicate a mapping relationship between the first position information and second position information of the sub-data in the cache data; A second rearrangement module is used to perform a second rearrangement operation on the sub-data in the cache data according to the second position information and based on the second instruction to obtain output data; the second instruction is used to indicate a mapping relationship between the second position information and the third position information of the sub-data in the output data.
9. An electronic device, characterized in that: The electronic device comprises a processor and a memory, and the processor is used to implement the data rearrangement method according to any one of claims 1 to 7 when executing a computer program stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data rearrangement method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
FPGA (Field Programmable Gate Array) comparator resource allocation method and system for network telemetering rearrangement
CN120750891A
Data rearrangement method and apparatus, and electronic device and storage medium
WO2026179216A1