Data processing method, device, terminal equipment and computer readable storage medium
By dividing the dynamic tensor shape into multiple intervals and filling it with reference shapes, the problem of increasing the amount of operations caused by static processing in the prior art is solved, and the processing performance of the neural network model is improved.
Patent Information
- Application Number
- CN202111296774.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-03
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2041-11-03
AI Technical Summary
When processing neural network models with dynamic tensor shapes in the prior art, static processing methods lead to an increase in the amount of operations and low processing performance, especially when the input data tensor shape changes in a large range.
By dividing the initial shape of the input data into multiple data shape intervals and filling the initial data with the reference data shape to which it belongs, inputting it into the target model, avoiding additional operations introduced by the shape limit value, and improving static processing fine grain size and performance.
It effectively reduces the amount of calculations in the static processing of dynamic shapes, improves processing performance, and ensures that the calculation results equal to the dynamic input data are obtained within the data shape interval.
Smart Images

Figure CN114219695B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a data processing method, apparatus, terminal device and computer-readable storage medium. Background Art
[0002] Typically, neural network models are presented in a static shape. Specifically, these models are represented as static data flow graphs, where the shape and size of each node input and output (i.e., tensor or n-dimensional array) are known in advance, and the shape of the data remains unchanged for each call. With the development of deep learning technology, some neural network models have shown dynamic shape characteristics, which brings complexity to model compilation overhead, memory usage, optimization pipeline and deployment.
[0003] In order to solve the above problems, it is necessary to statically process the model of dynamic tensor shape. The existing static processing method usually takes the limit value within the optional shape range of the input data as the input data shape of the model. When the range of variation of the tensor shape of the input data is large, the above method will generate more additional operations, resulting in lower processing performance. Summary of the invention
[0004] The embodiments of the present application provide a data processing method, apparatus, terminal device and computer-readable storage medium, which can effectively reduce the amount of calculation in the process of staticizing the dynamic shape of calculation data and improve the processing performance.
[0005] In a first aspect, an embodiment of the present application provides a data processing method, including:
[0006] Acquire first data of an input target model and an initial data shape of the first data;
[0007] Acquire a data shape interval corresponding to the target model and a reference data shape corresponding to each of the data shape intervals;
[0008] Determine a reference data shape corresponding to a target interval as a target shape, wherein the target interval is a data shape interval to which the initial data shape belongs;
[0009] Filling the first data of the initial data shape with data of the target shape to obtain processed data;
[0010] The processed data is input into the target model to obtain output data.
[0011] In the embodiment of the present application, the interval division of the input data of the dynamic tensor form is realized through multiple data shape intervals, which increases the fine-grainedness of the static processing and ensures that the calculation results equivalent to the dynamic input data are obtained within the data shape interval; by filling the data of the initial data shape with the reference data shape corresponding to the data shape interval to which it belongs, the additional calculations caused by the introduction of the shape limit value are avoided, the amount of calculations in the static processing process is reduced, and the processing performance is improved.
[0012] In a possible implementation manner of the first aspect, acquiring the data shape interval corresponding to the target model and the reference data shape corresponding to each of the data shape intervals includes:
[0013] Acquire a data range of a data shape of input data of the target model;
[0014] Dividing the data range into a plurality of data shape intervals;
[0015] The reference data shape corresponding to each of the data shape intervals is determined.
[0016] In a possible implementation manner of the first aspect, dividing the data range into a plurality of data shape intervals includes:
[0017] Sampling a plurality of sample data from the data range;
[0018] Acquire performance data corresponding to each of the plurality of sample data, wherein the performance data corresponding to each of the sample data represents the performance of the target model when the sample data is used as the data shape of input data of the target model;
[0019] respectively calculating the slope of the performance data between every two adjacent sampling data;
[0020] Determine performance mutation data from the plurality of sampled data according to the slope;
[0021] The data range is divided into a plurality of data shape intervals according to the performance mutation data.
[0022] In a possible implementation manner of the first aspect, determining the performance mutation data from the multiple sampled data according to the slope includes:
[0023] If the second data is greater than or equal to a preset multiple of the third data, the i-th sampled data is determined as the performance mutation data, where the second data is the slope of the performance data between the i-th sampled data and the (i + 1)-th sampled data, the third data is the slope of the performance data between the (i - 1)-th sampled data and the i-th sampled data, 1 < i < M, i is a positive integer, and M is the number of sampled data sampled from the data range.
[0024] In a possible implementation manner of the first aspect, the dividing the data range into a plurality of the data shape intervals according to the performance mutation data includes:
[0025] If the ratio of the fourth data to the fifth data is greater than a preset judgment threshold, the data shape interval between the (k - 1)-th performance mutation data and the k-th performance mutation data is divided into N segments, where the fifth data is the increment value between the (k - 1)-th performance mutation data and the k-th performance mutation data, the fourth data is the increment value between the performance data of the (k - 1)-th performance mutation data and the performance data of the k-th performance mutation data, and N is determined by the fourth data.
[0026] In a possible implementation manner of the first aspect, the determining the reference data shape corresponding to each of the data shape intervals includes:
[0027] For each of the data shape intervals, the maximum value of the data shape interval is determined as the reference data shape corresponding to the data shape interval.
[0028] In a possible implementation manner of the first aspect, after inputting the processed data into the target model to obtain output data, the method further includes:
[0029] Performing a de-padding process on the output data to obtain final data, where the de-padding process is used to remove the data in the output data that matches the padding data of the processed data, and the data shape of the final data is the same as the data shape of the result obtained by inputting the first data of the initial data shape into the target model.
[0030] In a second aspect, an embodiment of the present application provides a data processing device, including:
[0031] A data acquisition unit, configured to acquire the first data input into the target model and the initial data shape of the first data;
[0032] A shape acquisition unit, configured to acquire the data shape intervals corresponding to the target model and the reference data shape corresponding to each of the data shape intervals;
[0033] a shape determining unit, configured to determine a reference data shape corresponding to a target interval as a target shape, wherein the target interval is a data shape interval to which the initial data shape belongs;
[0034] a data filling unit, used to fill the first data of the initial data shape with data of the target shape to obtain processed data;
[0035] A data input unit is used to input the processed data into the target model to obtain output data.
[0036] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a data processing method as described in any one of the first aspects above when executing the computer program.
[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and wherein the computer program, when executed by a processor, implements a data processing method as described in any one of the first aspects above.
[0038] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the data processing method described in any one of the above-mentioned first aspects.
[0039] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0041] Figure 1 It is a flowchart of a data processing method provided in an embodiment of the present application;
[0042] Figure 2 It is a schematic diagram of the effect of defilling provided in an embodiment of the present application;
[0043] Figure 3 is a flowchart of a data processing method provided by another embodiment of the present application;
[0044] Figure 4 is a schematic diagram of a data shape interval provided in an embodiment of the present application;
[0045] Figure 5 is a schematic diagram of a data shape interval provided by another embodiment of the present application;
[0046] Figure 6 is a structural block diagram of a data processing device provided in an embodiment of the present application;
[0047] Figure 7 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0049] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0050] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting" depending on the context.
[0051] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0052] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0053] See also Figure 1, is a flow chart of a data processing method provided in an embodiment of the present application. As an example but not a limitation, the method may include the following steps:
[0054] S101, obtaining first data of an input target model and an initial data shape of the first data.
[0055] The tensor shape of the input data of some subnetworks in the neural network model (such as the backbone network in the neural network model) is dynamic, and the tensor shape of the input data of some subnetworks (such as the fully connected network and classification network at the back end of the backbone network in the neural network model) is static. The target model in the embodiment of the present application may refer to the subnetwork in the neural network model whose input data tensor shape is dynamic. Of course, the target model in the embodiment of the present application may also refer to the neural network model as a whole.
[0056] Typically, in different application scenarios, the tensor shape of the input data of the target network varies within a certain data range. The initial data shape in the embodiment of the present application is any value within the data range, and the initial data shape refers to the tensor shape of the first data input to the target model.
[0057] For example, the input data of the target network is an image, and the shape of the data is also expressed as the width and height values of the image. If the width and height of the image vary in the range of 20 to 270 (i.e., the data range), when the target model is required to process a 40×40 image, the initial data shape is 40×40. First, the input data of the initial data shape is statically processed using the following S102-S104 to obtain processed data, and then the processed data is input into the target model.
[0058] For another example: the input data of the target network is text data, and the shape of the data is represented by the values of the rows and columns of the data. If the range of the rows and columns of the text data (i.e., the data range) is 1 to 100; when the target model needs to be used to process 10×100 text data, the initial data shape is 10×100.
[0059] It should be noted that different target networks can be used to process different types of data, such as images, text, and audio, etc. Therefore, the data shapes of the input data of different target networks are also different, and the range of variation of the tensor shape of the input data (i.e., the data range) is also different. The type of input data of the target network is not specifically limited in this application.
[0060] S102, obtaining a data shape interval corresponding to the target model and a reference data shape corresponding to each data shape interval.
[0061] Optionally, the data shape interval may be set by a user according to the range of the data shape of the input data of the target model.
[0062] However, artificial division of data shape intervals is subjective and cannot guarantee processing performance. To solve this problem, a method for dividing data shape intervals is proposed in the embodiment of the present application, and details are described in steps S201-S203.
[0063] S103: Determine the reference data shape corresponding to the target interval as the target shape.
[0064] The target interval is the data shape interval to which the initial data shape belongs.
[0065] Specifically, firstly, the data shape interval to which the initial data shape belongs is determined, and the data shape interval is determined as the target interval; then, the reference data shape corresponding to the target interval is determined as the target shape.
[0066] For example: the preset data shape intervals are 20-40 (the width and height of the image both range from 20-40), 40-80 (the width and height of the image both range from 40-80), 80-120 (the width and height of the image both range from 80-120); the reference data shape corresponding to the data shape interval 20-40 is 40×40, the reference data shape corresponding to the data shape interval 40-80 is 80×80, and the reference data shape corresponding to the data shape interval 80-120 is 120×120. Assuming that the input data is a 30×30 image, that is, the initial data shape is 30×30, the data shape interval to which the shape of the image belongs is 20-40, and the reference data shape corresponding to the data shape interval is 40×40, then the reference data shape corresponding to the initial data shape is 40×40.
[0067] S104, filling the first data of the initial data shape with data of the target shape to obtain processed data.
[0068] Continuing with the example in S103 , if the first data of the initial data shape is a 30×30 image and the target shape is 40×40, the first data of the initial data shape is filled into a 40×40 image.
[0069] Optionally, a preset pixel value may be used for filling, such as a pixel value of 0 or 255. For example, Figure 2 As shown, the edge filling method can be used to fill in the 6×6 image (such as Figure 2 The edge of the image shown in (b) is expanded, the pixel value of the expanded part is 255 (displayed in white), and the size of the expanded image is 10×10 (as shown in Figure 2). One side of the original image may also be expanded, for example, 6 rows and 4 columns of pixels are expanded above the original image, and the size of the filled image is 6×10, and the original image is located below the filled image. In the embodiment of the present application, the filling method is not specifically limited, and it is only necessary to ensure that the rules of the filling process and the subsequent defilling process are consistent.
[0070] S105, inputting the processed data into the target model to obtain output data.
[0071] As described in step S101 , different target models can be used to process different types of input data.
[0072] In an application scenario, when the input data of the target model is a 40×40 image, the image is processed using the above S101-S104. If the target shape corresponding to the image is 80×80, the processed data obtained is an 80×80 image. When the input data of the target model is a 30×30 image, the image is processed using the above S101-S104. If the target shape corresponding to the image is also 80×80, the processed data obtained is also an 80×80 image. It can be seen that after the processing of the above S101-S104 of the present application, input images of different sizes can be converted into processed images of the same size. In this way, images of various sizes within a certain image size range can be filled into several images of fixed sizes, and the target model only needs to process several images of fixed sizes, thereby realizing the staticization of dynamic data.
[0073] In another application scenario, when the input data of the target model is a text of 10 rows and 10 columns, the above S101-S104 is used to process the text. If the target shape corresponding to the text is 100 rows and 100 columns, the processed data obtained is a text of 100 rows and 100 columns. When the input data of the target model is a text of 20 rows and 30 columns, the above S101-S104 is used to process the text. If the target shape corresponding to the text is also 100 rows and 100 columns, the processed data obtained is also a text of 100 rows and 100 columns. It can be seen that after the processing of the above S101-S104 of the present application, the text of different sizes can be converted into text of the same size. In this way, texts of various sizes within a certain text size range can be converted into texts of several fixed sizes. The target model only needs to process texts of several fixed sizes, thereby realizing the staticization of dynamic data.
[0074] In addition, in an embodiment of the present application, the interval division of the input data of the dynamic tensor form is realized through multiple data shape intervals, which increases the fine-grainedness of the static processing and ensures that the calculation results equivalent to the dynamic input data are obtained within the data shape interval; by filling the data of the initial data shape with the data of the reference data shape corresponding to the data shape interval to which it belongs, the extra calculations caused by the introduction of the shape limit value are avoided, the amount of calculations in the static processing process is reduced, and the processing performance is improved.
[0075] The shape of the output data obtained through the above steps may be inconsistent with the shape of the data output by the dynamic shape model, resulting in that after the dynamic shape data is staticized, the same calculation result as the dynamic shape data cannot be achieved.
[0076] In order to solve the above problem, in one embodiment, after S105, the method further includes:
[0077] The output data is de-filled to obtain final data, wherein the de-filling process is used to remove data in the output data that matches the filling data of the processed data, and the data shape of the final data is the same as the data shape of the result obtained by inputting the first data of the initial data shape into the target model.
[0078] The rules of the defilling process are consistent with the rules of the filling process described in the S104 embodiment.
[0079] For example, if the edge filling method is used in S104 to fill a 6×6 image (such as Figure 2 The edge of the image shown in (b) is expanded, and the size of the expanded image is 10×10 (as shown in Figure 2 As shown in (a) in the figure). Correspondingly, when defilling, the pixels at the edge of the output image are removed. Figure 2 As shown, remove Figure 2 The unshaded pixels shown in (a) in FIG. 1 are the pixels output by the model corresponding to the initial data shape, and the unshaded pixels are the output filling data caused by the input filling data. After removing the unshaded pixels in the output data, we get Figure 2 The 6×6 image shown in (b) (i.e., the final data).
[0080] For another example, if the upper portion of a 6×6 image is expanded in S104, 6 rows and 4 columns of pixels are added to the upper portion of the 6×6 image, and the size of the expanded image is 6×10. Accordingly, during the de-filling process, 6 rows and 4 columns of pixels in the upper portion of the output image are removed, and the final data obtained is a 6×6 image.
[0081] See also Figure 3 , is a flow chart of a data processing method provided by another embodiment of the present application. Figure 3As shown, the method in S102 is used to optimize the interval division of the dynamic input shape (i.e., the dynamic tensor shape of the input data) with the static shape backbone neural network (i.e., the target model). After obtaining the dynamic shape network input (i.e., the data of the initial data shape), the pad size (i.e., the size of the filling data) is calculated according to the optimized dynamic input shape interval, and then the data of the initial data shape is pad (i.e., padding processing) is performed according to the method in S104 to obtain the processed data. After the backbone neural network processes the processed data to obtain the output data, the padding data is removed according to the calculated pad size to obtain the dynamic shape network output (i.e., the final data).
[0082] In one embodiment, before step S102, the following steps are also included:
[0083] S201, obtaining a data range of a data shape of input data of a target model.
[0084] As described in S101, in different application scenarios, the tensor shape of the input data of the target network varies within a certain data range, and the data range needs to be divided into intervals. The details are as follows.
[0085] S202: Divide the data range into a plurality of data shape intervals.
[0086] Optionally, an implementation of S202 is:
[0087] I. Sample multiple sampling data from the data range.
[0088] See also Figure 4 , is a schematic diagram of a data shape interval provided in an embodiment of the present application. Figure 4 As shown, it is assumed that the data of the initial data shape is a picture with equal height and width, and the data range of the height and width of the picture is 20 to 270. Sampling this range, multiple sampling data are obtained, such as Figure 4 The solid circles shown in , each solid circle represents a sampling data.
[0089] II. Obtain performance data corresponding to each of the plurality of sampling data, wherein the performance data corresponding to each sampling data represents the performance of the target model when the sampling data is used as the data shape of input data of the target model.
[0090] In practical applications, the input data of each sampled data is input into the compiler of the neural network, and the corresponding performance data of the target model under each sampled data can be obtained. For example, the performance data may include processing time, operating power consumption, and resource consumption.
[0091] Optionally, for ease of calculation, the performance data can be normalized. For example, each performance data is normalized according to the minimum value among the performance data corresponding to multiple sampling data.
[0092] III. Calculate the slope of the performance data between every two adjacent sampling data respectively.
[0093] Exemplarily, the slope of the performance data between the i-th sampling data and the (i - 1)-th sampling data is where ΔS i is the increment value between the i-th sampling data and the (i - 1)-th sampling data, and ΔP i is the increment value between the performance data of the i-th sampling data and the performance data of the (i - 1)-th sampling data.
[0094] IV. Determine the performance mutation data from multiple sampling data according to the slope.
[0095] Optionally, one implementation manner for determining the performance mutation data is:
[0096] If ΔG i+1 ≥ αΔG i , then the i-th sampling data is determined as the performance mutation data;
[0097] If ΔG i+1 < ΔG i , it means that there is no performance mutation data.
[0098] where ΔG i+1 is the second data, that is, the slope of the performance data between the i-th sampling data and the (i + 1)-th sampling data, ΔG i is the third data, that is, the slope of the performance data between the (i - 1)-th sampling data and the i-th sampling data, α is a preset multiple; 1 < i <, i is a positive integer, and M is the number of sampling data sampled from the data range.
[0099] Optionally, if ΔG i+1 ≥ αΔG i , the (i + 1)-th sampling data can also be determined as the performance mutation data, or the average value of the i-th sampling data and the (i + 1)-th sampling data can be determined as the performance mutation data, which is not specifically limited here.
[0100] V. Divide the data range into multiple data shape intervals according to the performance mutation data.
[0101] Optionally, one implementation of dividing the data shape interval according to the performance mutation data is: determining each performance mutation data as a division point; and determining the data range between every two adjacent division points as a data shape interval.
[0102] like Figure 4 As shown, a performance mutation occurs from sample data 120 to sample data 130, and sample data 120 is determined as a performance mutation data. A performance mutation occurs from sample data 220 to sample data 230, and sample data 220 is determined as a performance mutation data. The data range is divided into three data shape intervals, 20 to 120 is a data shape interval, 120 to 220 is a data shape interval, and 220 to 270 is a data shape interval.
[0103] In practical applications, although there is no performance mutation between every two adjacent sampling data in a data shape interval, the performance changes greatly from the starting data to the ending data in the data shape interval.
[0104] In order to further subdivide the data shape interval, another optional implementation method of dividing the data shape interval according to the performance mutation data is:
[0105] make represents the fourth data, that is, the incremental value of the performance data between the sampling data corresponding to the kth and k-1th performance mutation data; let represents the fifth data, that is, the incremental value between the sampling data corresponding to the kth and k-1th performance mutation data. The data shape interval between the k-1th performance mutation data and the kth performance mutation data is divided into N segments, where β is a preset judgment threshold. The γ is a preset increment value.
[0106] Among the N segments divided, the dividing point of each segment is located at Location.
[0107] In order to avoid the impact of excessive selection of fixed reference input data on memory consumption, the number of segments should not be too large.
[0108] See also Figure 5 , is a schematic diagram of a data shape interval provided by another embodiment of the present application. Figure 5 As shown, using the above method Figure 4 The second data shape interval in (i.e., the data shape interval between 120 and 220) is further divided into two data shape intervals. So far, the data range is divided into four data shape intervals.
[0109] Through the above further division of the data shape interval, the granularity of the data shape interval division is improved, which can effectively improve the accuracy of staticization, reduce the amount of calculation of the target model during the data shape staticization processing, and improve the calculation efficiency.
[0110] S203: Determine a reference data shape corresponding to each data shape interval.
[0111] The performance mutation data determined in S202 and the division points obtained by further division constitute the boundary values of each data shape interval within the data range. The reference data shape is determined according to these boundary values.
[0112] Optionally, one implementation method of determining the reference data shape is:
[0113] For each data shape interval, a maximum value of the data shape interval is determined as a reference data shape corresponding to the data shape interval.
[0114] Optionally, another implementation method for determining the reference data shape is:
[0115] For each data shape interval, a preset multiple of the maximum value of the data shape interval is determined as a reference data shape corresponding to the data shape interval.
[0116] By the method in S201-S203, the dynamic data range of the tensor shape of the input data is divided into intervals, and the reference data shape of each data shape interval is determined according to the division point. By this method, the shape of the dynamic input data can be staticized into several fixed data, and the staticization of the dynamic input shape is achieved. By the above method, the additional amount of calculation introduced by the staticization of the shape limit value can be avoided, and the processing efficiency of the staticization is effectively improved. In addition, by dividing the data range of the data shape according to whether the performance data changes suddenly, it can ensure that a more optimized processing performance is obtained in the divided data shape interval, and the processing ability of the target model for dynamic input data is improved.
[0117] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0118] Corresponding to the data processing method described in the above embodiment, Figure 6 This is a structural block diagram of a data processing device provided in an embodiment of the present application. For the sake of convenience of explanation, only the parts related to the embodiment of the present application are shown.
[0119] Reference Figure 6 , the device comprises:
[0120] The data acquisition unit 61 is used to acquire the first data of the input target model and the initial data shape of the first data.
[0121] The shape acquisition unit 62 is used to acquire the data shape interval corresponding to the target model and the reference data shape corresponding to each of the data shape intervals.
[0122] The shape determining unit 63 is configured to determine a reference data shape corresponding to a target interval as a target shape, wherein the target interval is a data shape interval to which the initial data shape belongs.
[0123] The data filling unit 64 is used to fill the first data of the initial data shape with data of the target shape to obtain processed data.
[0124] The data input unit 65 is used to input the processed data into the target model to obtain output data.
[0125] Optionally, the device 6 further comprises:
[0126] The interval division unit 66 is used to obtain the data range of the data shape of the input data of the target model before obtaining the data shape interval corresponding to the target model and the reference data shape corresponding to each data shape interval; divide the data range into a plurality of data shape intervals; and determine the reference data shape corresponding to each data shape interval.
[0127] Optionally, the interval division unit 66 is further configured to:
[0128] Sampling a plurality of sample data from the data range;
[0129] Acquire performance data corresponding to each of the plurality of sample data, wherein the performance data corresponding to each of the sample data represents the performance of the target model when the sample data is used as the data shape of input data of the target model;
[0130] respectively calculating the slope of the performance data between every two adjacent sampling data;
[0131] Determine performance mutation data from the plurality of sampled data according to the slope;
[0132] The data range is divided into a plurality of data shape intervals according to the performance mutation data.
[0133] Optionally, the interval division unit 66 is further configured to:
[0134] If the second data is greater than or equal to a preset multiple of the third data, the i-th sampled data is determined as the performance mutation data, where the second data is the slope of the performance data between the i-th sampled data and the (i + 1)-th sampled data, the third data is the slope of the performance data between the (i - 1)-th sampled data and the i-th sampled data, 1 < i < M, and i is a positive integer, and M is the number of sampled data sampled from the data range.
[0135] Optionally, the interval division unit 66 is further configured to:
[0136] If the ratio of the fourth data to the fifth data is greater than a preset judgment threshold, the data shape interval between the (k - 1)-th performance mutation data and the k-th performance mutation data is divided into N segments, where the fifth data is the increment value between the (k - 1)-th performance mutation data and the k-th performance mutation data, the fourth data is the increment value between the performance data of the (k - 1)-th performance mutation data and the performance data of the k-th performance mutation data, and N is determined by the fourth data.
[0137] Optionally, the interval division unit 66 is further configured to:
[0138] For each of the data shape intervals, the maximum value of the data shape interval is determined as the reference data shape corresponding to the data shape interval.
[0139] Optionally, the apparatus 6 further includes:
[0140] A shape restoration unit 67, configured to perform a de-padding process on the output data after inputting the processed data into the target model to obtain the final data, where the de-padding process is used to remove the data in the output data that matches the padding data of the processed data, and the data shape of the final data is the same as the data shape of the result obtained by inputting the first data of the initial data shape into the target model.
[0141] It should be noted that for the information interaction, execution process, etc. between the above-mentioned devices / units, since they are based on the same concept as the method embodiment of the present application, their specific functions and the technical effects brought, please refer to the method embodiment part for details, and will not be elaborated here.
[0142] In addition, Figure 6 The data processing apparatus shown may be a software unit, a hardware unit, or a unit combining software and hardware built into an existing terminal device, may also be integrated into the terminal device as an independent attachment, or may exist as an independent terminal device.
[0143] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0144] Figure 7 Schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Figure 7 As shown, the terminal device 7 of this embodiment includes: at least one processor 70 ( Figure 7 Only one is shown in the figure) a processor, a memory 71, and a computer program 72 stored in the memory 71 and executable on the at least one processor 70, and when the processor 70 executes the computer program 72, the steps in any of the above-mentioned data processing method embodiments are implemented.
[0145] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 7 It is only an example of the terminal device 7 and does not constitute a limitation on the terminal device 7. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0146] The processor 70 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0147] In some embodiments, the memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or memory of the terminal device 7. In other embodiments, the memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used to store an operating system, an application program, a boot loader, data, and other programs, such as the program code of the computer program. The memory 71 may also be used to temporarily store data that has been output or is to be output.
[0148] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0149] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0150] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0151] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0152] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0153] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data processing method, characterized in that: Including: Obtain the first data of the input target model and the initial data shape of the first data; Obtain the data shape intervals corresponding to the target model and the reference data shapes corresponding to each of the data shape intervals; Determine the reference data shape corresponding to the target interval as the target shape, where the target interval is the data shape interval to which the initial data shape belongs; Pad the first data with the initial data shape to the data with the target shape to obtain processed data; Input the processed data into the target model to obtain output data.
2. The data processing method according to claim 1, characterized in that: Before obtaining the data shape intervals corresponding to the target model and the reference data shapes corresponding to each of the data shape intervals, it further includes: Obtain the data range of the data shape of the input data of the target model; Divide the data range into multiple data shape intervals; Determine the reference data shape corresponding to each of the data shape intervals.
3. The data processing method according to claim 2, characterized in that: The dividing the data range into multiple data shape intervals includes: Sample multiple sampling data from the data range; Obtain the performance data corresponding to each of the multiple sampling data, where the performance data corresponding to each sampling data represents the performance of the target model when the sampling data is the data shape of the input data of the target model; Calculate the slopes of the performance data between every two adjacent sampling data respectively; Determine performance mutation data from the multiple sampling data according to the slopes; Divide the data range into multiple data shape intervals according to the performance mutation data.
4. The data processing method according to claim 3, characterized in that: The determining performance mutation data from the multiple sampling data according to the slopes includes: If the second data is greater than or equal to a preset multiple of the third data, then determine the i-th sampling data as the performance mutation data, where the second data is the slope of the performance data between the i-th sampling data and the (i + 1)-th sampling data, the third data is the slope of the performance data between the (i - 1)-th sampling data and the i-th sampling data, 1 < i < M, and i is a positive integer, and M is the number of sampling data sampled from the data range.
5. The data processing method according to claim 3, characterized in that: The dividing the data range into multiple data shape intervals according to the performance mutation data includes: If the ratio of the fourth data and the fifth data is greater than a preset judgment threshold, then divide the data shape interval between the (k - 1)-th performance mutation data and the k-th performance mutation data into N segments, where the fifth data is the increment value between the (k - 1)-th performance mutation data and the k-th performance mutation data, the fourth data is the increment value between the performance data of the (k - 1)-th performance mutation data and the performance data of the k-th performance mutation data, and N is determined by the fourth data.
6. The data processing method according to claim 2, characterized in that: The determining the reference data shape corresponding to each of the data shape intervals includes: For each of the data shape intervals, determine the maximum value of the data shape interval as the reference data shape corresponding to the data shape interval.
7. The data processing method according to claim 1, characterized in that: After inputting the processed data into the target model to obtain output data, the method further includes: De-filling is performed on the output data to obtain final data, wherein the de-filling is used to remove data in the output data that matches the filling data of the processed data, and the data shape of the final data is the same as the data shape of the result obtained by inputting the first data of the initial data shape into the target model.
8. A data processing device, characterized in that: include: A data acquisition unit, used for acquiring first data of an input target model and an initial data shape of the first data; A shape acquisition unit, used for acquiring a data shape interval corresponding to the target model and a reference data shape corresponding to each of the data shape intervals; a shape determining unit, configured to determine a reference data shape corresponding to a target interval as a target shape, wherein the target interval is a data shape interval to which the initial data shape belongs; A data filling unit, used for filling the first data of the initial data shape with data of the target shape to obtain processed data; A data input unit is used to input the processed data into the target model to obtain output data.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
