Data rearrangement method and apparatus, and electronic device and storage medium

WO2026179216A1PCT designated stage Publication Date: 2026-09-03SHENZHEN INTELLIFUSION TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/132086
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-02-28
Filing Date
2025-11-03
Publication Date
2026-09-03

Smart Images

  • Figure CN2025132086_03092026_PF_FP_ABST
    Figure CN2025132086_03092026_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are a data rearrangement method and apparatus, and an electronic device and a storage medium. The data rearrangement method comprises: acquiring input data comprising sub-data of a plurality of dimensions; determining, from pre-stored rearrangement instructions, sub-instructions that satisfy a preset rule; by means of the sub-instructions, determining first positional information of the sub-data in the input data; splitting the rearrangement instructions on the basis of the sub-instructions, so as to obtain a first instruction and a second instruction; on the basis of the first positional information and the first instruction, performing a first rearrangement operation on the sub-data, so as to obtain cache data, wherein the first instruction indicates a mapping relationship between the first positional information and second positional information of the sub-data in the cache data; and on the basis of the second positional information and the second instruction, performing a second rearrangement operation on the sub-data in the cache data, so as to obtain output data, wherein the second instruction indicates a mapping relationship between the second positional information and third positional information of the sub-data in the output data. The present application relates to the technical field of data rearrangement, and can improve the efficiency of data rearrangement.
Need to check novelty before this filing date? Find Prior Art

Description

Data rearrangement methods, apparatus, electronic devices and storage media Technical Field

[0001] This application relates to the field of data rearrangement technology, and in particular to a data rearrangement method, apparatus, electronic device and storage medium.

[0002] This application claims priority to Chinese Patent Application No. 202510257403.2, filed on February 28, 2025, entitled “Data Rearrangement Method, Apparatus, Electronic Device and Storage Medium”, the entire contents of which are incorporated herein by reference. Background Technology

[0003] With the development of artificial intelligence (AI) technology, more and more organizations and individuals are inclined to use AI models for data analysis to assist production and thus improve productivity. To improve the accuracy of the model's output, it is necessary to train the AI ​​model using training data. To ensure that the dimensionality of the training data matches the dimensionality of the AI ​​model's input data, the dimensionality of the training data typically needs to be adjusted.

[0004] Currently, the positions of sub-data in the original data are typically determined based on pre-set rearrangement instructions, and these positions are then transformed to adjust the dimensions of the original data. However, because the computational logic of rearrangement instructions is complex and irregular, this data rearrangement method usually requires additional computing and storage resources, resulting in low data rearrangement efficiency. Technical issues

[0005] In view of the above, it is necessary to propose a data rearrangement method, apparatus, electronic device and storage medium to solve the technical problem of low efficiency when rearranging data.

[0006] This application provides a data rearrangement method applied to an electronic device. The method includes: acquiring input data, the input data including sub-data of multiple dimensions; determining sub-instructions conforming to preset rules from pre-stored rearrangement instructions; calculating the values ​​of the sub-data corresponding to the multiple dimensions using the sub-instructions 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 the 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 position information and the second instruction to obtain output data; the second instruction is used to indicate the mapping relationship between the second position information and a third position information of the sub-data in the output data.

[0007] This application embodiment also provides a data rearrangement apparatus, the apparatus comprising: an acquisition module for acquiring input data, the input data including sub-data of multiple dimensions; a determination module for determining sub-instructions conforming to preset rules from pre-stored rearrangement instructions; the determination module is further configured to use the sub-instructions to calculate the values ​​of the sub-data corresponding to the multiple dimensions, thereby obtaining first position information of the sub-data in the input data; a splitting module for splitting the rearrangement instructions based on the sub-instructions, thereby obtaining 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 position information and the first instruction, thereby obtaining cached data; the first instruction is used to indicate the mapping relationship between the first position information and a 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 position information and the second instruction, thereby obtaining output data; the second instruction is used to indicate the mapping relationship between the second position information and a third position information of the sub-data in the output data.

[0008] This application also provides an electronic device, comprising: a memory storing at least one instruction; and a processor executing the instructions stored in the memory to implement the data rearrangement method described above.

[0009] This application also provides a computer-readable storage medium storing at least one instruction, which is executed by a processor in an electronic device to implement the data rearrangement method described above.

[0010] As can be seen from the above technical solutions, the embodiments of this application can split the rearrangement instructions based on preset indivisible rules to obtain the first instruction and the second instruction, thereby simplifying the logic of data rearrangement and improving the efficiency of data rearrangement. The first instruction maps the first position information of the sub-data in the input data to determine the second position information of the sub-data in the cached data, and the second instruction maps the second position information to determine the third position information of the sub-data in the output data. Thus, by performing two mappings on the sub-data of the input data to obtain the output data, the sub-data in the input data can be rearranged at least twice to obtain output data that meets the input requirements of the artificial intelligence model, thereby reducing the computational complexity of a single data rearrangement, reducing the consumption of computing resources, and improving the efficiency of data rearrangement. Attached Figure Description

[0011] Figure 1 is an application scenario diagram of a data rearrangement method provided in an embodiment of this application.

[0012] Figure 2 is a flowchart of a data rearrangement method provided in an embodiment of this application.

[0013] Figure 3 is a schematic diagram of input data provided in an embodiment of this application.

[0014] Figure 4 is a flowchart of a method for determining a first instruction and a second instruction according to an embodiment of this application.

[0015] Figure 5 is a flowchart of a method for determining cached data according to an embodiment of this application.

[0016] Figure 6 is a schematic diagram of cached data provided in an embodiment of this application.

[0017] Figure 7 is a flowchart of a method for determining output data provided in an embodiment of this application.

[0018] Figure 8 is a schematic diagram of the output data provided in an embodiment of this application.

[0019] Figure 9 is a functional block diagram of a data rearrangement device provided in an embodiment of this application.

[0020] Figure 10 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Embodiments of the present invention

[0021] This application provides a data rearrangement method that 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, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0022] Electronic devices can be any electronic product that allows human-computer interaction with a customer, such as personal computers, tablets, smartphones, personal digital assistants (PDAs), game consoles, interactive network television (IPTV), smart wearable devices, etc.

[0023] Electronic devices may also include network devices and / or client devices. The network devices include, but are not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.

[0024] The networks in which electronic devices are located include, but are not limited to, the Internet, wide area networks, metropolitan area networks, local area networks, and virtual private networks (VPNs).

[0025] As shown in Figure 1, the data rearrangement method provided in this application can be applied to an electronic device 100, which is communicatively connected to a database 200. The electronic device 100 can be an edge computing device. Specifically, the electronic device 100 is used to train an artificial intelligence model. This artificial intelligence model can be a target detection model for detecting human targets in images, a natural language model for analyzing text, or a speech recognition model for analyzing speech data; this application does not limit the specific model to any of these.

[0026] Database 200 is used to store pre-collected input data. Specifically, the input data is used to train the artificial intelligence model. For example, if the artificial intelligence model is a target detection model for detecting human targets 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. The input data includes sub-data with multiple dimensions. When training the artificial intelligence model based on the input data in database 200, to ensure that the dimensions of the data input to the artificial intelligence model meet the model's input requirements, multiple sub-data in the input data need to be rearranged to obtain output data that meets the model's input requirements.

[0027] Specifically, the electronic device 100 can traverse the sub-instructions in the preset rearrangement instructions, determine the sub-instructions that satisfy the preset indivisibility rules, and update the sub-instructions according to the indivisibility rules to obtain the first instruction and the second instruction. The first instruction and the second instruction occupy less computing resources than the rearrangement instructions. Based on the first instruction, a first index corresponding to the sub-data in the input data is determined to represent the first position information of the sub-data in the input data. Then, based on the mapping relationship indicated by the first instruction, a cache index corresponding to the first index is determined to determine the second position information of the sub-data in the cached data. Finally, a first rearrangement operation is performed on the sub-data according to the cache index to obtain the cached data, thereby performing the first rearrangement of the sub-data in the input data to achieve the first dimensional transformation.

[0028] The electronic device 100 further determines a second index corresponding to the cache index based on the second instruction, in order to determine the third position information of the sub-data in the output data. Then, it performs a second rearrangement operation on the sub-data in the cache data according to the second index to obtain the output data. In this way, the input data can be transformed into output data that conforms to the input dimensions of the artificial intelligence model through two index transformations, reducing the computational load of a single rearrangement process and thus improving the efficiency of data rearrangement.

[0029] Figure 2 shows a flowchart of a data rearrangement method according to an embodiment of this application. The order of the steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements. The data rearrangement method provided in this embodiment includes the following steps.

[0030] S20, Obtain input data, which includes sub-data of multiple dimensions.

[0031] In one embodiment of this application, the input data can be data used to train an artificial intelligence model. For example, if the artificial intelligence model is an object detection model for detecting human targets in an image, the input data can 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 can be text data pre-collected for training the natural language model.

[0032] In one embodiment of this application, the input data includes sub-data with 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 can be (8526, 96, 8). This dimension represents that the input data of the artificial intelligence model has three dimensions, each including 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 has 32 rows, 64 columns, 3 channels, and 1392 batches of data. Specifically, the input data can be 1392 batches of image data, where each batch of image data includes 32 rows and 64 columns of pixels, and each pixel includes 3 channel values, where the three channel values ​​can be the RGB pixel values ​​of each pixel in the image. To ensure that the input data can be used to train the object detection model, the input data with 3 channels, 1392 batches, 32 rows, and 64 columns needs to be converted into input data with 96 rows, 8 columns, and 8526 channels.

[0033] Figure 3 shows a schematic diagram of input data 300. Input data 300 can be multiple image data sets and has four dimensions. The first original dimension 310 represents the number of channels in the pixels of the image data, and the number of channels can be 3. The second original dimension 320 represents the batch size of the multiple image data sets used to train the artificial intelligence model, and the number of batches can be 1392. The third original dimension 330 represents the number of rows in each batch of image data, and the number of rows can be 32. The fourth original dimension 340 represents the number of columns in each batch of image data, and the number of columns can be 64.

[0034] S21, determine the sub-instruction that conforms to the preset rules from the pre-stored rearrangement instructions.

[0035] In one embodiment of this application, to ensure that the artificial intelligence model can receive and process information from the input data, it is necessary to ensure that the dimensions of the data input to the artificial intelligence model conform to the architecture of the artificial intelligence model. Specifically, to ensure that the artificial intelligence model can be trained based on the input data, pre-written rearrangement instructions can be used to rearrange the sub-data of multiple dimensions in the input data to obtain output data, ensuring that the dimensions of the output data meet the requirements of the artificial intelligence model. The rearrangement instructions can be programs written in a preset programming language, used to indicate the mapping relationship between a first index and a second index. The first index is used to indicate 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. The preset programming language can be Python, Java, or C; this application does not limit this.

[0036] For example, when the default programming language is Python, the reordering instruction could include the following: "for i0,i1,i2 in T.grid(8526,96,8):

[0037] with T.block("input data"):

[0038] a,b,c = T.axis.remap("SSS",[i0,i1,i2]);

[0039] Output data [a,b,c] = Input data [b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]".

[0040] The rearrangement instruction includes multiple sub-instructions, which determine the first position information of a sub-data item in the input data based on multiple dimension values ​​of the sub-data item. For example, the rearrangement instruction "input data [b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]" indicates the first index of any sub-data item in the input data. Specifically, the sub-instruction "b / / 32" represents the value of the first original dimension in the first index, "(a*8+c) / / 49" represents the value of the second original dimension in the first index, "b%32" represents the value of the third original dimension in the first index, and "(a*8+c)%49" represents the value of the fourth original dimension in the first index.

[0041] In one embodiment of this application, the computational logic of sub-instructions is relatively complex, resulting in low efficiency in determining the first position information of sub-data in the input data based on the dimension value of sub-data, thus leading to low efficiency in data rearrangement. To improve the efficiency of data rearrangement, multiple sub-instructions in the rearrangement instruction can be filtered according to preset rules to determine sub-instructions that conform to the preset rules. Specifically, multiple sub-instructions can be traversed according to their arrangement order in the rearrangement instruction; it can be determined whether the traversed sub-instruction conforms to the preset rules; if the traversed sub-instruction conforms to the preset rules, it can be determined that the computational logic of the sub-instruction cannot be simplified further. The preset rules are indivisible rules; if any sub-instruction in the rearrangement instruction cannot be decomposed by the preset operation, then that sub-instruction is determined to conform to the preset rules.

[0042] In one embodiment of this application, the preset operations include integer division and / or modulo operations. If any sub-instruction cannot be simplified further by integer division and / or modulo operations, it indicates that the calculation logic of the sub-instruction cannot be simplified further, and therefore it can be determined that the sub-instruction conforms to the preset indivisibility rule. For example, if the sub-instruction is “a*16+c*2 / / 2”, it can be simplified to “a*8+c” by integer division, therefore this sub-instruction does not conform to the preset indivisibility rule; if the sub-instruction is “a*8+c / / 1”, it cannot be simplified further by integer division and / or modulo operations, indicating that this sub-instruction conforms to the preset indivisibility rule.

[0043] In one embodiment of this application, in order to improve the efficiency of determining sub-instructions that conform to preset rules, the method further includes: simplifying the rearrangement instructions based on preset simplification rules to obtain simplified rearrangement instructions; and determining that any sub-instruction in the simplified rearrangement instructions is a sub-instruction that conforms to preset rules if any sub-instruction cannot be decomposed by the preset operation.

[0044] The preset simplification rules include: the characters in the sub-instruction satisfy a preset arrangement order, and the characters satisfy a first quantization relationship. For example, 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 a greatest common divisor. For example, a sub-instruction satisfying this first condition can be "2*a+4*b+6*c / / 7". To rewrite the form of the sub-instruction, thereby reducing its computational complexity while retaining its calculation logic, a simplified rearrangement instruction can be determined based on the greatest common divisor and the sub-instruction, provided that the sub-instruction includes preset characters and multiple characters in the sub-instruction have a greatest common divisor. 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 based on the new coefficient and multiple characters. The preset character can be a division character. For example, when the subinstruction is “2*a+4*b+6*c / / 7”, it can be determined that the subinstruction includes a division character, and the multiple characters in the subinstruction have a greatest common divisor of 2. Then, the coefficient of each character can be divided by the greatest common divisor to obtain a new coefficient. The simplified rearrangement instruction determined based on the new coefficient and the multiple characters can be “a+2*b+3*c / / 7”.

[0045] In one embodiment of this application, the preset simplification rule can also be that the sub-instruction satisfies the form "(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 is "x%y".

[0046] In one embodiment of this application, the preset simplification rule can also be that the sub-instruction satisfies the form "(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 is "0".

[0047] In one embodiment of this application, the preset simplification rule can also be that the sub-instruction satisfies the form "(x*c1+y) / / (k*c1)" and "y<1", where x, y, and k are variable characters, and c1 is a constant character. Then, after simplifying the rearrangement instruction based on the preset simplification rule, the simplified rearrangement instruction is "x / / k".

[0048] S22, using the sub-instruction to calculate the values ​​of the sub-data corresponding to the multiple dimensions, to obtain the first position information of the sub-data in the input data.

[0049] In one embodiment of this application, in order to adjust the position 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; the values ​​of the multiple dimensions corresponding to the sub-data can be calculated using multiple sub-instructions in the rearrangement instruction 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 of the input data can be determined based on the first position information.

[0050] For example, when the default programming language is Python, the reordering instruction could include the following: "for i0,i1,i2 in T.grid(8526,96,8):

[0051] with T.block("input data"):

[0052] a,b,c = T.axis.remap("SSS",[i0,i1,i2]);

[0053] Output data [a,b,c] = Input data [b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]".

[0054] The instruction "[b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]" represents the first index in the input data. The sub-instruction "b / / 32" represents the value of the first original dimension in the first index, "(a*8+c) / / 49" represents the value of the second original dimension in the first index, "b%32" represents the value of the third original dimension in the first index, and "(a*8+c)%49" represents the value of the fourth original dimension in the first index.

[0055] For example, when 'a' is 8526, 'b' is 96, and 'c' is 8, the first original dimension of the first index has a value of 3, the second original dimension has a value of 1392, the third original dimension has a value of 0, and the fourth original dimension has a value of 8. If the input data consists of multiple batches of image data, then the sub-data corresponding to this first index belongs to the 1392nd batch of image data in the input data, and this sub-data is the pixel value of the 3rd channel of the pixel in the 0th row and 8th column of that batch of image data.

[0056] S23, based on the sub-instruction, split the rearranged instruction to obtain the first instruction and the second instruction.

[0057] In one embodiment of this application, since the computational load of multiple sub-instructions implementing the reordering logic in the reordering instruction is large, the form of the sub-instructions can be edited to split the reordering instruction into a first instruction and a second instruction based on the sub-instructions. This simplifies the reordering logic in the reordering instruction, resulting in a first instruction and a second instruction with less computational load, thereby reducing the consumption of computing resources and improving the efficiency of data reordering during the data reordering process. Specifically, sub-instructions that satisfy preset rules can be replaced according to preset variables to obtain updated instructions. The preset variables can be used to characterize the cache index of the sub-data in the cached data, indicating the second position information of the sub-data in the cached data. Then, based on the updated instructions, 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, thus obtaining the first instruction. And based on the updated instructions, 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, thus obtaining the second instruction.

[0058] The programming language corresponding to the first and second instructions is the same as the programming language used to write the rearranged instructions. For example, the programming language corresponding to the first and second instructions can be Python, Java, or C; this application does not limit this. For a detailed explanation of the method for determining the first and second instructions, please refer to Figure 4.

[0059] 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.

[0060] In one embodiment of this application, a first instruction is used to indicate a mapping relationship between first location information and second location information of sub-data in cached data. This mapping relationship characterizes the correspondence between a first index and a 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 first index, used to characterize the first location information of sub-data, is processed based on the first instruction to obtain the value of the cache index; the second location information of the corresponding sub-data in the cached data is determined based on the value of the cache index; and all sub-data are arranged according to the second location information of each sub-data to obtain the cached data.

[0061] For example, if the default programming language is Python, the first instruction could include: "for ax0,ax1 in T.grid(96,68216):

[0062] with T.block("initial data"):

[0063] a,b,= T.axis.remap("SS",[ax0,ax1]);

[0064] Cache data [b, a*8+c] = input data [b / / 32, (a*8+c) / / 49, b%32, (a*8+c)%49]".

[0065] Here, "cached data [b, a*8+c]" represents the value of the cache index, indicating the second position of the sub-data within the cache data. Specifically, "b" represents the value of the first dimension in the cache index, and "a*8+c" represents the value of the second dimension. When a is 8526, b is 96, and 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]. This cache index indicates the sub-data with the first index [1392, 3, 0, 8] in the input data, located in row 96 and column 68216 of the cache data. For a detailed explanation of how to determine the cache data, please refer to Figure 5.

[0066] In this way, the first position information of the sub-data in the input data can be determined based on the first index in the high-dimensional input data, and the cache index corresponding to the first index can be determined based on the first instruction, thereby determining the second position information of the sub-data in the cache data, providing data support for the subsequent rearrangement of the sub-data in the input data into the cache data.

[0067] In one embodiment of this application, a cache index is used to characterize the second position information of sub-data in 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 into the position indicated by the corresponding cache index in the cached data.

[0068] For example, in the image data of the 1392nd batch of input data, when the pixel value of the 3rd channel of the pixel in row 0, column 8 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 to be [96, 68216]. Therefore, the pixel value 255 can be filled into the position of row 96, column 68216 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.

[0069] For example, Figure 6 illustrates cached data 600, which is a two-dimensional dataset obtained by rearranging sub-data from the input data. Cached data 600 includes two dimensions: a first cache dimension 610 and a second cache dimension 620. For any sub-data in cached data 600, the first cache dimension 610 represents the row in cached data 600, and the first cache dimension 620 represents the column in cached data 600. The value range of the first cache dimension 610 can be 0 to 95, and the value range of the second cache dimension 620 can be 0 to 68215. The range of the first cache dimension 610 represents that the cached data includes 96 rows of data, and the range of the second cache dimension 620 represents that the cached data includes 68216 columns of data.

[0070] S25, based on the second position information, a second rearrangement operation is performed on the sub-data in the cached data according to the second instruction 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.

[0071] In one embodiment of this application, the second instruction is used to determine the second index corresponding to the sub-data in the output data based on the cache index corresponding to the sub-data in the cached data. This index indicates 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 the data dimension of the input data. The output data can be data used to train 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 output data is also different from the dimension of the input data. Specifically, the cache index used to represent the second position information of the sub-data is processed based on the second instruction 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.

[0072] Specifically, the method for performing a second rearrangement operation on the sub-data in the cached data based on the second instruction to obtain the output data is detailed in the corresponding description in Figure 7.

[0073] For example, if the default programming language is Python, the second instruction could include: "for ax0,ax1,ax2 in T.grid(8526,96,8):

[0074] with T.block("cached data"):

[0075] a,b,c= T.axis.remap("SS",[ax0,ax1,ax2]);

[0076] Output data [a,b,c] = cached data [b,a*8+c]".

[0077] The "output data [a,b,c]" is used to represent the second index in the output data, indicating the third position information of the sub-data in the output data. "a" represents the value of the first output dimension in the second index, "b" represents the value of the second output dimension in the second index, and "c" represents the value of the third output dimension in the second index. When a is 8526, b is 96, and c is 8, the cache index can be [96, 68216]. The corresponding second index of the output data can be [8526, 96, 8], representing the sub-data with cache index [96, 68216] in the cache data, located in row 8526, column 96, and channel 8 of the output data.

[0078] In one embodiment of this application, the second index is used to characterize 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 is 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 into the position indicated by the corresponding second index in the output data. The output data satisfies 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.

[0079] In one embodiment of this application, the output data includes one or more of image data, text data, and speech 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 pre-collected image data used to train an object detection model, then the output data includes image data; if the input data is pre-collected text data used to train a natural language model, then the output data includes text data; if the input data is pre-collected speech data used to train a speech recognition model, then the output data includes speech data.

[0080] For example, when the input data consists of multiple batches of image data, the output data can be obtained by rearranging the sub-data from the multiple batches of image data. If a certain sub-data belongs to the 1392nd batch of image data in the input data, and the sub-data is the pixel value of the 3rd channel of the pixel in the 0th row and 8th column of the image data in that batch, then the sub-data is the data in the 96th row and 68216th column of the cached data, and the sub-data is the data in the 8th channel of the 8526th row and 96th column of the output data. For example, in the image data of batch 1392 in the input data, when the pixel value of the 3rd channel of the pixel in row 0, column 8 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 to be [96,68216]. According to the mapping relationship indicated by the second instruction, the second index corresponding to this cache index can be determined to be [8526,96,8]. Therefore, the pixel value 255 can be filled into the position of the 8th channel in row 8526, column 96 in the output data. After filling all the sub-data in the cache data into the positions indicated by the corresponding second index 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.

[0081] For example, Figure 8 illustrates the output data 800. Output data 800 is two-dimensional data obtained by rearranging the sub-data in the cached data, and this output data meets the format requirements of the input data for the artificial intelligence model to be trained. Output data 800 includes two dimensions: a first output dimension 810 and a second output dimension 820. For any sub-data in output data 800, the first output dimension 810 can be used to represent the row where the sub-data is located in output data 800, and the second output dimension 820 can be used to represent the column where the sub-data is located in cached data 800. The value range of the first cache dimension 810 can be from 0 to 95, and the value range of the second cache dimension 820 can be from 0 to 68215. The value range of the first cache dimension 810 represents that the cached data includes 96 rows of data, and the value range of the second cache dimension 820 represents that the cached data includes 68216 columns of data.

[0082] As can be seen from the above technical solutions, the embodiments of this application can split the rearrangement instructions based on preset indivisible rules to obtain the first instruction and the second instruction, thereby simplifying the logic of data rearrangement and improving the efficiency of data rearrangement. The first instruction maps the first position information of the sub-data in the input data to determine the second position information of the sub-data in the cached data, and the second instruction maps the second position information to determine the third position information of the sub-data in the output data. Thus, by performing two mappings on the sub-data of the input data to obtain the output data, the sub-data in the input data can be rearranged at least twice to obtain output data that meets the input requirements of the artificial intelligence model, thereby reducing the computational complexity of a single data rearrangement, reducing the consumption of computing resources, and improving the efficiency of data rearrangement.

[0083] Figure 4 shows a flowchart of a method for determining a first instruction and a second instruction according to an embodiment of this application. The order of the steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements. The method for determining a first instruction and a second instruction provided in this embodiment of the application includes the following steps.

[0084] S30, update the sub-instruction according to the preset rule to obtain the updated instruction.

[0085] In one embodiment of this application, multiple sub-instructions in the rearrangement instruction can be used to determine a corresponding second index based on a first index in the input data, and rearrange the sub-data in the input data according to the second index to obtain output data. The rearrangement instruction can be a program written in a preset programming language, which can be Python, Java, or C; this application does not limit this. For example, when the preset programming language is Python, the content included in the rearrangement instruction could be "for i0,i1,i2 in T.grid(8526,96,8):

[0086] with T.block("input data"):

[0087] a,b,c = T.axis.remap("SSS",[i0,i1,i2]);

[0088] Output data [a,b,c] = Input data [b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]".

[0089] The rearrangement instruction includes multiple sub-instructions, which determine the first position information of a sub-data item in the input data based on multiple dimension values ​​of the sub-data item. For example, the rearrangement instruction "input data [b / / 32,(a*8+c) / / 49,b%32,(a*8+c)%49]" indicates the first index of any sub-data item in the input data. Specifically, the sub-instruction "b / / 32" represents the value of the first original dimension in the first index, "(a*8+c) / / 49" represents the value of the second original dimension in the first index, "b%32" represents the value of the third original dimension in the first index, and "(a*8+c)%49" represents the value of the fourth original dimension in the first index.

[0090] In one embodiment of this application, since the computational complexity of sub-instructions can be large, implementing the mapping relationship between the first and second indices may consume significant computational resources, leading to low efficiency in data rearrangement. Therefore, the form of the sub-instructions can be rewritten based on preset indivisibility rules to obtain the first and second instructions. Specifically, multiple sub-instructions in the rearrangement instructions can be traversed, and sub-instructions that satisfy the indivisibility rules can be replaced with preset variables, thereby updating the sub-instructions according to the preset rules to obtain the updated instructions. For example, the sub-instruction "a*8+c" is a sub-instruction that satisfies the indivisibility rules. This sub-instruction can be replaced with B, and the form of the updated instruction is: "for i0,i1,i2 in T.grid(8526,96,8):

[0091] with T.block("input data"):

[0092] a,b,c = T.axis.remap("SSS",[i0,i1,i2]);

[0093] Output data [a,b,c] = Input data [b / / 32,B / / 49,b%32,B%49]".

[0094] S31, determine the mapping relationship between the first location information and the second location information based on the updated instruction, and obtain the first instruction.

[0095] In one embodiment of this application, a first instruction is used to indicate a mapping relationship between first location information and second location information of sub-data in cached data. Specifically, this mapping relationship is used to characterize the correspondence between a first index and a 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, if the preset programming language is Python, the content included in the first instruction could be: "for ax0,ax1 in T.grid(96,68216):

[0096] with T.block("initial data"):

[0097] a,b,= T.axis.remap("SS",[ax0,ax1]);

[0098] Cache data [b,B] = input data [b / / 32,B / / 49,b%32,B%49]".

[0099] 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.

[0100] S32, based on the updated instruction, determine the mapping relationship between the second location information and the third location information, and obtain the second instruction.

[0101] In one embodiment of this application, the second instruction is used to determine the second index corresponding to the sub-data in the output data based on the cache index corresponding to the sub-data in the cached data. This index indicates 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 the data dimension of the input data. The output data can be data used to train 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 output data is also different from the dimension of the input data. For example, if the preset programming language is Python, the second instruction could include the following: "for ax0,ax1,ax2 in T.grid(8526,96,8):

[0102] with T.block("cached data"):

[0103] a,b,c= T.axis.remap("SS",[ax0,ax1,ax2]);

[0104] Output data [a,b,c] = cached data [b,B]".

[0105] In this context, the value of the preset variable B is equal to the value of the sub-instruction "a*8+c", i.e., B=a*8+c. "Output data [a,b,c]" represents the second index in the output data, indicating the third position of the sub-data within the output data. Specifically, "a" represents the value of the first output dimension in the second index, "b" represents the value of the second output dimension in the second index, and "c" represents the value of the third output dimension in the second index. When a is 8526, b is 96, and c is 8, the cache index can be [96, 68216]. The corresponding second index of the output data can be [8526, 96, 8], representing the sub-data with cache index [96, 68216] in the cache data, located in the 8th channel of the 96th column of the 8th row in the output data.

[0106] Figure 5 shows a flowchart of a method for determining cached data according to an embodiment of this application. The order of steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements. The method for determining cached data provided in this embodiment includes the following steps.

[0107] S40, based on the first instruction, determine the corresponding second position information according to the first position information of each sub-data in the input data.

[0108] In one embodiment of this application, a first instruction is used to indicate a mapping relationship between first location information and second location information of sub-data in cached data. This mapping relationship is used to characterize the correspondence between a first index and a 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 characterize the second location information of sub-data in cached data. For example, if the preset programming language is Python, the content included in the first instruction could be: "for ax0,ax1 in T.grid(96,68216):

[0109] with T.block("initial data"):

[0110] a,b,= T.axis.remap("SS",[ax0,ax1]);

[0111] Cache data [b,B] = input data [b / / 32,B / / 49,b%32,B%49]".

[0112] In this context, the value of the preset variable B is equal to the value of the sub-instruction "a*8+c", i.e., B = a*8+c. "Cache data [b, a*8+c]" represents the value of the cache index, indicating the second position of the sub-data within the cache data. Specifically, "b" represents the value of the first dimension in the cache index, and "a*8+c" represents the value of the second dimension. When a is 8526, b is 96, and 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 with the first index [1392, 3, 0, 8] in the input data, and this sub-data is located in the 96th row and 68216th column of the cache data. In this way, the first position information of the sub-data in the input data can be determined based on the first index in the high-dimensional input data, and the cache index corresponding to the first index can be determined based on the first instruction, thereby determining the second position information of the sub-data in the cache data.

[0113] S41, Arrange all sub-data according to the second position information of each sub-data to obtain the cached data.

[0114] In one embodiment of this 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 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.

[0115] For example, in the image data of the 1392nd batch in the input data, when the pixel value of the 3rd channel of the pixel in row 0, column 8 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 to be [96, 68216]. Therefore, the pixel value 255 can be filled into the position of row 96, column 68216 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.

[0116] Figure 7 shows a flowchart of a method for determining output data according to an embodiment of this application. The order of steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements. The method for determining output data provided in this embodiment includes the following steps.

[0117] S50, based on the second instruction, determine the corresponding third position information according to the second position information of each sub-data in the cached data.

[0118] In one embodiment of this application, the second instruction is used to determine the second index corresponding to the sub-data in the output data based on the cache index corresponding to the sub-data in the cached data. The mapping relationship between the cache index and the second index indicates 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 the data dimension of the input data. The output data can be data used to train 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 output data is also different from the dimension of the input data. For example, if the preset programming language is Python, the second instruction could include: "for ax0,ax1,ax2 in T.grid(8526,96,8):

[0119] with T.block("cached data"):

[0120] a,b,c= T.axis.remap("SS",[ax0,ax1,ax2]);

[0121] Output data [a,b,c] = cached data [b,B]".

[0122] In this context, the value of the preset variable B is equal to the value of the sub-instruction "a*8+c", i.e., B=a*8+c. "Output data [a,b,c]" represents the second index in the output data, indicating the third position of the sub-data within the output data. Specifically, "a" represents the value of the first output dimension in the second index, "b" represents the value of the second output dimension in the second index, and "c" represents the value of the third output dimension in the second index. When a is 8526, b is 96, and c is 8, the cache index can be [96, 68216]. The corresponding second index of the output data can be [8526, 96, 8], representing the sub-data with cache index [96, 68216] in the cache data, located in the 8th channel of the 96th column of the 8th row in the output data.

[0123] S51, Arrange all sub-data according to the third position information of each sub-data to obtain the output data.

[0124] In one embodiment of this application, the second index is used to characterize 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 is 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 into the position indicated by the corresponding second index in the output data. The output data satisfies 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.

[0125] Please refer to Figure 9, which is a functional block diagram of a data rearrangement apparatus provided in an embodiment of this application. A data rearrangement apparatus 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 this application refers to a series of computer-readable instruction segments that can be executed by the processor 13 and perform a fixed function, and which are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0126] The acquisition module 910 is used to acquire input data, which includes sub-data of multiple dimensions.

[0127] The determining module 911 is used to determine sub-instructions that conform to preset rules from pre-stored rearrangement instructions.

[0128] The determining module 911 is further configured to use the sub-instruction to calculate the values ​​of the multiple dimensions corresponding to the sub-data, and obtain the first position information of the sub-data in the input data.

[0129] The splitting module 912 is used to split the rearrangement instruction based on the sub-instruction to obtain a first instruction and a second instruction.

[0130] The first rearrangement module 913 is used to perform a first rearrangement operation on the sub-data based on the first position information and 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.

[0131] The second rearrangement module 914 is used to perform a second rearrangement operation on the sub-data in the cached data based on the second position information and the second instruction 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.

[0132] In some embodiments, the preset rule is an indivisible rule, and the determining module 911 is further configured to: determine any sub-instruction in the rearrangement instruction as a sub-instruction that conforms to the preset rule if any sub-instruction in the rearrangement instruction cannot be decomposed by the preset operation.

[0133] In some embodiments, the determining module 911 is further configured to: simplify the rearrangement instruction based on a preset simplification rule to obtain a simplified rearrangement instruction; and determine that any sub-instruction in the simplified rearrangement instruction is a sub-instruction that conforms to the preset rule if any sub-instruction in the simplified rearrangement instruction cannot be decomposed by the preset operation.

[0134] In some embodiments, the splitting module 912 is further configured to: update the sub-instruction according to the preset rule to obtain an updated instruction; determine the mapping relationship between the first location information and the second location information based on the updated instruction to obtain the first instruction; and determine the mapping relationship between the second location information and the third location information based on the updated instruction to obtain the second instruction.

[0135] In some embodiments, the first rearrangement module 913 is further configured to: determine corresponding second position information based on the first instruction and the first position information of each sub-data in the input data; and arrange all sub-data according to the second position information of each sub-data to obtain the cached data.

[0136] In some embodiments, the second rearrangement module 914 is further configured to: determine the corresponding third position information according to the second position information of each sub-data in the cached data based on the second instruction; and arrange all sub-data according to the third position information of each sub-data to obtain the output data.

[0137] Please refer to Figure 10, which is a schematic diagram of the structure of an electronic device provided in an embodiment of this 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 executes the computer-readable instructions stored in the memory to implement a data rearrangement method as described in any of the above embodiments.

[0138] In one embodiment of this 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.

[0139] Figure 10 only shows an electronic device 100 with a memory 12 and a processor 13. Those skilled in the art will understand that the structure shown in Figure 10 does not constitute a limitation on the electronic device 100, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.

[0140] Referring to Figure 2, the memory 12 in the electronic device 100 stores a plurality of computer-readable instructions to implement a data rearrangement method. The processor 13 can execute the plurality of instructions to achieve: acquiring input data, the input data including sub-data of multiple dimensions; determining sub-instructions conforming to preset rules from pre-stored rearrangement instructions; calculating the values ​​of the sub-data corresponding to the multiple dimensions using the sub-instructions to obtain the 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 position information and 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; performing a second rearrangement operation on the sub-data in the cached data based on the second position information and the second instruction 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.

[0141] Specifically, the specific implementation method of the processor 13 for the above instructions can be referred to the description of the relevant steps in the corresponding embodiment of Figure 2, which will not be repeated here.

[0142] Those skilled in the art will understand that the schematic diagram is merely an example of the electronic device 100 and does not constitute a limitation on the electronic device 100. The electronic device 100 may be a bus-type structure or a star-type structure. The electronic device 100 may also include more or fewer other hardware or software than shown in the diagram, or different component arrangements. For example, the electronic device 100 may also include input / output devices, network access devices, etc.

[0143] It should be noted that electronic device 100 is only an example. Other existing or future electronic products that are suitable for this application should also be included within the scope of protection of this application and are incorporated herein by reference.

[0144] The memory 12 includes at least one type of readable storage medium, which can be non-volatile or volatile. The readable storage medium includes flash memory, portable hard drives, multimedia cards, card-type memory (e.g., SD or DX memory), magnetic storage, magnetic disks, optical disks, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 100, such as the portable hard drive of the electronic device 100. In other embodiments, the memory 12 can also be an external storage device of the electronic device 100, such as a plug-in portable hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electronic device 100. The memory 12 can be used not only to store application software and various types of data installed on the electronic device 100, such as the code of a data rearrangement program, but also to temporarily store data that has been output or will be output.

[0145] In some embodiments, the processor 13 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits packaged with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 13 is the control unit of the electronic device 100, connecting to various components of the electronic device 100 via various interfaces and lines. It executes programs or modules stored in the memory 12 (e.g., executing a data rearrangement program) and calls data stored in the memory 12 to perform various functions of the electronic device 100 and process data.

[0146] 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 data rearrangement method embodiments, such as the steps shown in FIG2.

[0147] For example, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete this application. The one or more modules / units may be a series of computer-readable instruction segments capable of performing a specific function, which 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.

[0148] The integrated unit implemented as a software functional module described above can be stored in a computer-readable storage medium. This software functional module, stored in a storage medium, includes several instructions to cause a computer device (which may be a personal computer, computer equipment, or network device, etc.) or processor to execute portions of the data rearrangement method described in the various embodiments of this application.

[0149] If the modules / units integrated in the electronic device 100 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware devices. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above.

[0150] The computer program includes computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, and other memory.

[0151] Furthermore, the computer-readable storage medium may primarily include a stored program area and a stored data area, wherein the stored program area may store the operator system, the application program required for at least one function, etc.; and the stored data area may store data created based on the use of blockchain nodes, etc.

[0152] The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one arrow is used in Figure 10, but this does not mean that there is only one bus or one type of bus. The bus is configured to implement communication between the memory 12 and at least one processor 13, etc.

[0153] This application also provides a computer-readable storage medium (not shown) storing computer-readable instructions, which are executed by a processor in an electronic device to implement the data rearrangement method described in any of the above embodiments.

[0154] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.

[0155] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

Claims

1. A data rearrangement method, applied to electronic devices, characterized in that, The method includes: Obtain input data, which includes sub-data of multiple dimensions; From the pre-stored rearrangement instructions, determine the sub-instructions that conform to the preset rules; The sub-instruction is used to calculate the values ​​of the sub-data corresponding to the multiple dimensions, thereby obtaining the first position information of the sub-data in the input data; Based on the sub-instruction, the rearranged instruction is split to obtain the first instruction and the second instruction; Based on the first position information, a first rearrangement operation is performed 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. Based on the second position information, a second rearrangement operation is performed on the sub-data in the cached data according to the second instruction 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.

2. The data rearrangement method as described in claim 1, characterized in that, The preset rule is an indivisible rule, and the step of determining sub-instructions that conform to the preset rule from the pre-stored rearrangement instructions includes: If any sub-instruction in the rearrangement instruction cannot be decomposed by a preset operation, then that sub-instruction is determined to be a sub-instruction that conforms to a preset rule.

3. The data rearrangement method as described in claim 1, characterized in that, The step of determining sub-instructions that conform to preset rules from pre-stored rearrangement instructions includes: The rearrangement instruction is simplified based on the preset simplification rules to obtain the simplified rearrangement instruction. If any sub-instruction in the simplified rearrangement instructions cannot be decomposed by the preset operation, then the specified sub-instruction is determined to be a sub-instruction that conforms to the preset rules.

4. The data rearrangement method as described in claim 2 or 3, characterized in that, The preset operations include integer division operations and / or modulo operations.

5. The data rearrangement method as described in claim 1, characterized in that, The step of splitting the rearranged instructions based on the sub-instructions to obtain the first instruction and the second instruction includes: The sub-instruction is updated according to the preset rules to obtain the updated instruction; Based on the updated instruction, the mapping relationship between the first location information and the second location information is determined, and the first instruction is obtained; Based on the updated instruction, the mapping relationship between the second location information and the third location information is determined, and the second instruction is obtained.

6. The data rearrangement method as described in claim 1, characterized in that, The step of performing a first rearrangement operation on the sub-data based on the first position information and the first instruction to obtain cached data includes: Based on the first instruction, the corresponding second position information is determined according to the first position information of each sub-data in the input data; Based on the second position information of each sub-data, all sub-data are arranged to obtain the cached data.

7. The data rearrangement method as described in claim 1, characterized in that, The step of performing a second rearrangement operation on the sub-data in the cached data based on the second position information and the second instruction to obtain the output data includes: Based on the second instruction, the corresponding third position information is determined according to the second position information of each sub-data in the cached data; Based on the third position information of each sub-data, all sub-data are arranged to obtain the output data.

8. A data rearrangement device, characterized in that, The device includes: The acquisition module is used to acquire input data, which includes sub-data of multiple dimensions; The determination module is used to determine sub-instructions that conform to preset rules from the pre-stored rearrangement instructions; The determining module is further configured to use the sub-instruction to calculate the values ​​of the multiple dimensions corresponding to the sub-data, and obtain the first position information of the sub-data in the input data; A splitting module is used to split the rearranged instruction based on the sub-instruction to obtain a first instruction and a second instruction; The first rearrangement module is used to perform a first rearrangement operation on the sub-data based on the first position information and 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. The second rearrangement module is used to perform a second rearrangement operation on the sub-data in the cached data based on the second position information and the second instruction 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.

9. An electronic device, characterized in that, The electronic device includes a processor and a memory, the processor being configured to implement the data rearrangement method as described in any one of claims 1 to 7 when executing a computer program stored in the memory.

10. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by a processor, it implements the data rearrangement method as described in any one of claims 1 to 7.