Time sequence processing method, computing device and storage medium
Through the periodic step-by-step calculation time series processing method, the existing DTW method has solved the problem of high computational complexity in large-scale data processing, and achieved more efficient time series processing.
Patent Information
- Application Number
- CN202510208047.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-06-27
AI Technical Summary
The existing dynamic time bending (DTW) methods have high computational complexity in large-scale time series data processing, making it difficult to meet the efficiency requirements of ultra-long sequences or real-time scenarios.
By obtaining multiple sets of time series, the absolute difference value of elements and the accumulated distance values in the accumulated distance matrix are calculated, and the periodic step-by-step calculation method is used to reduce the waiting time of the calculation unit and improve the calculation efficiency.
It effectively reduces the complexity and time of cumulative distance matrix calculation, improves the calculation efficiency of time series processing, and is suitable for ultra-long sequence and real-time scenarios.
Smart Images

Figure CN120215874A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of data processing, and in particular, to a time series processing method, a computing device, and a storage medium. Background Art
[0002] In time series analysis, Dynamic Time Warping (DTW) has become a core similarity measurement method due to its advantages in supporting asynchronous alignment and variable-length sequences. However, the high computational complexity of Dynamic Time Warping limits its large-scale applications. The existing optimization schemes for Dynamic Time Warping mainly include the following two categories:
[0003] First, based on the lower bound function of Dynamic Time Warping, pre-screening is used to eliminate non-matching candidate sequences, and only the sequences that meet the lower bound conditions are subjected to precise calculations.
[0004] Second, global constraints are adopted to reduce the path calculation amount by restricting the search range of the time warping window.
[0005] However, both methods focus on reducing the calculation scale and do not change the core cumulative cost matrix calculation mechanism of Dynamic Time Warping (DTW). For the sequences passed through screening or constraints, it is still necessary to traverse the two-dimensional matrix and calculate the minimum cumulative distance point by point according to the recursive relationship, and its time complexity remains unchanged.
[0006] Therefore, the existing optimizations only reduce the overall calculation frequency through path pruning and fail to break through the high complexity bottleneck of matrix calculation itself, making it difficult to meet the efficiency requirements of ultra-long sequences or real-time scenarios. Summary of the Invention
[0007] In view of this, embodiments of the present disclosure provide a time series processing method, a computing device, and a storage medium to improve the calculation efficiency.
[0008] Embodiments of the present disclosure provide a time series processing method. The time series processing method includes: obtaining x sets of time series; wherein each set of the time series includes: a first time series and a second time series; the first time series includes n first elements, and the second time series includes m second elements; the x sets of the time series correspond to x cumulative distance matrices; each of the cumulative distance matrices includes n*m third elements; starting from the third element at the beginning of the first cumulative distance matrix, calculating the absolute difference value and the cumulative distance value of the third element step by step according to a period until the cumulative distance values of all the third elements in the x cumulative distance matrices are calculated; wherein, for each cumulative distance matrix, calculating the cumulative distance value of the third elements at positions (y, z) and (y + 1, z - 1) in the same period; wherein, if (y + 1, z - 1) exceeds the position range of the cumulative distance matrix, no calculation is performed; y is less than or equal to n; z is less than or equal to m; x, n, y, and z are all positive integers.
[0009] In the above solution, for the third element at position (y, z) in each cumulative distance matrix, if the cumulative distance value of the third element is calculated in the i-th period, then in the j-th period, calculating the absolute difference value of the third elements at positions (y + 1, z) and (y, z + 1), and, in a period with a period ordinal number greater than or equal to j + 1, calculating the cumulative distance value of the third elements at positions (y + 1, z) and (y, z + 1); wherein, if (y + 1, z) and (y, z + 1) exceed the position range of the cumulative distance matrix, no calculation is performed; both i and j are positive integers; j is greater than or equal to i.
[0010] In the above solution, the time series processing method further includes: for each cumulative distance matrix, calculating the cumulative distance value of the third elements where the sum of y and z is equal to i + 1 in the i-th period, and calculating the absolute value difference of the third elements where the sum of y and z is equal to i + 2.
[0011] In the above solution, after obtaining the x sets of the time series, the time series processing method further includes: determining the number of calculation units according to the number of the first elements and the number of the second elements in each set of the time series; wherein the calculation unit is used to calculate the absolute difference value and the cumulative distance value; the number of the calculation units is greater than or equal to twice the minimum value of n and m.
[0012] In the above solution, the time series processing method further includes: for each cumulative distance matrix, after calculating the cumulative distance values of all the third elements where the sum of y and z is equal to p, calculating the cumulative distance value of the third elements where the sum of y and z is equal to p + 1; wherein p is greater than 1 and is an integer.
[0013] An embodiment of the present disclosure provides a computing device, which includes: a plurality of computing units and a control unit; wherein, the control unit is configured to obtain x sets of time series; wherein, each set of the time series includes: a first time series and a second time series; the first time series includes n first elements, and the second time series includes m second elements; the x sets of the time series correspond to x cumulative distance matrices; each of the cumulative distance matrices includes n*m third elements; the plurality of computing units are all connected to the control unit and are configured to start from the third element at the beginning of the 1st cumulative distance matrix and stepwise calculate the absolute difference and the cumulative distance value of the third element in cycles until the cumulative distance values of all the third elements in the x cumulative distance matrices are calculated; wherein, for each of the cumulative distance matrices, the cumulative distance values of the third elements at positions (y, z) and (y+1, z-1) are calculated in the same cycle; wherein, if (y+1, z-1) exceeds the position range of the cumulative distance matrix, no calculation is performed; y is less than or equal to n; z is less than or equal to m; x, n, y, and z are all positive integers.
[0014] In the above solution, for any one of the computing units in the calculation process, only one calculation of the absolute difference or one calculation of the cumulative distance value is performed in each cycle.
[0015] In the above solution, each of the computing units includes: a selector and an adder; wherein, the output end of the selector is connected to the input end of the adder.
[0016] In the above solution, the control unit is further configured to, for each cumulative distance matrix, calculate the cumulative distance value of the third element whose sum of y and z is equal to i+1 in the i-th cycle, and calculate the absolute value difference of the third element whose sum of y and z is equal to i+2; or, after calculating the cumulative distance values of all the third elements whose sum of y and z is equal to p, calculate the cumulative distance value of the third element whose sum of y and z is equal to p+1.
[0017] An embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program or instruction is stored, wherein, when the computer program or instruction is executed, the computer is made to execute the time series processing method according to any one of the above solutions. Description of the Drawings
[0018] Figure 1 Flow diagram of the time series processing method provided by the embodiment of the present disclosure Figure 1 ;
[0019] Figure 2Structural schematic diagram of a computing device provided by an embodiment of the present disclosure;
[0020] Figure 3 Flow schematic of a time series processing method provided by an embodiment of the present disclosure Figure 2 ;
[0021] Figure 4 Flow schematic of a time series processing method provided by an embodiment of the present disclosure Figure 3 ;
[0022] Figure 5 Flow schematic of a time series processing method provided by an embodiment of the present disclosure Figure 4 ;
[0023] Figure 6 Flow schematic of a time series processing method provided by an embodiment of the present disclosure Figure 5 ;
[0024] Figure 7 Structural schematic diagram of a computing unit in the prior art;
[0025] Figure 8 Structural schematic diagram of a computing unit provided by an embodiment of the present disclosure. Detailed implementation manners
[0026] In order to make the objectives, technical solutions, and advantages of the present disclosure clearer, the technical solutions of the present disclosure will be further elaborated in detail below in conjunction with the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on the present disclosure. All other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present disclosure.
[0027] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0028] If similar descriptions such as "first / second" appear in the application documents, the following explanation is added. In the following description, the terms "first / second / third" are only used to distinguish similar objects and do not represent a specific order for the objects. It can be understood that "first / second / third" can be interchanged with a specific order or sequence when allowed, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0029] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this disclosure belongs. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.
[0030] Figure 1 This is an optional time series processing method provided by an embodiment of the present disclosure. It should be noted that Figure 1 the shown time series processing method can be implemented by Figure 2 the shown computing device 200, and will be described in combination with Figure 1 the shown steps.
[0031] S101. Obtain x groups of time series; wherein, each group of time series includes: a first time series and a second time series; the first time series includes n first elements, and the second time series includes m second elements; the x groups of time series correspond to x cumulative distance matrices; each cumulative distance matrix includes n*m third elements.
[0032] In the embodiment of the present disclosure, with reference to Figure 2 , the computing device 200 can obtain x groups of time series. Each group of time series and each cumulative distance matrix corresponding to each group of time series can be understood with reference to Table 1 below:
[0033]
[0034] Table 1
[0035] It should be noted that n1, n2,..., n n in Table 1 are respectively the n first elements included in the first time series. m1, m2,..., m m in Table 1 are respectively the m second elements included in the second time series. k 11 , k 12 ,..., k nm in Table 1 are respectively the n*m third elements included in each cumulative distance matrix. The subscripts "11, 12,..., nm" of the third elements such as k 11 , k 12 ,..., k nm in Table 1 can be used to represent the row and column positions of the corresponding each third element in the cumulative distance matrix. Both n and m are positive integers.
[0036] In the embodiment of the present disclosure, with reference to Table 1, if the first time series is {n1, n2,..., n n}, and the second time series is {m1, m2,..., m m}, then the cumulative distance matrix corresponding to the first time series and the second time series can be
[0037] It should also be noted that the number of elements in the first time series (or the second time series) in the x groups of time series can be equal or unequal, and the number of elements in the first time series and the second time series can be any positive integer, without any restrictions.
[0038] S102. Starting from the third element at the beginning of the first cumulative distance matrix, calculate the absolute difference and cumulative distance value of the third element step by step in cycles until the cumulative distance values of all the third elements in x cumulative distance matrices are calculated; wherein, for each cumulative distance matrix, calculate the cumulative distance values of the third elements at positions (y, z) and (y + 1, z - 1) in the same cycle; wherein, if (y + 1, z - 1) exceeds the position range of the cumulative distance matrix, no calculation is performed; y is less than or equal to n; z is less than or equal to m; x, n, y, and z are all positive integers.
[0039] In the embodiments of the present disclosure, referring to Figure 2 , the computing device 200 can start the calculation from the k 11 in the first cumulative distance matrix and calculate x cumulative distance matrices step by step in cycles. That is to say, the computing device 200 can calculate the absolute difference and cumulative distance value of each third element step by step in different cycles. For example, during the process of calculating the first cumulative distance matrix, the computing device 200 can calculate the absolute differences of the third elements k 11 , k 12 , and k 21 in Table 1 in the first cycle; then, calculate the cumulative distance values of the third elements k 12 and k 21 in the second cycle, and the absolute differences of the third elements k 13 22 and k 31 and k nm in sequence according to the cycle until the cumulative distance value of the third element k nm in the first cumulative distance matrix is calculated. The calculation process of the remaining cumulative distance matrices can be understood by referring to the first cumulative distance matrix.
[0040] Specifically, the calculation method of the cumulative distance value of each third element can be understood by referring to the following formula (1):
[0041]
[0042] It should be noted that in formula (1), the meaning of "d yz " is the absolute difference of the third element at position (y, z) in the cumulative distance matrix, that is: the absolute value |n y - m z | of the difference between the first element n y in the first time series and the second element m z in the second time series; "k yz ", "k (y-1)(z-1) ", "k (y)(z-1) ", and "k (y-1)(z)” are the cumulative distance values of the third elements at the corresponding positions in the cumulative distance matrix. The result of the "min" operation is "k (y-1)(z-1) ”, “k (y)(z-1) ” and “k (y-1)(z) ” which is the minimum value among the three cumulative distance values.
[0043] It should also be noted that if there are no cells to the left, above, and diagonally above the left of the third element k 11 in Table 1, then the cumulative distance value of the third element k 11 is equal to its absolute difference d 11 . For the third elements k 21 , …, k n1 where there are no cells to the left and diagonally above the left, then for k 21 , …, k n1 in formula (1), the result of the "min" operation is the cumulative distance value of the corresponding cell above. For example, for the third element k 31 in formula (1), the result of the "min" operation is the cumulative distance value of the third element k 21 . For the third elements k 12 , …, k nm where there are no cells above and diagonally above the left, then for the third elements k 12 , …, k nm in formula (1), the result of the "min" operation is the cumulative distance value of the cell to the left. For example, for k 13 in formula (1), the result of the "min" operation is the cumulative distance value of the third element k 12 . In addition, for the remaining third elements, the cumulative distance values need to compare the cumulative distance values of the three cells above, to the left, and diagonally above the left. Therefore, after the cumulative distance values of the above three cells are calculated, the cumulative distance value of this third element can be calculated.
[0044] Next, taking the first time series {n1, n2, …, n n} = {4, 3, 8, 5} and the second time series {m1, m2, …, m m} = {2, 3, 6} as an example:
[0045] Combined with Table 2 and formula (1), the calculation device 200 can calculate the absolute differences of the third elements k 11 , k 12 and k 21 in Table 1 in the first cycle, and then calculate the cumulative distance values of the third elements k 11 , k 12 and k 21 in the second cycle, until the cumulative distance values of the third elements k 43The cumulative distance value. Thus, the cumulative distance matrix corresponding to the first time series {4, 3, 8, 5} and the second time series {2, 3, 6} can be as shown in Table 2 below:
[0046]
[0047] Table 2
[0048] In the embodiments of the present disclosure, referring to Figure 2 , for each cumulative distance matrix, the computing device 200 can calculate the cumulative distance value of the third element at positions (y, z) and (y + 1, z - 1) in the same cycle, that is: calculate the third element k yz and k (y+1)(z-1) of the cumulative distance value in the same cycle. For example, the cumulative distance values of the third element k 12 and k 12 in Table 1 can be calculated in the same cycle. Another example, the cumulative distance values of the third element k 13 and k 22 in Table 1 can be calculated in the same cycle, or the cumulative distance values of the third element k 22 and k 31 can be calculated in the same cycle, or the cumulative distance values of the third element k 13 、k 22 and k 31 can be calculated in the same cycle.
[0049] It should be noted that in the process of calculating the cumulative distance value of the third element at positions (y, z) and (y + 1, z - 1) in the same cycle, if (y + 1, z - 1) exceeds the position range of the cumulative distance matrix, no calculation is performed. For example, as shown in Table 2, when the third element at position (y, z) is k 42 , there is no third element at position (y + 1, z - 1) in the cumulative distance matrix, so no calculation is required. The cumulative distance value of the third element k 42 can be calculated in the same cycle as the cumulative distance value of the third element k 33 .
[0050] Furthermore, combining Table 2 and formula (1), k 23 = |n2 - m3| + min(k 12 , k 13 , k 22 ) = |3 - 6| + min(3, 5, 2) = 5. When calculating the cumulative distance value of the third element k 23 , it is necessary to compare k 12 , k 13 and k 22The cumulative distance value. At this time, due to the third element k 13 and k 22 The cumulative distance values are calculated in the same cycle, and the third element k 12 When calculating the cumulative distance value of the third element k 13 and k 22 The calculation is completed before calculating the cumulative distance values of and k 23 Therefore, there will be no need to wait for the cumulative distance value of one of the third elements k 12 , k 13 and k 22 during the process of calculating the cumulative distance value of the third element k
[0051] That is to say, after calculating the cumulative distance values of the third elements at positions (y, z) and (y + 1, z - 1) in the same cycle, since the cumulative distance values of the third elements at positions (y, z) and (y + 1, z - 1) are calculated in the same cycle, and the calculation of the third element at position (y, z - 1) is completed before calculating the cumulative distance values of the third elements at positions (y, z) and (y + 1, z - 1). In this way, during the process of calculating the cumulative distance value of the third element at position (y + 1, z), the cumulative distance values of (y, z), (y + 1, z - 1) and (y, z - 1) do not need to wait, eliminating the data ready waiting time during the calculation of the cumulative distance value of (y + 1, z), that is: for some or all of the third elements in each cumulative distance matrix, the data ready waiting time is eliminated. Thus, the embodiments of the present disclosure can save calculation time and improve calculation efficiency.
[0052] In some embodiments of the present disclosure, S102 shown in Figure 3 can be implemented through S201 shown in Figure 1 which will be described in combination with each step.
[0053] S201. For the third element at position (y, z) in each cumulative distance matrix, if the cumulative distance value of the third element is calculated in the i-th cycle, then calculate the absolute difference of the third elements at positions (y + 1, z) and (y, z + 1) in the j-th cycle, and calculate the cumulative distance values of the third elements at positions (y + 1, z) and (y, z + 1) in cycles with a cycle ordinal greater than or equal to j + 1; wherein, if (y + 1, z) and (y, z + 1) exceed the position range of the cumulative distance matrix, no calculation is performed; both i and j are positive integers; j is greater than or equal to i.
[0054] In the embodiments of the present disclosure, with reference to Figure 2, the computing device 200 may calculate the cumulative distance value of the third element located at (y, z) in the i-th cycle, and calculate the absolute difference of the third elements located at (y + 1, z) and (y, z + 1) in the j-th cycle. j is greater than or equal to i. For example, as shown in Table 2, the computing device 200 may simultaneously calculate the cumulative distance value of the third element k 21 and the cumulative distance value of the third element k 22 and k 31 in the second cycle. That is to say, the absolute difference of the third elements located at (y + 1, z) and (y, z + 1) can be calculated in the same cycle as the cumulative distance value of the third element located at (y, z). For another example, as shown in Table 2, the computing device 200 may calculate the cumulative distance value of k 21 in the second cycle, and calculate the absolute difference of the third elements k 12 and k 21 in the third cycle or a cycle with a cycle ordinal number greater than 3. That is to say, after calculating the cumulative distance value of the third element located at (y, z), the absolute difference of the third elements located at (y + 1, z) and (y, z + 1) is calculated.
[0055] In the embodiments of the present disclosure, with reference to Figure 2 , the computing device 200 may calculate the cumulative distance value of the third elements located at (y + 1, z) and (y, z + 1) in a cycle with a cycle ordinal number greater than or equal to j + 1. For example, as shown in Table 2, when calculating the cumulative distance values of the third elements k 12 and k 21 in the second cycle, the computing device 200 may calculate the absolute difference of the third elements k 12 and k 21 in the third cycle or a cycle with a cycle ordinal number greater than 3. In this way, since the absolute difference of the third elements located at (y + 1, z) and (y, z + 1) is calculated in the same cycle, the cumulative distance value of the third elements located at (y + 1, z) and (y, z + 1) can be calculated in the same cycle. Therefore, the embodiments of the present disclosure can avoid waiting for the readiness of the absolute difference of (y + 1, z) and (y, z + 1) during the process of simultaneously calculating the cumulative distance values of the third elements located at (y + 1, z) and (y, z + 1), further eliminating the time for waiting for data readiness, and can further save the calculation time and improve the calculation efficiency.
[0056] In some embodiments of the present disclosure, S102 shown in Figure 4 may be implemented through S301 shown in Figure 1 , and will be described in combination with each step.
[0057] S301. For each cumulative distance matrix, calculate the cumulative distance value of the third element where the sum of y and z equals i + 1 in the i-th cycle, and calculate the absolute value difference of the third element where the sum of y and z equals i + 2.
[0058] It should be noted that both the i-th and the (i + 1)-th cycles here are the cycle ordinal numbers of the current cumulative distance matrix, and the cycle ordinal number of the current cumulative distance matrix starts from 1.
[0059] In the embodiments of the present disclosure, with reference to Figure 2 , the calculation device 200 can calculate the cumulative distance value of the third element where the sum of y and z equals i + 1 in the i-th cycle, and calculate the absolute value difference of the third element where the sum of y and z equals i + 2. For example, as shown in Table 2, the calculation device 200 can calculate the cumulative distance value of the third elements k 12 and k 21 in the 2nd cycle, and the absolute value difference of the third elements k 13 , k 22 and k 31 . Then, the calculation device can calculate the cumulative distance value of the third elements k 13 , k 22 and k 31 in the 3rd cycle, and the absolute value difference of the third elements k 23 , k 32 and k 41 . In this way, after calculating the cumulative distance value of the third elements k 12 and k 21 in the 2nd cycle, and the absolute value difference of the third elements k 13 , k 22 and k 31 , the cumulative distance value of the third elements k 13 , k 22 and k 31 can be calculated in the 3rd cycle.
[0060] That is to say, the multiple cumulative distance values and multiple absolute difference values calculated in the previous cycle can be used for the calculation of the cumulative distance value in the next cycle, that is: the calculation result of the previous cycle can be used as the input of the next cycle. Thus, the embodiments of the present disclosure do not require additional storage resources to store the calculated absolute difference values and cumulative distance values, reducing the area of the calculation device 200. At the same time, the input of the absolute difference values and cumulative distance values required for calculation in each cycle can be completed in the previous cycle, eliminating the time for data ready waiting. Therefore, the calculation time can be saved and the calculation efficiency can be improved.
[0061] In some embodiments of the present disclosure, after obtaining x sets of time series, it is also possible to pass through Figure 5The time series processing method is implemented by S401 shown below, and will be described in conjunction with each step.
[0062] S401. According to the number of first elements and the number of second elements in each group of time series, determine the number of computing units; wherein, the computing units are used to calculate the absolute difference and the cumulative distance value; the number of computing units is greater than or equal to twice the minimum value of n and m.
[0063] In the embodiments of the present disclosure, with reference to Figure 2 , each computing unit performs only one absolute difference calculation or only one cumulative distance value calculation in each cycle. To meet the requirements of the processing methods such as S301 in the above embodiments, it is necessary to obtain the number of computing units required for each group of time series. The computing device 200 can determine the number of computing units according to the number of first elements and the number of second elements in each group of time series.
[0064] Taking the requirement of meeting the processing methods such as S301 as an example: the number of first elements in a group of time series corresponding to Table 2 is 4, and the number of second elements is 3. Arranged according to the cycle ordinal number, the number of calculations in the 3rd and 4th cycles is the largest, both being 6 times. For example, in the 3rd cycle, it is necessary to calculate the cumulative distance values of the third elements k 13 , k 22 and k 31 , and the absolute differences of the third elements k 23 , k 32 and k 41 . Therefore, the number of computing units required for a group of time series corresponding to Table 2 is 6. In this way, the embodiments of the present disclosure can allocate the number of computing units for each cumulative distance matrix to meet the calculation requirements of the cumulative distance matrix. Thus, the waiting caused by insufficient computing units is avoided, the computing time is further saved, and the computing efficiency is improved.
[0065] In some embodiments of the present disclosure, the time series processing method can also be implemented by S501, and will be described in conjunction with each step.
[0066] S501. For each cumulative distance matrix, after calculating the cumulative distance values of all the third elements where the sum of y and z is equal to p, calculate the cumulative distance values of the third elements where the sum of y and z is equal to p + 1; wherein, p is greater than 1 and is an integer.
[0067] It should be noted that in accordance with Figure 3During the calculation of x groups of time series by the shown time series processing method, there may be a situation where the number of calculation units is insufficient. For example, for a group of time series corresponding to Table 2, the number of the first elements is 4, and the number of the second elements is 3. Arranged according to the cycle ordinal number, the number of calculations in the 3rd and 4th cycles is the largest, both being 6 times. If the number of calculation units is less than 6, S301 cannot be implemented.
[0068] In the embodiments of the present disclosure, with reference to Figure 2 , during the calculation of each cumulative distance matrix, the calculation device 200 may calculate the cumulative distance value of all the third elements where the sum of y and z is equal to p + 1 after calculating the cumulative distance value of all the third elements where the sum of y and z is equal to p. For example, as shown in Table 2, the sum of the row and column positions of the third elements k 12 and k 21 is equal to 3, and the sum of the row and column positions of the third elements k 13 、k 22 and k 31 is equal to 4. The calculation device 200 may calculate the cumulative distance value of the third elements k 12 and k 21 and then calculate the cumulative distance value of the third elements k 13 、k 22 and k 31 ; wherein, the third elements k 13 、k 22 and k 31 can be calculated within multiple cycles. That is to say, the input of the absolute difference and the cumulative distance value required for the calculation in each cycle can be completed before the current cycle. In this way, the embodiments of the present disclosure can avoid waiting for data readiness due to insufficient calculation units. Thus, the calculation time can be further saved and the calculation efficiency can be improved.
[0069] Figure 6 FIG. is a schematic flowchart of another optional time series processing method provided by the embodiments of the present disclosure, which will be described in conjunction with each step.
[0070] S601. Start.
[0071] S602. Input all sequence matrix parameters.
[0072] In the embodiments of the present disclosure, with reference to Figure 2 , external devices such as the host computer input all sequence matrix parameters to the calculation device 200. That is: the calculation device 200 can obtain x groups of time series.
[0073] S603. Confirm the number of calculation units.
[0074] In the embodiments of the present disclosure, with reference toFigure 2 The computing device 200 can determine the number of computing units required for each group of time series according to the number of first elements and the number of second elements of x groups of time series.
[0075] S604. Oblique two-stage calculation.
[0076] In the embodiments of the present disclosure, referring to Figure 2 , the computing device 200 can perform two-stage calculation on x groups of time series, that is: the computing device 200 can split the calculation of the absolute difference and the cumulative distance matrix of each third element and perform them in different cycles.
[0077] In the embodiments of the present disclosure, referring to Figure 2 , the computing device 200 can perform oblique calculation on each group of time series, that is: the computing device 200 can make multiple third elements with equal row-column values of each group of time series in the same calculation state. That is to say, the computing device 200 can calculate the cumulative distance values (or absolute differences) of multiple third elements with equal row-column values in each cumulative distance matrix in the same cycle.
[0078] S605. The calculation of the end unit is completed.
[0079] S606. Result output.
[0080] S607. End.
[0081] In the embodiments of the present disclosure, referring to Figure 2 , after calculating the cumulative distance matrix of x groups of time series, the computing device 200 can output the last cumulative distance value in multiple cumulative distance matrices as the result.
[0082] In some embodiments of the present disclosure, referring to Figure 2 , the computing device 200 includes multiple computing units. For example, as Figure 2 shown, the computing device 200 may include computing units 10a, 10b, and 10c. The computing device 200 may also include a greater number of computing units, which is not limited here. The computing device 200 may also include devices such as a buffer to store the output results of multiple computing units.
[0083] It should be noted that the computing device 200 and the time series processing method in the above embodiments can be applied to fields such as speech recognition, gesture recognition, information retrieval, and data mining.
[0084] In the embodiments of the present disclosure, referring to Figure 2, the computing device 200 further includes a control unit 20. The computing device 200 is configured to obtain x sets of time series; wherein, each set of time series includes: a first time series and a second time series; the first time series includes n first elements, and the second time series includes m second elements; the x sets of time series correspond to x cumulative distance matrices; each cumulative distance matrix includes n*m third elements. The control unit 20 may include n first elements in the first time series and m second elements in the second time series according to each computing unit.
[0085] In the embodiments of the present disclosure, with reference to Figure 2 , a plurality of computing units 10 are all connected to the control unit 20. The plurality of computing units 10 are configured to start from the third element at the beginning of the first cumulative distance matrix and stepwise calculate the absolute difference value and the cumulative distance value of the third element in a cycle until the cumulative distance values of all the third elements in the x cumulative distance matrices are calculated; wherein, for each cumulative distance matrix, the cumulative distance values of the third elements at positions (y, z) and (y + 1, z - 1) are calculated in the same cycle; wherein, if (y + 1, z - 1) exceeds the position range of the cumulative distance matrix, no calculation is performed; y is less than or equal to n; z is less than or equal to m; x, n, y, and z are all positive integers.
[0086] It can be understood that after calculating the cumulative distance values of the third elements at positions (y, z) and (y + 1, z - 1) in the same cycle, since the cumulative distance values of the third elements at positions (y, z) and (y + 1, z - 1) are calculated in the same cycle, and the calculation of the third element at position (y - 1, z) is completed before calculating the cumulative distance values of the third elements at positions (y, z) and (y + 1, z - 1). In this way, during the process of calculating the cumulative distance value of the third element at position (y + 1, z), the situation of waiting is avoided, thereby saving calculation time and improving calculation efficiency.
[0087] Figure 7 is a schematic structural diagram of a computing unit of the prior art provided by the embodiments of the present disclosure. It should be noted that in the prior art, the computing unit shown in Figure 7 is usually used to calculate the cumulative distance value. For example, when calculating the cumulative distance value of the third element k Figure 7 in Table 2 above using the computing unit shown in 22 , the first selector will receive the first element n2 and the second element m2 corresponding to the third element k 22 , the first selector calculates and outputs the absolute difference value of the third element k 22 , and the second selector receives three third elements (k 11 , k 21 , and k 12)'s cumulative distance value and compare them, and output the comparison results of the cumulative distance values of three third elements (k 11 , k 21 and k 12 ); then, the second adder sums the absolute difference of the third element k 22 from the first adder, and the comparison results of the cumulative distance values of three third elements (k 11 , k 21 and k 12 ) from the second selector, and outputs the cumulative distance value of the third element k 22 . In this way, the third element needs to wait for the absolute difference to be ready before calculating the cumulative distance value. That is to say, in the prior art, the calculation of the cumulative distance value and the absolute difference is highly coupled, and the data ready time in the process of calculating the cumulative distance value is relatively long.
[0088] In some embodiments of the present disclosure, referring to Figure 2 , for any computing unit in the process of calculation, only one absolute difference or one cumulative distance value is calculated in each cycle. For example, the absolute difference and the cumulative distance value of the third element k 22 are calculated respectively by two Figure 8 shown computing units 10, that is: the embodiments of the present disclosure can split the absolute difference and the cumulative distance value of each third element through the Figure 8 shown computing unit 10. Another example is that the embodiments of the present disclosure can introduce bypass logic (Bypass) at the output end of the first adder of the computing unit described in Figure 7 , skip the second adder when only the absolute difference is needed, and directly output the result of the absolute difference; and add an input end to the second adder to receive the absolute difference calculated in advance, so as to split the absolute difference and the cumulative distance value of each third element.
[0089] It can be understood that the embodiments of the present disclosure split the calculation of the absolute difference and the cumulative distance value of each third element. In this way, in the case where the cumulative distance value of any third element cannot be calculated, the embodiments of the present disclosure can use the idle computing unit to calculate the absolute difference of this third element in advance, so as to avoid the situation of idle computing units and improve the hardware utilization rate. And in the case of calculating the cumulative distance value, the embodiments of the present disclosure can directly call the calculated absolute difference, avoiding the situation of waiting for the absolute difference to be ready, thereby saving calculation time and improving calculation efficiency.
[0090] In some embodiments of the present disclosure, referring to Figure 8 , each computing unit 10 includes a selector 11 and an adder 12. Among them, the output end of the selector 11 is connected to the input end of the adder 12.
[0091] It should also be noted that Figure 7 The prior art shown in the figure cascades the absolute difference calculation (the first adder) with the cumulative distance comparison and summation (the second adder). Even in some scenarios where only the absolute difference needs to be calculated, the data still has to flow through the second adder. In this way, in the case of only calculating the absolute difference, the data will also pass through the second adder, thus increasing the latency during the calculation of only the absolute difference. Moreover, if only the absolute difference is calculated, the second adder and the second selector are idle, resulting in waste of devices.
[0092] In the embodiments of the present disclosure, referring to Figure 8 , during the process of the calculation unit 10 calculating the absolute difference, the selector 11 can receive the first element and the second element, and output the selection results of the first element and the second element to the adder 12. The adder 12 calculates the absolute difference between the first element and the second element, and directly outputs the calculated absolute difference through its output terminal. In this way, compared with the related art, in the embodiments of the present disclosure, during the process of only calculating the absolute difference, the calculation latency is reduced and the calculation efficiency is improved.
[0093] In the embodiments of the present disclosure, referring to Figure 8 , during the process of the calculation unit 10 calculating the cumulative distance value, the selector 11 can receive three cumulative distance values, compare and output the comparison results of the three cumulative distance values. The two input terminals of the adder 12 respectively receive the comparison results of the three cumulative distance values and the absolute difference, and calculate and output the cumulative distance value according to what is shown in formula (3). In this way, compared with the related art, in the embodiments of the present disclosure, during the process of only calculating the cumulative distance value, waiting for the absolute difference to be ready is avoided, and the calculation efficiency is improved. At the same time, the calculation of the cumulative distance value does not cause waste of devices, and the device utilization efficiency is improved.
[0094] In some embodiments of the present disclosure, referring to Figure 2 , the control unit 20 is further configured to, for each cumulative distance matrix, calculate the cumulative distance value of the third element where the sum of y and z is equal to i + 1 in the i-th cycle, and calculate the absolute value difference of the third element where the sum of y and z is equal to i + 2; or, after calculating the cumulative distance values of all third elements where the sum of y and z is equal to p, calculate the cumulative distance value of the third element where the sum of y and z is equal to p + 1; where p is greater than 1 and is an integer.
[0095] In the embodiments of the present disclosure, in combination with Figure 2 and Figure 8 , the control unit 20 can use the calculation unit 10 shown in Figure 8 to calculate the cumulative distance matrix in Table 3 below, and the calculation results of different calculation methods are shown in Table 4:
[0096]
[0097] Table 3
[0098]
[0099] Table 4
[0100] It should be noted that Table 3 can be understood with reference to Table 2, and details are not elaborated here. The calculation method of S301 in Table 4 and Related Art 1 both use 4 calculation units as shown in Figure 8 for calculation. Related Art 2 in Table 4 uses 2 calculation units as shown in Figure 7 for calculation. The calculation method of Related Art 1 is calculated in the calculation direction from left to right and from top to bottom, that is: in sequence according to k 11 、k 12 、k 13 、k 14 、k 21 、k 22 、k 23 and k 24 order for calculation. The calculation order of the cumulative distance value of the calculation method of Related Art 2 is the same as that of S301, but the calculation of its absolute difference and cumulative distance value is not split.
[0101] In the embodiments of the present disclosure, in combination with Table 3 and Table 4, the control unit 20 can calculate the cumulative distance value of the third element whose sum of y and z is equal to i + 1 in the i-th cycle, and calculate the absolute difference of the third element whose sum of y and z is equal to i + 2. For example, in the second cycle, the control unit 20 can allocate 4 calculation units to d 13 、d 22 、k 12 and k 21 for calculation. Thus, compared with the calculation method of Related Art 1, the embodiments of the present disclosure reduce the number of calculation cycles, thereby reducing the calculation time and improving the calculation efficiency.
[0102] In the embodiments of the present disclosure, in combination with Table 3 and Table 4, the control unit 20 can split the absolute difference and the cumulative distance value. Thus, compared with the calculation method of Related Art 2, the delay of the calculation unit in the embodiments of the present disclosure is small, thereby reducing the delay of each calculation cycle, reducing the calculation time, and improving the calculation efficiency.
[0103] In the embodiments of the present disclosure, referring to Table 3, when the number of computing units does not meet the calculation method of S301, the control unit 20 may calculate the cumulative distance value of all third elements where the sum of y and z is equal to p + 1 after calculating the cumulative distance value of all third elements where the sum of y and z is equal to p. In this way, the embodiments of the present disclosure can avoid data ready waiting caused by insufficient computing units. Thus, the computing time can be further saved and the computing efficiency can be improved.
[0104] The embodiments of the present disclosure also provide a computer-readable storage medium, in which a computer program is stored. When the computer program is run by a processor, some or all of the steps in the time series processing method provided in the above embodiments are implemented.
[0105] The embodiments of the present disclosure also provide a computer program product, which includes a computer program stored in a computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute some or all of the steps in the time series processing method provided in the above embodiments.
[0106] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.
[0107] The serial numbers of the above embodiments of the present disclosure are only for description and do not represent the advantages and disadvantages of the embodiments. The methods disclosed in several method embodiments provided by the present disclosure can be arbitrarily combined without conflict to obtain new method embodiments. The features disclosed in several product embodiments provided by the present disclosure can be arbitrarily combined without conflict to obtain new product embodiments. The features disclosed in several method or device embodiments provided by the present disclosure can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0108] The above is only the specific implementation manner of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present disclosure, and all of them should be covered by the protection scope of the present disclosure.
Claims
1. A time series processing method, comprising: Obtain x groups of time series; wherein each group of the time series includes: a first time series and a second time series; the first time series includes n first elements, and the second time series includes m second elements; the x groups of the time series correspond to x cumulative distance matrices; each of the cumulative distance matrices includes n*m third elements; Starting from the third element in the first cumulative distance matrix, the absolute difference and cumulative distance value of the third element are calculated step by step according to the cycle until the cumulative distance values of all the third elements in the x cumulative distance matrices are calculated; wherein, For each of the cumulative distance matrices, the cumulative distance values of the third elements at positions (y, z) and (y+1, z-1) are calculated in the same period; if (y+1, z-1) exceeds the position range of the cumulative distance matrix, no calculation is performed; y is less than or equal to n; z is less than or equal to m; x, n, y and z are all positive integers.
2. The time series processing method according to claim 1, wherein: For each of the third elements at position (y, z) in the cumulative distance matrix, if the cumulative distance value of the third element is calculated in the i-th period, then the absolute difference between the third elements at positions (y+1, z) and (y, z+1) is calculated in the j-th period, and, in the period with a period ordinal greater than or equal to j+1, the cumulative distance values of the third elements at positions (y+1, z) and (y, z+1) are calculated; wherein, if (y+1, z) and (y, z+1) exceed the position range of the cumulative distance matrix, no calculation is performed; i and j are both positive integers; j is greater than or equal to i.
3. The time series processing method according to claim 1, wherein: The time series processing method further includes: For each of the cumulative distance matrices, the cumulative distance value of the third element whose sum of y and z is equal to i+1 is calculated in the i-th cycle, and the absolute value difference of the third element whose sum of y and z is equal to i+2 is calculated.
4. The time series processing method according to claim 3, wherein: After obtaining x groups of the time series, the time series processing method further includes: The number of calculation units is determined according to the number of the first elements and the number of the second elements in each group of the time series; wherein the calculation unit is used to calculate the absolute difference and the cumulative distance value; and the number of the calculation units is greater than or equal to twice the minimum value of n and m.
5. The time series processing method according to claim 1, wherein: The time series processing method further includes: For each of the cumulative distance matrices, after calculating the cumulative distance values of all the third elements whose sum of y and z is equal to p, calculate the cumulative distance value of the third element whose sum of y and z is equal to p+1; wherein p is greater than 1 and is an integer.
6. A computing device, wherein: include: A plurality of computing units and control units; wherein, The control unit is configured to obtain x groups of time series; each group of the time series includes: a first time series and a second time series; the first time series includes n first elements, and the second time series includes m second elements; the x groups of the time series correspond to x cumulative distance matrices; each of the cumulative distance matrices includes n*m third elements; Multiple calculation units are connected to the control unit and are configured to start from the third element starting from the first cumulative distance matrix, and calculate the absolute difference and cumulative distance value of the third element step by step according to a period until the cumulative distance values of all the third elements in the x cumulative distance matrices are calculated; wherein, for each cumulative distance matrix, the cumulative distance values of the third elements at positions (y, z) and (y+1, z-1) are calculated in the same period; wherein, if (y+1, z-1) exceeds the position range of the cumulative distance matrix, no calculation is performed; y is less than or equal to n; z is less than or equal to m; x, n, y and z are all positive integers.
7. The computing device according to claim 6, wherein: For any calculation unit in the process of calculation, the calculation of the absolute difference value or the cumulative distance value is performed only once in each cycle.
8. The computing device according to claim 6, wherein: Each of the calculation units includes: a selector and an adder; wherein the output end of the selector is connected to the input end of the adder.
9. The computing device according to claim 7, wherein the control unit is further configured to calculate, for each cumulative distance matrix, in the i-th period, the cumulative distance value of the third element whose sum of y and z is equal to i+1, and calculate the absolute value difference of the third element whose sum of y and z is equal to i+2; or, after calculating the cumulative distance values of all the third elements whose sum of y and z is equal to p, calculate the cumulative distance value of the third element whose sum of y and z is equal to p+1; wherein, p is greater than 1 and is an integer.
10. A computer-readable storage medium having a computer program or instruction stored thereon, wherein: When the computer program or instruction is executed, the computer is caused to perform the time series processing method according to any one of claims 1 to 5.