Arrangement method and device of vector elements, electronic equipment and storage medium
By generating a butterfly network and determining the hierarchy and input-output mapping of the switching node SN unit, the vector elements are rearranged, solving the efficiency and energy efficiency problems of the traditional scalar processor architecture and improving the efficiency and performance of data processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING VCORE TECH CO LTD
- Filing Date
- 2026-04-21
- Publication Date
- 2026-07-10
AI Technical Summary
Traditional general-purpose scalar processor architectures suffer from huge overheads in instruction fetching and decoding, as well as wasted control logic, when processing large-scale data, making it difficult to meet the requirements of high performance.
By extending vectors, a method for arranging vector elements is proposed to generate a butterfly network. The hierarchy and input-output mapping relationship of the switching node SN unit are determined, and the vector elements are rearranged to enable non-blocking transmission in the butterfly network and mapped to vector hardware for data processing.
It improves data processing efficiency and memory access efficiency, reduces access latency, and enables large models to run close to theoretical peak performance on vector hardware.
Smart Images

Figure CN122086892B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vector processing technology, and in particular to a method, apparatus, electronic device and storage medium for arranging vector elements. Background Technology
[0002] With the explosive growth in computing power demands from artificial intelligence, scientific computing, and high-end embedded applications, traditional general-purpose scalar processor architectures are increasingly unable to meet the extreme requirements of efficiency and energy efficiency. The core bottleneck lies in the fact that processing large-scale data requires the continuous execution of a large number of repetitive scalar instructions, leading to huge overhead in instruction fetching and decoding, as well as significant waste of control logic.
[0003] Vector extensions, especially the introduction of permutation instructions, are precisely designed to resolve this fundamental contradiction. They represent an architectural enhancement of the basic instruction set, achieving a paradigm shift from "scalar" to "vector." A single vector instruction can complete the operation of an entire data set, significantly reducing the pressure on the instruction cache and fetch unit. This results in fewer instructions and higher execution efficiency when performing the same computational task. Summary of the Invention
[0004] The purpose of this application is to at least partially solve one of the technical problems in the related art.
[0005] Therefore, the first objective of this application is to propose a method for arranging vector elements to achieve the rearrangement of vector elements and enable the rearranged vector elements to be transmitted in a butterfly network without blocking, thereby enabling the mapping of complex and variable large model workloads onto vector hardware to achieve efficient execution of data processing.
[0006] The second objective of this application is to propose a device for arranging vector elements.
[0007] The third objective of this application is to propose an electronic device.
[0008] The fourth objective of this application is to provide a computer-readable storage medium.
[0009] The fifth objective of this application is to provide a computer program product.
[0010] To achieve the above objectives, a first aspect of this application proposes a method for arranging vector elements, comprising: acquiring vector elements to be processed, and determining the level of each switching node (SN) unit in a butterfly network based on the number of vector elements to generate the butterfly network; wherein the butterfly network is used to arrange the vector elements; determining the input-output mapping relationship between the levels of each switching node (SN) unit in the butterfly network; determining the target state of the SN unit in each level based on the input-output mapping relationship; and arranging the vector elements based on the target state to perform data processing based on the arranged vector elements.
[0011] To achieve the above objectives, a second aspect of this application provides a vector element arrangement apparatus, comprising: a generation module, configured to acquire vector elements to be processed and, based on the number of vector elements, determine the level of each switching node (SN) unit in a butterfly network to generate the butterfly network; wherein the butterfly network is used to arrange the vector elements; a first determining module, configured to determine the input-output mapping relationship between the levels of each switching node (SN) unit in the butterfly network; a second determining module, configured to determine the target state of the SN unit in each level based on the input-output mapping relationship; and an arrangement module, configured to arrange the vector elements based on the target state for data processing based on the arranged vector elements.
[0012] To achieve the above objectives, a third aspect of this application provides an electronic device, comprising: a processor; and a memory communicatively connected to the processor; the memory storing computer execution instructions; and the processor executing the computer execution instructions stored in the memory to enable the processor to execute the vector element arrangement method described in the first aspect of the application.
[0013] To achieve the above objectives, a fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, the computer instructions being used to cause the computer to execute the vector element arrangement method described in the above aspect of the embodiment.
[0014] To achieve the above objectives, a fifth aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the vector element arrangement method described in the above aspect of the embodiment.
[0015] The vector element arrangement method, apparatus, electronic device, and storage medium provided in this application determine the level of each SN unit in the butterfly network based on the number of vector elements to generate the butterfly network, and determine the input-output mapping relationship between SN units at each level. Based on the input-output mapping relationship, the target state of the SN units in each level is determined, and the vector elements are arranged based on the target state. Therefore, this scheme can rearrange vector elements, allowing them to be transmitted non-blockingly in the butterfly network. This enables the mapping of complex and variable large model workloads onto vector hardware, achieving efficient data processing execution, reducing access latency, improving memory access efficiency and overall performance, and enabling large models to run on vector hardware at near-theoretical peak performance.
[0016] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0017] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0018] Figure 1 A flowchart illustrating a method for arranging vector elements provided in an embodiment of this application;
[0019] Figure 2 This is a schematic diagram of the butterfly network provided in an embodiment of this application;
[0020] Figure 3 A schematic diagram of the SN unit provided in an embodiment of this application;
[0021] Figure 4 A flowchart illustrating another method for arranging vector elements provided in an embodiment of this application;
[0022] Figure 5 A flowchart illustrating another method for arranging vector elements provided in an embodiment of this application;
[0023] Figure 6 This is a flowchart illustrating the process of determining the target state of an SN unit according to an embodiment of this application.
[0024] Figure 7 A flowchart illustrating another method for arranging vector elements provided in an embodiment of this application;
[0025] Figure 8 A schematic diagram of the arrangement instructions provided in the embodiments of this application;
[0026] Figure 9This is a schematic diagram of a vector element arrangement device provided in an embodiment of this application. Detailed Implementation
[0027] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0028] The method and apparatus for arranging vector elements according to embodiments of this application are described below with reference to the accompanying drawings.
[0029] Figure 1 This is a flowchart illustrating a method for arranging vector elements according to an embodiment of this application, as shown below. Figure 1 As shown, the method for arranging vector elements in this application includes, but is not limited to, the following steps:
[0030] S101: Obtain the vector elements to be processed, and determine the level of each switching node SN unit contained in the butterfly network based on the number of vector elements, so as to generate the butterfly network.
[0031] It should be noted that the execution subject of the vector element arrangement method provided in this application embodiment is an electronic device, which can be a terminal device. Optionally, the terminal device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be personal computers (PCs), televisions, etc. This application embodiment does not impose specific limitations.
[0032] In some embodiments, a butterfly network is a multi-level switching network structure composed of multi-level switch node (SN) units. In this application, the butterfly network is used to arrange vector elements.
[0033] In some embodiments, elements input to the vector processing module can be used as vector elements to be processed. For example, for an image processing task, if the elements input to the vector processing module are image data, then the image data can be used as vector elements to be processed.
[0034] Optionally, the length of the vector elements determines the size of the butterfly network. In other words, the level of the SN unit can be determined based on the number of vector elements, and the butterfly network can be generated according to the level of the SN unit.
[0035] In some embodiments, if the number of vector elements is N, then the SN unit has There are 7 levels. Taking N=16 as an example, the butterfly network contains 7 levels of SN units. Each SN unit has 2 inputs and 2 outputs.
[0036] In some embodiments, the number of SN units can be determined based on the number of vector elements, and the SN units can be divided into [number] based on the number of SN units and the number of levels. There are several levels. Optionally, the number of SN units is... Taking N=16 as an example, the butterfly network contains 7 levels of SN units, and the total number of SN units is 56, so each level has 8 SN units.
[0037] Figure 2 This is a schematic diagram of the butterfly network provided in an embodiment of this application.
[0038] Figure 2 The butterfly network in the model consists of seven levels: level-1, level-2, level-3, level-4, level-5, level-6, and level-7. Each level includes SN0, SN1, SN2, SN3, SN4, SN5, SN6, and SN7.
[0039] In some embodiments, the SN units in the butterfly network are arranged in rows, with each row containing the same SN units; that is, each level has different SN units. Figure 2 For example, the SN units in the first row are all SN0, and each level contains SN units from SN0 to SN7.
[0040] Figure 3 This is a schematic diagram of the SN unit provided in an embodiment of this application. The SN unit has two inputs (input_0 and input_1) and two outputs (output_0 and output_1). input_0 reg represents register 1, and input_1 reg represents register 2. The SN unit also includes two cross units.
[0041] If the cross unit status is 0, it indicates a pass-through. Then, input _0 in register 1 and input _1 in register 2 are not cross-connected and pass directly through cross unit 1 and cross unit 2. At this time, output _0 = input _0 and output _1 = input _1.
[0042] If the cross unit state is 1, indicating crossover, then input _0 in register 1 and input _1 in register 2 need to be crossovered. Input _0 is crossovered through cross unit 2, at which point output _1 = input _0. Input _1 is crossovered through cross unit 1, at which point output _0 = input _1.
[0043] In other words, the SN unit can perform different operations for the pass-through state and the cross-connect state, so that data can pass through the SN unit directly or after a cross-connect.
[0044] S102, determine the input-output mapping relationship between the levels of each switching node SN unit contained in the butterfly network.
[0045] In some embodiments, because the butterfly network is butterfly-shaped and symmetrical, each level has its corresponding symmetrical level. The input-output mapping relationship between any level and its corresponding level can be determined.
[0046] In other words, the input-output mapping relationship is a pairwise input-output mapping relationship between levels.
[0047] In some embodiments, since the butterfly network is butterfly-shaped symmetrical, that is, symmetrical about the axis of symmetry, which is a level of SN unit, the SN unit at that level does not have a symmetry level.
[0048] Continue with Figure 2 For example, Figure 2 The levels with input-output mapping relationships include: level-1 and level-7, level-2 and level-6, level-3 and level-5, and... Figure 2 The axis of symmetry in it is level-4.
[0049] In some embodiments, the input-output mapping relationship between pairs of levels can be determined based on the contents of the vector registers of the SN units in the level. Optionally, the vector registers store data elements and index values. For any SN unit in each level, the data elements and index values in that SN unit can be compared to determine whether they are the same, thereby determining the input-output mapping relationship between pairs of levels.
[0050] For example, for SN0 in level-1 and level-7, we iterate through and compare the data elements and index values of SN0 in level-1 to see if they are the same. If they are the same, we can assign a value of 1 to the comparison result; if they are different, we can assign a value of 0 to the comparison result.
[0051] Furthermore, the location information of the data element and index value corresponding to the comparison result of 1 can be determined, and the output port of SN0 in level-1 in level-7 can be determined based on the location information.
[0052] Since the SN unit has two inputs and two outputs, the output corresponding to each input can be determined separately. That is, the output port of the input port of SN0 in level-1 can be determined separately in level-7 as the input-output mapping relationship.
[0053] In some embodiments, the input-output mapping relationships between level-1 and level-7, level-2 and level-6, and level-3 and level-5 can be determined. After determining the input-output mapping relationship, the input and output ports of level-4 can be determined based on the input and output ports of each level.
[0054] S103 determines the target state of the SN unit in each level based on the input-output mapping relationship.
[0055] In some embodiments, the target state of the SN unit in each level can be determined based on the coordinate matrix corresponding to the SN unit. The coordinate matrix is related to the input-output mapping relationship of the SN unit; the coordinate matrix is a two-row, two-column matrix.
[0056] In some embodiments, a mapping table can be determined based on the input-output mapping relationship. The mapping table can intuitively display the output ports of the SN units in each level, thereby enabling the location of the output ports. That is, the output ports corresponding to the SN units can be determined according to the input-output mapping relationship, and the coordinate matrix corresponding to the SN units can be determined according to the coordinate values of the output ports. Then, the target state of the SN units in each level can be determined according to the coordinate matrix.
[0057] In some embodiments, the coordinate values of the output port can indicate which output port of the input port in the SN unit of any level outputs its data.
[0058] Continuing with level-1 and level-7 as examples, taking SN0 in level-1 as an example, SN0 includes two input ports, SN0_0 and SN0_1. If SN0_0 is output by SN2 in level-7, and the output port is SN2_1, which is the 5th output port in level-7, then the coordinates of the output port are (0,5).
[0059] In some embodiments, for the coordinate matrix of an SN unit, the coordinate values of the output ports corresponding to each input port are determined as elements in the first row of the coordinate matrix, and the elements in the second row are calculated based on the elements in the first row.
[0060] In some embodiments, the coordinate matrix may include the coordinate values of the output port as elements of the coordinate matrix, and may also include marker elements, that is, the coordinate values and marker elements can form the elements of the coordinate matrix.
[0061] In some embodiments, the column index can be determined by the elements in the first row, and the mapping table can be queried based on the column index. The queried coordinate values are then used as elements in the second row, thereby enabling the calculation of elements in the second row based on the elements in the first row.
[0062] In some embodiments, the target states of the SN unit include a pass-through state and a cross-connect state. The pass-through state indicates that the input ports of the SN unit are directly connected to the corresponding output ports, and no data exchange occurs. The cross-connect state indicates that the input ports of the SN unit are cross-connected to the output ports, and data exchange occurs.
[0063] For example, in the through state, the SN unit inputs from input port 0 and outputs from output port 0; in the cross state, the SN unit inputs from input port 0 and outputs from output port 1.
[0064] In some embodiments, after determining the coordinate matrix of the SN element, the state of the SN element can be determined in different ways depending on whether the SN element is an SN element in the axis of symmetry.
[0065] In some embodiments, if the SN unit is an SN unit in the axis of symmetry, it can be determined whether the input index of the SN unit is the same as the input index of its adjacent SN unit. If they are the same, it means that the target state of the SN unit is a pass-through state; otherwise, it is a cross-connect state.
[0066] In some embodiments, if the SN unit is not an SN unit within the axis of symmetry, the target state of the SN unit can be determined by querying the values of elements in the coordinate matrix. Optionally, if the value of the queried element is 0, the target state of the SN unit is a pass-through state; if the value of the queried element is 1, the target state of the SN unit is a cross-connected state. The element value can be queried based on the index of the coordinate matrix.
[0067] S104, Arrange the vector elements based on the target state, and perform data processing based on the arranged vector elements.
[0068] In some embodiments, the target state of the SN unit in each level can indicate the transmission path of the vector element in the butterfly network, thereby determining from which port the vector element enters and from which port it exits in the butterfly network, i.e., the input position and output position of each SN unit, so that the vector elements can be rearranged based on the input position and output position.
[0069] In some embodiments, the transmission path of vector elements in the butterfly network can be determined based on the target state, and the input and output positions of vector elements in each SN unit can be determined based on the transmission path. Thus, the vector elements can be arranged based on the input and output positions. By arranging the vector elements, efficient data transformation and routing can be achieved.
[0070] Alternatively, the original vector elements can be sorted by determining the final output position of any vector element to obtain rearranged vector elements.
[0071] In some embodiments, after arranging the vector elements, the data structure of the vector elements can be optimized, and data processing can be performed based on the arranged vector elements so that the data processing can make more efficient and accurate use of data characteristics.
[0072] For example, data processing based on the arranged vector elements can improve computational efficiency, optimize algorithm performance, and meet the computational requirements of large models.
[0073] It should be noted that the vector element arrangement method provided in this application embodiment can be applied to technical fields such as image processing, speech recognition, and natural language processing.
[0074] The vector elements can be elements obtained by extracting features from image data. For example, the arranged vector elements can be used for image processing such as image classification and object detection.
[0075] Alternatively, vector elements can be elements obtained by detecting speech data. For example, the arranged vector elements can be used for speech recognition, wake word detection, and other speech processing.
[0076] The vector element arrangement method provided in this application determines the level of each SN unit in the butterfly network based on the number of vector elements to generate the butterfly network, and determines the input-output mapping relationship between SN units at each level. Based on this input-output mapping relationship, the target state of the SN units in each level is determined, and the vector elements are arranged based on the target state. Therefore, this solution can rearrange vector elements, allowing them to be transmitted non-blockingly in the butterfly network. This enables the mapping of complex and variable large model workloads onto vector hardware, achieving efficient data processing, reducing access latency, improving memory access efficiency and overall performance, and enabling large models to run on vector hardware at near-theoretical peak performance.
[0077] Figure 4 This is a flowchart illustrating another method for arranging vector elements provided in an embodiment of this application, as shown below. Figure 4 As shown, the method for arranging vector elements in this application includes, but is not limited to, the following steps:
[0078] S401: Obtain the vector elements to be processed, and determine the level of each switching node SN unit contained in the butterfly network based on the number of vector elements, so as to generate the butterfly network.
[0079] S402, determine the input-output mapping relationship between the levels of each switching node SN unit contained in the butterfly network.
[0080] In the embodiments of this application, steps S401-S402 can be implemented in any of the embodiments of this application, and no limitation is made here, nor will it be described in detail.
[0081] S403, determine the mapping table corresponding to the input-output mapping relationship.
[0082] In some embodiments, after determining the input-output mapping relationship, the output port corresponding to any SN unit can be determined, thereby generating a mapping table based on the output port. The mapping table may contain the input and output ports of each SN unit between pairs of levels that have a symmetrical relationship.
[0083] In some embodiments, an index value can be set for each port to quickly locate the output port. The index value is related to the number of vector elements. For example, if the vector has 16 elements, the index value is [0, 15], meaning there are 16 index values.
[0084] In some embodiments, if an input port of any SN unit outputs at the output port of the SN unit in its corresponding level, the output port can be located according to the index value.
[0085] For example, if the index value of the input port of any SN unit is 5 and the index value of the output port of the corresponding SN unit in the same level is 2, then this position can be represented as (5,2), which means that the input is taken at the 6th input port in the entire level and the output is taken at the 3rd output port in the corresponding entire level.
[0086] In some embodiments, when generating the mapping table, the output port of a vector element can be indicated by assignment. For example, assigning values from 0 to 1 to the output port with index 5 in the first row means that the first input port in that level needs to output from the 6th output port in the corresponding level.
[0087] S404, based on the mapping table, determine the coordinate matrix corresponding to the SN unit, and determine the target state of the SN unit based on the coordinate matrix.
[0088] In some embodiments, the coordinate matrix is formatted as follows:
[0089]
[0090] in, Indicates a row element. This represents column elements, where rows and columns are the rows and columns in the mapping table. This represents a marker element, which is its initialized value.
[0091] In other words, the coordinate matrix can be determined first based on the mapping table. and The value of is then used to update the initialized marker elements, thereby obtaining the coordinate matrix corresponding to the SN unit.
[0092] In some embodiments, the value corresponding to each element in the coordinate matrix can be determined sequentially; for example, first determine... and In and The value, and then according to and In and The value is determined. and In and The value is then determined. , , and The value of the marker element.
[0093] In some embodiments, by obtaining the row index of the mapping table and determining the target row where the SN unit corresponding to the row index is located, the first coordinate value with a first set value in the target row is determined from the mapping table, and the target element in the coordinate matrix is updated based on the first coordinate value.
[0094] Here, the target element refers to and In and The first set value can be 1. That is, by querying the first coordinate value (1) in the target row corresponding to the row index, and then using the first coordinate value... and In and Update. The first coordinate value can be represented as... .
[0095] It should be noted that the row index represents the row of the SN unit, but the SN unit has two input ports. Therefore, one row index can correspond to the input ports of two SN units, and the first coordinate value of 1 corresponding to each input port in the target row can be determined separately.
[0096] For example, let the row index be row, and there are 8 rows of SN units. Then row∈[0,7], and the ports of the SN units in each row are SN[row]_0 and SN[row]_1, respectively.
[0097] In other words, by determining the first coordinate value of 1 in row SN[row]_0, update of and And by determining the coordinates of the values of 1 in row SN[row]_1, update of and .
[0098] Furthermore, it can be based on and In and Calculate the value. and In and The value. Optionally, it can be based on and In and The value determines the column index of the mapping table, allowing the table to be queried based on the column index, thus achieving the desired result. and In and The value of . Optionally, the column index of the mapping table can be determined based on the result of the division operation between the target element and the second set value.
[0099] In some embodiments, the result of the division operation between the target element and the second set value can be the quotient and remainder of a portion of the target element and the second set value, which are used as the result of the division operation.
[0100] With the target element as of and For example, some elements can be of The result of the division operation can be of The quotient and remainder of the second set value, where the second set value can be 2.
[0101] In some embodiments, after determining the result of the division operation, it can be determined whether the remainder in the result of the division operation is a first set value. If it is the first set value, the column index is the quotient - 1; otherwise, the column index is the quotient + 1.
[0102] For example, let C.quo be... of Let the quotient obtained by dividing by 2 be C.mod. of The remainder when divided by 2. If C.mod is 1, then column index col = C.quo - 1; otherwise, column index col = C.quo + 1.
[0103] Similarly, taking the target element as of and For example, some elements can be of The result of the division operation can be of The quotient and remainder of the second set value, where the second set value can be 2.
[0104] In some embodiments, after determining the result of the division operation, it can be determined whether the remainder in the result of the division operation is a first set value. If it is the first set value, the column index is the quotient - 1; otherwise, the column index is the quotient + 1.
[0105] For example, let D.quo be... of Let the quotient obtained by dividing by 2 be D.mod. of The remainder when divided by 2. If D.mod is 1, then column index col = D.quo - 1; otherwise, column index col = D.quo + 1.
[0106] Furthermore, by determining the target column where the column index corresponds to the SN cell, and determining the second coordinate value of the target column with the value of the first set value from the mapping table, the remaining elements in the coordinate matrix are updated based on the second coordinate value.
[0107] The remaining elements are and In and In other words, you can query the second coordinate value of the target row corresponding to the column index, where the value is 1, and then perform operations based on that second coordinate value. and In and Update.
[0108] Optionally, the specific implementation of querying the target row with a value of 1 based on the column index is the same as the implementation of querying the target row with a value of 1 based on the row index, and will not be elaborated further.
[0109] In some embodiments, the elements in the coordinate matrix other than the marker elements are updated in the manner described above. Furthermore, the initialized marker elements can be updated to obtain the final updated coordinate matrix, which serves as the coordinate matrix of the SN unit.
[0110] It should be noted that during the process of determining the coordinate matrix of the SN unit based on the mapping relationship table, a coordinate matrix table corresponding to the coordinate matrix can also be generated, and its order can be arranged according to the order of the SN units in each level.
[0111] In some embodiments, the coordinate matrix other than the marker elements can be updated by querying, and the coordinate matrix can be updated according to the query results. In other words, the marker elements can be updated according to the query results.
[0112] In some embodiments, a first index and a second index can be obtained, wherein the first index is a top-down query index and the second index is a bottom-up query index, so that the first marker element in the updated coordinate matrix can be queried based on the first index and the second index to obtain the first query result and the second query result.
[0113] In some embodiments, top-down and bottom-up execution are performed based on the order of the SN units. For example, top-down execution is SN0-SN7, and bottom-up execution is SN7-SN0.
[0114] The first marker element can be The query retrieves the first marked element in the updated coordinate matrix based on the first and second indices. In other words, it allows a top-down query of the coordinate matrix based on the first index. The first query result M(A) is obtained; based on the second index, a bottom-up query can be performed in the coordinate matrix. The second query result M(B) is obtained.
[0115] In other words, M(A) is the coordinate matrix... middle The value of M(B) is the coordinate matrix. middle The value of .
[0116] In some embodiments, the coordinate matrix can be updated based on the first query result and the second query result. Optionally, the marker elements in the coordinate matrix can be updated. That is, the marker elements that should be included in the coordinate matrix are determined, and the marker elements are updated based on the first query result and the second query result. The marker elements that should be included in the coordinate matrix may include the first marker element and the second marker element.
[0117] For example, the first marker element is The second marker element is .
[0118] In some embodiments, updating the marker element can be done according to a set update rule.
[0119] In some embodiments, the flag elements can be assigned based on the values of the first query result and the second query result, respectively. Update.
[0120] In some embodiments, if the first query result M(A) is 0 and the second query result M(B) is 1, the marked element can be updated according to the set update rules. Update.
[0121] For example, the update rules are as follows:
[0122] If A.markState == 1, then
[0123] B.markState=1, B.markData=!A.markData;
[0124] C.markState=1, C.markData=!A.markData;
[0125] D.markState=1, D.markData=A.markData;
[0126] Otherwise, if B.markState == 1, then
[0127] A.markState = 1, A.markData =!B.markData;
[0128] C.markState = 1, C.markData = B.markData;
[0129] D.markState = 1, D.markData =!B.markData;
[0130] Otherwise, if C.markState == 1, then
[0131] A.markState = 1, A.markData =!C.markData;
[0132] B.markState = 1, B.markData = C.markData;
[0133] D.markState = 1, D.markData =!C.markData;
[0134] Otherwise, if D.markState == 1, then
[0135] A.markState = 1, A.markData = D.markData;
[0136] B.markState = 1, B.markData =!D.markData;
[0137] C.markState = 1, C.markData =!D.markData;
[0138] Otherwise,
[0139] A.markState = 1, A.markData = 0;
[0140] B.markState = 1, B.markData = 1;
[0141] C.markState = 1, C.markData = 1;
[0142] D.markState = 1, D.markData = 0.
[0143] Where, A.markState represents in The value, A.markData, represents middle The value of B.markState represents middle The value, B.markData, represents middle The value of C.markState represents middle The value, C.markData, represents middle The value of D.markState represents middle The value, D.markData, represents middle The value of .
[0144] In some embodiments, after determining the coordinate matrix of the SN unit, the target state of the SN unit can be determined based on the coordinate matrix, wherein the target state of the SN unit includes a through state and an intersection state.
[0145] In some embodiments, 0 and 1 can be set to represent the through state and the cross state, respectively. When the value is determined to be 0 according to the coordinate matrix, it means that the target state of the SN unit is the through state. When the value is determined to be 1 according to the coordinate matrix, it means that the target state of the SN unit is the cross state.
[0146] In some embodiments, since the SN unit is in a butterfly network and the SN unit is in its corresponding level, and each level has its symmetrical level except for the axis of symmetry, the same determination method can be used for the pairs of symmetrical levels to determine the target state of the SN unit in that level, and a different method can be used for the level of the axis of symmetry to determine the target state of the SN unit in that level.
[0147] Continue with Figure 2 For example, Figure 2 The levels with input-output mapping relationships include: level-1 and level-7, level-2 and level-3, level-3 and level-5, and... Figure 2 The axis of symmetry in it is level-4.
[0148] In other words, level-1 and level-7, level-2 and level-3, and level-3 and level-5 use the same method to determine the target state of the SN unit, while level-4 uses a different method to determine the target state of the SN unit.
[0149] For example, the target state of the SN unit in level-4 can be determined by the input index of the SN unit. The target states of the SN units in level-1 and level-7, level-2 and level-3, and level-3 and level-5 can be determined by querying the value of the index set in the SN unit.
[0150] S405, arrange the vector elements based on the target state, and perform data processing based on the arranged vector elements.
[0151] In the embodiments of this application, step S405 can be implemented in any of the ways described in the various embodiments of this application. This is not limited here and will not be elaborated further.
[0152] In the vector element arrangement method provided in this application embodiment, by determining the mapping relationship table corresponding to the input-output mapping relationship, the coordinate matrix corresponding to the SN unit is determined based on the mapping relationship table, and the target state of the SN unit is determined based on the coordinate matrix. Thus, the vector elements can be arranged based on the target state, which can realize the rearrangement of vector elements and map the complex and ever-changing large model workload onto the vector hardware to achieve efficient task execution.
[0153] Figure 5 This is a flowchart illustrating another method for arranging vector elements provided in an embodiment of this application, as shown below. Figure 5 As shown, the method for arranging vector elements in this application includes, but is not limited to, the following steps:
[0154] S501: Obtain the vector elements to be processed, and determine the level of each switching node SN unit contained in the butterfly network based on the number of vector elements, so as to generate the butterfly network.
[0155] S502, determine the input-output mapping relationship between the levels of each switching node SN unit contained in the butterfly network.
[0156] S503, determine the mapping table corresponding to the input-output mapping relationship.
[0157] S504, based on the mapping table, determine the coordinate matrix corresponding to the SN unit.
[0158] In the embodiments of this application, steps S501-S504 can be implemented in any of the embodiments of this application, and no limitation is made here, nor will it be described in detail.
[0159] S505 determines the level of the SN unit and its position in the butterfly network.
[0160] In some embodiments, different levels of SN units can use different methods to determine the target state of the SN unit, thereby improving the flexibility of target state determination, optimizing the allocation of computing resources, and thus improving overall operating efficiency.
[0161] In some embodiments, the SN unit is located in a butterfly network, and the butterfly network has a symmetrical structure. This allows the level of the SN unit to be determined, thereby determining the position of that level in the butterfly network and using different methods to determine the target state of SN units at different positions.
[0162] In some embodiments, since the butterfly network exhibits a symmetrical structure, the hierarchy can be divided into symmetrical axis and asymmetrical axis.
[0163] S506, in response to the position indicating that the level of the SN unit is the axis of symmetry of the butterfly network, the target state of the SN unit is determined based on the first input index of the SN unit.
[0164] In some embodiments, when the level of the SN unit is determined to be the axis of symmetry of the butterfly network, the target state of the SN unit can be determined based on the first input index of the SN unit. Optionally, the first input index can be compared with the input indices of other SN units, thereby determining the target state of the SN unit based on the comparison result.
[0165] In some embodiments, the first level is determined by identifying the level adjacent to the level corresponding to the symmetry axis of the butterfly network, wherein the first level is higher than the level corresponding to the symmetry axis of the butterfly network. For example, if the level corresponding to the symmetry axis of the butterfly network is level-4, then the first level is level-5.
[0166] Furthermore, by determining the second input index of the SN unit corresponding to the first level, comparing whether the first input index and the second input index are the same, in response to the first input index being equal to the second input index, the target state of the SN unit is determined to be the pass-through state; otherwise, the target state of the SN unit is the cross-connect state.
[0167] Figure 6 This is a flowchart illustrating the process of determining the target state of an SN unit according to an embodiment of this application. Figure 6 The symmetry axis of the butterfly network corresponds to level-4, and the first level is level-5. Level-4 has 8 SN units, namely SN0, SN1, SN2, SN3, SN4, SN5, SN6, and SN7.
[0168] For the i-th SN unit, obtain SN[i 2]_0's first input index (level-4.input.index), and SN[i 2] _0's second input index (level-5.input.index), and determine whether the first input index is the same as the second input index. If they are the same, it can be determined that the target state of the i-th SN unit in level-4, i.e., SN[i], is the pass-through state; otherwise, the target state of SN[i] is the cross-connect state.
[0169] Continue determining the target state of the (i+1)th SN unit until i+1 equals 8, at which point the process ends. Here, i is a natural number from 0 to 7.
[0170] S507, in response to the symmetry axis of the hierarchical non-butterfly network of the position indicator SN unit, determines the target state of the SN unit based on the matrix column index and coordinate matrix of the coordinate matrix.
[0171] In some embodiments, once the axis of symmetry of the hierarchical non-butterfly network of the SN unit is determined, the target state of the SN unit can be determined based on the value of the queried element by querying the coordinate matrix.
[0172] In some embodiments, since the level of the SN unit is not the axis of symmetry of the butterfly network, the level of the SN unit has its symmetrical level. That is, the level of the non-butterfly network axis of symmetry exhibits low-level and high-level symmetry, and the way the target state of the SN unit is determined in the low-level and high-level is also different.
[0173] Optionally, setting method 1 is to determine the target state of SN units in the lower level, and setting method 2 is to determine the target state of SN units in the higher level.
[0174] In some embodiments, Method 1 involves setting a matrix column index to query the coordinate matrix of the SN unit based on the matrix column index, thereby determining the value of the element corresponding to the matrix column index, and determining the target state of the SN unit based on the value of that element.
[0175] For example, set the matrix column index to col_index, where col_index is a natural number from 0 to 7.
[0176] In some embodiments, the target state of the SN unit is determined based on the value of the second marker element corresponding to the column index in the coordinate matrix. For example, the coordinate matrix can be queried. middle The value is used as the value of the second marker element corresponding to the column index of the matrix.
[0177] In some embodiments, in response to the value of the second marker element corresponding to the matrix column index being a third preset value, the target state of the SN unit is determined to be a through state; in response to the value of the second marker element corresponding to the matrix column index being a first preset value, the target state of the SN unit is determined to be a cross state.
[0178] For example, taking the lowest level as level-1, let the matrix column index be col_index, where col_index is a natural number from 0 to 7.
[0179] The target state of the SN cell in level-1 is determined as follows:
[0180] The coordinate matrix is retrieved using the matrix column index to obtain SN[col_index].A.markData.
[0181] If SN[col_index].A.markData==0, then the target state of the SN cell is the pass-through state;
[0182] If SN[col_index].A.markData==1, then the target state of the SN cell is the cross state.
[0183] In some embodiments, Method 2 involves querying a coordinate matrix in which the column elements of the coordinate matrix are multiples of the matrix column indices as the target coordinate matrix, and determining the value of the second marker element of the target matrix to determine the target state of the SN unit based on the value.
[0184] In some embodiments, the target coordinate matrix is determined by identifying coordinate matrices in which the column elements and column indices of the coordinate matrix are multiples of each other. Here, the column elements are the coordinate elements in the coordinate matrix. .
[0185] The target state of the SN unit is determined by determining the value of the second marker element in the target coordinate matrix and whether the value of the second marker element is equal to the third set value or the first set value.
[0186] In some embodiments, in response to the second marker element in the target coordinate matrix being a third set value, the target state of the SN unit is determined to be a through state. In response to the second marker element in the target coordinate matrix being a first set value, the target state of the SN unit is determined to be a cross state.
[0187] The first setting value is 1, and the third setting value is 0.
[0188] For example, let's take level-7 as an example.
[0189] The target state of the SN element in level-7 is determined as follows:
[0190] Query column element col equals col_index The target coordinate matrix of 2 is denoted as M;
[0191] If M.markData == 0, then the target state of the SN cell is the pass-through state;
[0192] If M.markData == 1, then the target state of the SN cell is the crossover state.
[0193] S508, arranges the vector elements based on the target state, and performs data processing based on the arranged vector elements.
[0194] In the embodiments of this application, step S508 can be implemented in any of the ways described in the various embodiments of this application. This is not limited here and will not be elaborated further.
[0195] In the vector element arrangement method provided in this application embodiment, by determining the position of the SN unit in the butterfly network, the target state of the SN unit can be determined in different ways according to the position, thereby improving the flexibility of target state determination, ensuring that data can flow from the first input port to the last output port without blocking, thereby optimizing the allocation of computing resources and improving the overall operating efficiency.
[0196] Figure 7 This is a flowchart illustrating another method for arranging vector elements provided in an embodiment of this application, as shown below. Figure 7 As shown, the method for arranging vector elements in this application includes, but is not limited to, the following steps:
[0197] S701: Obtain the vector elements to be processed, and determine the level of each switching node SN unit contained in the butterfly network based on the number of vector elements, so as to generate the butterfly network.
[0198] In the embodiments of this application, step S701 can be implemented in any of the ways described in the embodiments of this application. This is not limited here and will not be described in detail.
[0199] S702 sorts the levels of the butterfly network in ascending order.
[0200] S703 determines the input-output mapping relationship between any two levels based on the ranking results.
[0201] In some embodiments, the butterfly network exhibits a symmetrical structure. Based on a schematic diagram of the butterfly network, two symmetrical levels can be identified as pairs of levels with an input-output mapping relationship. These pairs of levels are defined as having a symmetrical relationship and include a lower level and a higher level.
[0202] In some embodiments, the levels can be sorted to determine whether there is an input-output mapping relationship between any two levels. Optionally, the first and last levels in the sorting results can be determined to establish an input-output mapping relationship between them.
[0203] For example, if the sorting result is level-1, level-2, level-3, level-4, level-5, level-6, and level-7, then it can be determined that there is a mapping relationship between level-1 and level-7, level-2 and level-6, and level-3 and level-5.
[0204] S704 determines the input / output mapping relationship based on the vector register of the corresponding SN unit at the lower level.
[0205] In some embodiments, the SN unit consists of two vector registers. The input-output mapping relationship between the two levels of the SN unit can be determined based on the data information stored in the vector registers. The data information may include data elements and index values.
[0206] In other words, the two vector registers in the SN unit can store data elements and index values respectively.
[0207] In some embodiments, data information from the vector register is obtained, and the data information between lower levels is compared for consistency. If the data information is identical, the input / output mapping relationship is determined based on this identical data information.
[0208] In some embodiments, since the SN unit has two inputs and two outputs, the output corresponding to each input can be determined separately. For example, the output port of SN0 in level-1 can be determined as the input-output mapping relationship in level-7.
[0209] In other words, if we can determine that there are target input ports of the lower-level SN units and target output ports of the higher-level SN units that have the same data information, then the input-output mapping relationship is: input is made from the target input port of the lower-level SN unit, and output is made from the target output port of the higher-level SN unit.
[0210] For example, if both the data elements and index values are 15, then the i-th data element and the j-th index value can be compared. If they are the same, the input port of the i-th SN unit in the lower level is determined as the target input port, and the output port of the j-th SN unit in the higher level is determined as the target output port. In other words, the input-output mapping relationship is that input is from the port of the i-th SN unit in the lower level, and output is from the port of the j-th SN unit in the higher level.
[0211] S705 determines the target state of the SN unit in each level based on the input-output mapping relationship.
[0212] S706, arranges the vector elements based on the target state, and performs data processing based on the arranged vector elements.
[0213] In the embodiments of this application, steps S704-S705 can be implemented in any of the embodiments of this application, and no limitation is made here, nor will it be described in detail.
[0214] The vector element arrangement method provided in this application involves determining pairwise levels with input-output mapping relationships, and then determining the input-output mapping relationships based on the data information of the lower-level SN units in each pairwise level. Once the input-output mapping relationships are determined, the target state of the SN units in each level can be determined based on these relationships, and the vector elements are arranged based on the target states. Therefore, this solution can rearrange vector elements, thereby enabling the mapping of complex and variable large model workloads onto vector hardware for efficient task execution.
[0215] Exemplary illustration, which can be based on Figure 2 The butterfly network in the text explains the arrangement of vector elements. Based on... Figure 2 First, determine the target state of the SN port in level-1 and level-7, then determine the target state of the SN port in level-2 and level-6, then determine the target state of the SN port in level-3 and level-5, and finally determine the target state of the SN port in level-4.
[0216] Figure 8 This is a schematic diagram illustrating the arrangement instructions provided in an embodiment of this application. It can be based on... Figure 8 The sorting instruction sorts the vector elements. Figure 8 It includes element index, data element, and index value. The data element is stored in the vector register (VS2), and the index value is stored in the vector register (VS1).
[0217] based on Figure 8By comparing whether the data elements and index values are the same, the input-output mapping relationship of the SN units in level-1 and level-7 can be determined. This mapping relationship is shown in Table 1 below:
[0218] Table 1
[0219]
[0220] Furthermore, based on Table 1, the coordinate matrix of the SN element in level-1 can be determined, and the coordinate matrix of the SN element in level-1 is shown in Table 2 below:
[0221] Table 2
[0222]
[0223] Furthermore, based on the coordinate matrix in Table 2, the target state of the SN unit in level-1 and level-7 can be calculated.
[0224] Let the column index of the matrix be col_index, where col_index is a natural number from 0 to 7.
[0225] The target state of the SN cell in level-1 is determined as follows:
[0226] The coordinate matrix is retrieved using the matrix column index to obtain SN[col_index].A.markData.
[0227] If SN[col_index].A.markData==0, then the target state of the SN cell is "pass-through";
[0228] If SN[col_index].A.markData==1, then the target state of the SN cell is "cross".
[0229] The target state of the SN element in level-7 is determined as follows:
[0230] Query column element col equals col_index The target coordinate matrix of 2 is denoted as M;
[0231] If M.markData == 0, then the target state of the SN cell is "pass-through";
[0232] If M.markData == 1, then the target state of the SN cell is "cross".
[0233] The target states of SN cells in level-1 and level-7 are shown in Table 3 below:
[0234] Table 3
[0235]
[0236] Based on the determination of the target states of SN units in level-1 and level-7 Figure 8 The data in the butterfly network is shown in Table 4 below. Empty entries in Table 4 indicate that the current step is not yet determined.
[0237] Table 4
[0238]
[0239] Based on Table 4, the input-output mapping relationship between level-2 and level-6 can be determined. The input-output mapping relationship between level-2 and level-6 is shown in Table 5 below. Indicates irrelevant items:
[0240] Table 5
[0241]
[0242] Furthermore, based on Table 5, the coordinate matrix of level-2 can be calculated, and the coordinate matrix of level-2 is shown in Table 6 below:
[0243] Table 6
[0244]
[0245] Based on Table 6, the target state of the SN unit in level-2 and level-6 can be calculated.
[0246] Let the column index of the matrix be col_index, where col_index is a natural number from 0 to 3.
[0247] The target state of the SN element in level-2 is determined as follows:
[0248] The coordinate matrix is retrieved using the matrix column index to obtain SN[col_index].A.markData.
[0249] If SN[col_index].A.markData==0, then the target state of the SN cell is "pass-through";
[0250] If SN[col_index].A.markData==1, then the target state of the SN cell is "cross".
[0251] The target state of the SN element in level-6 is determined as follows:
[0252] Query column element col equals col_index The target coordinate matrix of 2 is denoted as M;
[0253] If M.markData == 0, then the target state of the SN cell is "pass-through";
[0254] If M.markData == 1, then the target state of the SN cell is "cross".
[0255] The target states of SN cells in level-2 and level-6 are shown in Table 7 below:
[0256] Table 7
[0257]
[0258] Based on the determination of the target states of SN units in level-2 and level-6 Figure 8 The data in the butterfly network is shown in Table 8 below. Empty entries in Table 8 indicate that the current step is not yet determined.
[0259] Table 8
[0260]
[0261] Based on Table 8, the input-output mapping relationship between level-3 and level-5 can be determined. The input-output mapping relationship between level-3 and level-5 is shown in Table 9 below. Indicates irrelevant items:
[0262] Table 9
[0263]
[0264] Based on Table 9, the coordinate matrix of the SN unit in level-3 can be calculated, as shown in Table 10 below:
[0265] Table 10
[0266]
[0267] Based on Table 10, the target state of the SN unit in level-3 and level-5 can be calculated.
[0268] Let the column index of the matrix be col_index, where col_index is a natural number from 0 to 1.
[0269] The target state of the SN element in level-3 is determined as follows:
[0270] The coordinate matrix is retrieved using the matrix column index to obtain SN[col_index].A.markData.
[0271] If SN[col_index].A.markData==0, then the target state of the SN cell is "pass-through";
[0272] If SN[col_index].A.markData==1, then the target state of the SN cell is "cross".
[0273] The target state of the SN element in level-5 is determined as follows:
[0274] Query column element col equals col_index The target coordinate matrix of 2 is denoted as M;
[0275] If M.markData == 0, then the target state of the SN cell is "pass-through";
[0276] If M.markData == 1, then the target state of the SN cell is "cross".
[0277] The target states of SN cells in level-3 and level-5 are shown in Table 11 below:
[0278] Table 11
[0279]
[0280] Based on the determination of the target states of SN units in level-3 and level-5 Figure 8 The data in the butterfly network is shown in Table 12 below. Empty entries in Table 12 indicate that the current step is not yet determined.
[0281] Table 12
[0282]
[0283] Based on Table 12, we can... Figure 6 The target state of the SN unit in level-4 is determined in the manner shown below. The target states of the SN unit in level-4 are shown in Table 13 below:
[0284] Table 13
[0285]
[0286] Table 14 shows the data in... Figure 2 The states in the butterfly network shown:
[0287] Table 14
[0288]
[0289] Corresponding to the vector element arrangement methods proposed in the above embodiments, an embodiment of this application also proposes a vector element arrangement device. Since the vector element arrangement device proposed in this application corresponds to the vector element arrangement methods proposed in the above embodiments, the implementation methods of the above vector element arrangement methods are also applicable to the vector element arrangement device proposed in this application, and will not be described in detail in the following embodiments.
[0290] Figure 9 This is a schematic diagram of a vector element arrangement device provided in an embodiment of this application.
[0291] like Figure 9 As shown, the vector element arrangement device 900 includes:
[0292] The generation module 901 is used to acquire the vector elements to be processed and, based on the number of the vector elements, determine the level of each exchange node SN unit included in the butterfly network to generate the butterfly network; wherein, the butterfly network is used to arrange the vector elements;
[0293] The first determining module 902 is used to determine the input-output mapping relationship between the levels of each switching node SN unit included in the butterfly network;
[0294] The second determining module 903 is used to determine the target state of the SN unit in each level based on the input-output mapping relationship;
[0295] The arrangement module 904 is used to arrange the vector elements based on the target state, so as to perform data processing based on the arranged vector elements.
[0296] In one possible implementation of this application embodiment, the second determining module 903 is further configured to: determine a mapping table corresponding to the input-output mapping relationship; and determine a coordinate matrix corresponding to the SN unit based on the mapping table, so as to determine the target state of the SN unit based on the coordinate matrix.
[0297] In one possible implementation of this application embodiment, the second determining module 903 is further configured to: obtain the row index of the mapping relationship table and determine the target row where the SN unit corresponding to the row index is located; determine the first coordinate value of the target row with a value of a first set value from the mapping relationship table, and update the target element in the coordinate matrix based on the first coordinate value; determine the column index of the mapping relationship table based on the division result between the target element and the second set value; determine the target column where the SN unit corresponding to the column index is located, and determine the second coordinate value of the target column with a value of the first set value from the mapping relationship table, and update the remaining elements in the coordinate matrix based on the second coordinate value.
[0298] In one possible implementation of this application embodiment, the second determining module 903 is further configured to: obtain a first index and a second index; the first index is a top-down query index, and the second index is a bottom-up query index; query the first marker element in the updated coordinate matrix based on the first index and the second index to obtain a first query result and a second query result; and update the coordinate matrix based on the first query result and the second query result.
[0299] In one possible implementation of this application, the second determining module 903 is further configured to: determine the marker elements that should be included in the coordinate matrix; the marker elements include a first marker element and a second marker element; and update the marker elements based on the first query result and the second query result.
[0300] In one possible implementation of this application embodiment, the second determining module 903 is further configured to: determine the level of the SN unit and determine the position of the level in the butterfly network; in response to the position indicating that the level of the SN unit is the axis of symmetry of the butterfly network, determine the target state of the SN unit based on the first input index of the SN unit; in response to the position indicating that the level of the SN unit is not the axis of symmetry of the butterfly network, determine the target state of the SN unit based on the matrix column index of the coordinate matrix and the coordinate matrix.
[0301] In one possible implementation of this application, the second determining module 903 is further configured to: determine the value of the element corresponding to the matrix column index in the coordinate matrix; determine the target state of the SN unit as a pass-through state in response to the value of the second marker element corresponding to the matrix column index being a third set value; or determine the target state of the SN unit as a cross-connection state in response to the value of the second marker element corresponding to the matrix column index being a first set value.
[0302] In one possible implementation of this application embodiment, the second determining module 903 is further configured to: determine a coordinate matrix in which the column elements of the coordinate matrix have a multiple relationship with the column index of the matrix as a target coordinate matrix; determine the target state of the SN unit as a pass-through state in response to the second marker element in the target coordinate matrix being a third set value; or, determine the target state of the SN unit as a cross-connection state in response to the second marker element in the target coordinate matrix being a first set value.
[0303] In one possible implementation of this application, the target state of the SN unit is determined based on the matrix column index of the coordinate matrix and the coordinate matrix: the level adjacent to the level corresponding to the symmetry axis of the butterfly network is determined as the first level, wherein the first level is greater than the level corresponding to the symmetry axis of the butterfly network; the second input index of the SN unit corresponding to the first level is determined; in response to the first input index being equal to the second input index, the target state of the SN unit is determined to be a pass-through state, otherwise the target state of the SN unit is a cross-connected state.
[0304] In one possible implementation of this application, the arrangement module 904 is further configured to: determine the transmission path of the vector element in the butterfly network based on the target state; determine the input position and output position of the vector element in each SN unit based on the transmission path; and arrange the vector element based on the input position and output position.
[0305] In one possible implementation of this application embodiment, the first determining module 902 is further configured to: sort the levels of the butterfly network in ascending order; determine the input-output mapping relationship between pairs of levels based on the sorting result of the levels; wherein the pairs of levels are two levels with a symmetrical relationship, and the pairs of levels include a low level and a high level; and determine the input-output mapping relationship based on the vector register of the SN unit corresponding to the low level.
[0306] In one possible implementation of this application embodiment, the first determining module 902 is further configured to: acquire data information of the vector register; compare whether the data information between the lower levels is the same; and, in response to the data information being the same, determine the input-output mapping relationship based on the same data information.
[0307] In one possible implementation of this application embodiment, the first determining module 902 is further configured to: determine the target input port of the low-level SN unit and the target output port of the high-level SN unit that have the same data information; input from the target input port of the low-level SN unit and output from the target output port of the high-level SN unit.
[0308] The vector element arrangement device provided in this application determines the level of each SN unit in the butterfly network based on the number of vector elements to generate the butterfly network, and determines the input-output mapping relationship between SN units at each level. Based on the input-output mapping relationship, the target state of the SN units in each level is determined, and the vector elements are arranged based on the target state. Therefore, this solution can rearrange vector elements, allowing them to be transmitted non-blockingly in the butterfly network. This enables the mapping of complex and variable large model workloads onto vector hardware, achieving efficient data processing, reducing access latency, improving memory access efficiency and overall performance, and enabling large models to run on vector hardware at near-theoretical peak performance.
[0309] It should be noted that the explanation of the above-described method for arranging vector elements also applies to the vector element arrangement device of this embodiment, and will not be repeated here.
[0310] To implement the above embodiments, this application also proposes an electronic device, including: a processor and a memory communicatively connected to the processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory to implement the method provided in the foregoing embodiments.
[0311] To implement the above embodiments, this application also proposes a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods provided in the foregoing embodiments.
[0312] To implement the above embodiments, this application also proposes a computer program product, including a computer program that, when executed by a processor, implements the methods provided in the foregoing embodiments.
[0313] The collection, storage, use, processing, transmission, provision, and application of user personal information involved in this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0314] It should be noted that personal information collected from users should be used for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. Furthermore, such collection / sharing should only be conducted after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign an agreement / authorization that includes authorization of relevant user information before the user uses the function. In addition, any necessary steps must be taken to protect and safeguard access to such personal information data and ensure that others with access to personal information data comply with their privacy policies and procedures.
[0315] This application is intended to provide an implementation scheme for users to selectively prevent the use or access to their personal information data. Specifically, this application is intended to provide hardware and / or software to prevent or block access to such personal information data. Once personal information data is no longer needed, risks can be minimized by restricting data collection and deleting data. Furthermore, where applicable, such personal information is de-identified to protect user privacy.
[0316] In the foregoing descriptions of the embodiments, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0317] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0318] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0319] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0320] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any of the following techniques known in the art, or a combination thereof: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0321] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0322] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0323] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A method for arranging vector elements, characterized in that, The method includes: The process involves acquiring vector elements to be processed and determining the level of each switching node (SN) unit in the butterfly network based on the number of vector elements, thereby generating the butterfly network. The butterfly network is used to arrange the vector elements. Each SN unit has two inputs, each corresponding to a register. Each SN unit also has two outputs, each corresponding to a crossover unit. Determine the input-output mapping relationship between the levels of each switching node (SN) unit contained in the butterfly network; Based on the input-output mapping relationship, the target state of the SN unit in each level is determined; wherein, the target state includes a through state and a cross state; The vector elements are arranged based on the target state, and data processing is performed based on the arranged vector elements.
2. The method according to claim 1, characterized in that, The step of determining the target state of the SN unit in each level based on the input-output mapping relationship includes: Determine the mapping table corresponding to the input-output mapping relationship; Based on the mapping table, the coordinate matrix corresponding to the SN unit is determined, and the target state of the SN unit is determined based on the coordinate matrix.
3. The method according to claim 2, characterized in that, The step of determining the coordinate matrix corresponding to the SN unit based on the mapping table includes: Obtain the row index of the mapping table and determine the target row where the SN unit corresponding to the row index is located; The first coordinate value of the target row with a first set value is determined from the mapping table, and the target elements in the coordinate matrix are updated based on the first coordinate value. Based on the division result between the target element and the second set value, the column index of the mapping table is determined; The target column of the SN unit corresponding to the column index is determined, and the second coordinate value of the target column with the value of the first set value is determined from the mapping table. Based on the second coordinate value, the remaining elements in the coordinate matrix are updated.
4. The method according to claim 3, characterized in that, The method further includes: Retrieve the first index and the second index; the first index is a top-down index, and the second index is a bottom-up index. Based on the first index and the second index, query the first marked element in the updated coordinate matrix to obtain the first query result and the second query result; The coordinate matrix is updated based on the first query result and the second query result.
5. The method according to claim 4, characterized in that, The step of updating the coordinate matrix based on the first query result and the second query result includes: Determine the marker elements that should be included in the coordinate matrix; the marker elements include a first marker element and a second marker element; The marked element is updated based on the first query result and the second query result.
6. The method according to any one of claims 2-5, characterized in that, Determining the target state of the SN unit based on the coordinate matrix includes: Determine the level of the SN unit and the position of the level in the butterfly network; In response to the location indicating that the level of the SN unit is the axis of symmetry of the butterfly network, the target state of the SN unit is determined based on the first input index of the SN unit; In response to the location indicating that the level of the SN unit is not the axis of symmetry of the butterfly network, the target state of the SN unit is determined based on the matrix column index of the coordinate matrix and the coordinate matrix.
7. The method according to claim 6, characterized in that, The determination of the target state of the SN unit based on the matrix column index and the coordinate matrix includes: Determine the value of the element corresponding to the column index in the coordinate matrix; In response to the value of the second marker element corresponding to the matrix column index being a third preset value, the target state of the SN unit is determined to be a pass-through state; or, In response to the value of the second marker element corresponding to the matrix column index being a first set value, the target state of the SN unit is determined to be a cross state.
8. The method according to claim 7, characterized in that, The determination of the target state of the SN unit based on the matrix column index of the coordinate matrix and the coordinate matrix further includes: The target coordinate matrix is determined by identifying the coordinate matrix in which the column elements of the coordinate matrix have a multiple relationship with the column indices of the matrix. In response to the second marker element in the target coordinate matrix being a third preset value, the target state of the SN unit is determined to be a through state; or... In response to the second marker element in the target coordinate matrix being a first set value, the target state of the SN unit is determined to be a cross state.
9. The method according to claim 6, characterized in that, Determining the target state of the SN unit based on the first input index of the SN unit includes: The level adjacent to the level corresponding to the axis of symmetry of the butterfly network is determined as the first level, wherein the first level is greater than the level corresponding to the axis of symmetry of the butterfly network; Determine the second input index of the SN unit corresponding to the first level; In response to the first input index being equal to the second input index, the target state of the SN unit is determined to be a pass-through state; otherwise, the target state of the SN unit is a cross-connect state.
10. The method according to claim 1, characterized in that, The step of arranging the vector elements based on the target state includes: Determine the transmission path of the vector element in the butterfly network based on the target state; The input and output positions of the vector elements in each SN unit are determined based on the transmission path. The vector elements are arranged based on the input and output positions.
11. The method according to claim 1, characterized in that, Determining the input-output mapping relationship between the levels of each switching node (SN) unit in the butterfly network includes: The butterfly network is sorted in ascending order of its hierarchy; Based on the ranking results of the levels, it is determined that there is an input-output mapping relationship between any two levels; wherein, the two levels are two levels with a symmetrical relationship, and the two levels include a low level and a high level; The input-output mapping relationship is determined based on the vector register of the corresponding SN unit at the lower level.
12. The method according to claim 11, characterized in that, The step of determining the input-output mapping relationship based on the vector register corresponding to the lower-level SN unit includes: Obtain the data information of the vector register; Compare whether the data information between the lower levels is the same; In response to the identical data information, the input-output mapping relationship is determined based on the identical data information.
13. The method according to claim 12, characterized in that, The step of responding to the same data information and determining the input-output mapping relationship based on the same data information includes: Determine the target input port of the SN unit in the lower level and the target output port of the SN unit in the higher level that have the same data information. Input is received from the target input port of the SN unit in the lower level, and output is received from the target output port of the SN unit in the higher level.
14. A device for arranging vector elements, characterized in that, The device includes: A generation module is used to acquire vector elements to be processed and, based on the number of vector elements, determine the level of each switching node (SN) unit in the butterfly network to generate the butterfly network; wherein, the butterfly network is used to arrange the vector elements; each SN unit has two inputs, each corresponding to a register; each SN unit also has two outputs, each corresponding to a crossover unit; The first determining module is used to determine the input-output mapping relationship between the levels of each switching node (SN) unit included in the butterfly network; The second determining module is used to determine the target state of the SN unit in each level based on the input-output mapping relationship; wherein the target state includes a through state and a cross state; The arrangement module is used to arrange the vector elements based on the target state, so as to perform data processing based on the arranged vector elements.
15. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-13.
16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-13.
17. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1-13.