Data volume determination method and device, equipment and storage medium

By determining the minimum reference dimension shape that is greater than or equal to the input dimension shape to estimate the output data volume, the problems of memory waste and poor scalability in the prior art are solved, and a memory configuration that is closer to the actual data volume is achieved, thus improving performance.

CN121503533APending Publication Date: 2026-02-10TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411097024.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

In existing technologies, estimating the output data volume based on the shape of the maximum input dimension leads to wasted memory space, and existing methods have poor scalability or require a large amount of work.

Method used

By obtaining the input dimension shape of the input data, a minimum reference dimension shape that is greater than or equal to the input dimension shape is determined, and the output data volume is estimated based on this reference dimension shape to allocate memory space.

Benefits of technology

Reduce memory waste, improve scalability, reduce redundant copies, reduce inference latency, and improve throughput performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121503533A_ABST
    Figure CN121503533A_ABST
Patent Text Reader

Abstract

The invention discloses a data volume determination method and device, equipment and a storage medium, and relates to the technical field of artificial intelligence. The method comprises: obtaining an input dimension shape of input data, the input data being data processed by a neural network unit, and the input data comprising data of N dimensions; according to the input dimension shape, a first reference dimension shape is determined from the at least one reference dimension shape, the first reference dimension shape is a minimum reference dimension shape larger than or equal to the input dimension shape in the at least one reference dimension shape, and determination of the at least one reference dimension shape is related to at least one variable dimension; before the input data is processed through the neural network unit to obtain the output data, the estimated data size of the output data is determined based on the output dimension shape corresponding to the first reference dimension shape, and the estimated data size of the output data is used for determining the memory space configured for the output data. The method can reduce memory waste.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of AI (Artificial Intelligence), in particular to a data quantity determination method and device, equipment and a storage medium. BACKGROUND

[0002] When input data is processed by a neural network unit, memory space needs to be configured in advance for output data to store the output data. When the dimension value of a dimension of the input data is variable (for example, there is a dimension of batch size in the input data, and the dimension value of the dimension is variable, that is, the batch size is variable), the data quantity of the output data needs to be estimated in advance to configure the memory space for the output data. When the dimension value of the dimension is variable, the dimension can also be referred to as a variable dimension.

[0003] In related technologies, the dimension value of the variable dimension in the input data is set to the maximum value (for example, the batch size in the input data is set to the maximum value). The input data with the maximum dimension value of the variable dimension (that is, the input data with the maximum input dimension shape) is processed by a model to obtain output data (that is, output data with the maximum output dimension shape), and the data quantity of the output data is used to configure the memory space.

[0004] However, the estimated data quantity of the output data determined based on the input data with the maximum input dimension shape in the above related technologies is quite different from the actual data quantity of the output data. Therefore, it is easy to cause waste of the configured memory space. SUMMARY

[0005] The embodiments of the present application provide a data quantity determination method, device, equipment and storage medium, and the technical solutions provided by the present application include the following aspects.

[0006] According to an aspect of the embodiments of the present application, a data quantity determination method is provided, which includes the following steps.

[0007] An input dimension shape of input data is obtained, the input data is data processed by a neural network unit, the input data includes data of N dimensions, the input dimension shape includes dimension values corresponding to the N dimensions respectively, and there is at least one variable dimension in the N dimensions, and N is a positive integer;

[0008] A first reference dimension shape is determined from at least one reference dimension shape according to the input dimension shape, the first reference dimension shape is the smallest reference dimension shape greater than or equal to the input dimension shape in the at least one reference dimension shape, and the at least one reference dimension shape is related to the at least one variable dimension;

[0009] Before output data is obtained by processing the input data by the neural network unit, a predicted data amount of the output data is determined based on an output dimension shape corresponding to the first reference dimension shape, the predicted data amount of the output data being used to determine a memory space configured for the output data.

[0010] According to an aspect of an embodiment of the present application, a data amount determination apparatus is provided, and the apparatus comprises the following modules.

[0011] a shape obtaining module, configured to obtain an input dimension shape of input data, the input data being data processed by a neural network unit, the input data comprising data of N dimensions, the input dimension shape comprising dimension values corresponding to the N dimensions respectively, there being at least one variable dimension among the N dimensions, N being a positive integer;

[0012] a shape determining module, configured to determine a first reference dimension shape from at least one reference dimension shape according to the input dimension shape, the first reference dimension shape being a minimum reference dimension shape greater than or equal to the input dimension shape among the at least one reference dimension shape, the at least one reference dimension shape being determined in relation to the at least one variable dimension;

[0013] a data amount predicting module, configured to determine a predicted data amount of output data before the output data is obtained by processing the input data by the neural network unit, based on an output dimension shape corresponding to the first reference dimension shape, the predicted data amount of the output data being used to determine a memory space configured for the output data.

[0014] According to an aspect of an embodiment of the present application, a computer device is provided, the computer device comprising a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above data amount determination method.

[0015] According to an aspect of an embodiment of the present application, a computer readable storage medium is provided, the computer readable storage medium storing a computer program, the computer program being loaded and executed by a processor to implement the above data amount determination method.

[0016] According to an aspect of an embodiment of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being loaded and executed by a processor to implement the above data amount determination method.

[0017] The technical solutions provided by the embodiments of the present application can bring the following beneficial effects.

[0018] In view of the problem that the estimated data amount of output data directly based on the maximum dimension value of the variable dimension in the related art is prone to cause memory waste, the present application determines a minimum reference dimension shape (i.e. a first reference dimension shape) greater than or equal to the input dimension shape from at least one reference dimension shape based on the variable dimension in the input dimension shape. The estimated data amount of output data is obtained through the output dimension shape of the first reference dimension shape. Compared with blindly determining the estimated data amount directly according to the maximum dimension value, the present application finds the minimum reference dimension shape greater than or equal to the input dimension shape from a plurality of reference dimension shapes to further determine the estimated data amount. Since the first reference dimension shape is not only a reference dimension shape greater than or equal to the input dimension shape, but also the minimum reference dimension shape, the estimated data amount can be more consistent with the actual data amount of output data, and the memory waste can be reduced. BRIEF DESCRIPTION OF DRAWINGS

[0019] Figure 1 is a schematic diagram of a computer system provided by an embodiment of the present application;

[0020] Figure 2 is a schematic diagram of a data amount determination method provided by an embodiment of the present application;

[0021] Figure 3 is a flowchart of a data amount determination method provided by an embodiment of the present application;

[0022] Figure 4 is a flowchart of a data amount determination method provided by another embodiment of the present application;

[0023] Figure 5 is a flowchart of a data amount determination method provided by another embodiment of the present application;

[0024] Figure 6 is a schematic diagram of at least one grid point provided by an embodiment of the present application;

[0025] Figure 7 is a flowchart of a data amount determination method provided by another embodiment of the present application;

[0026] Figure 8 is a flowchart of a data amount determination method provided by another embodiment of the present application;

[0027] Figure 9 is a flowchart of a data amount determination method provided by another embodiment of the present application;

[0028] Figure 10 is a block diagram of a data amount determination apparatus provided by an embodiment of the present application;

[0029] Figure 11is a block diagram of a data amount determination apparatus provided by another embodiment of the present application;

[0030] Figure 12 is a structural block diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0031] For the purpose, technical solutions and advantages of the present application to be clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.

[0032] Reference is made to Figure 1 which shows a schematic diagram of a computer system provided by an embodiment of the present application. The computer system can include a terminal device 10 and a server 20.

[0033] The terminal device 10 includes but is not limited to a mobile phone, a tablet computer, a smart voice interactive device, a game console, a wearable device, a multimedia playing device, a PC (Personal Computer), a vehicle-mounted terminal, a smart home appliance, etc. A client of a target application program can be installed in the terminal device 10. Optionally, the target application program can be an application program that needs to be downloaded and installed, or an application program that can be used immediately after being clicked, which is not limited in the embodiments of the present application.

[0034] In the embodiments of the present application, the target application program can be an application program that provides a data amount determination or estimation function. Exemplarily, the target application program can be a data estimation application program, a social application program, a shopping application program, a game application program, etc., which is not limited in the present application. Taking the target application program as a data estimation application program as an example, for a neural network unit, it provides a service or function of estimating the data amount of the output data based on the input data of the neural network unit. Exemplarily, after the data estimation application program determines the estimated data amount of the output data, a memory space is configured in advance for the output data of the neural network unit based on the estimated data amount of the output data, to store the output data obtained by the neural network unit processing the input data.

[0035] The server 20 is configured to provide a background service for the client of the target application program in the terminal device 10. For example, the server 20 can be a stand-alone physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN (Content Delivery Network), and big data and artificial intelligence platform, but is not limited thereto.

[0036] The terminal device 10 and the server 20 can communicate with each other through a network. The network can be a wired network or a wireless network.

[0037] The execution subject of each step of the method provided in the embodiments of the present application can be a computer device, which refers to an electronic device with data calculation, processing and storage capabilities. The computer device can be a terminal device 10 in the system 100 or a server 20. Figure 1 The execution subject of each step of the method provided in the embodiments of the present application can be a computer device, which refers to an electronic device with data calculation, processing and storage capabilities. The computer device can be a terminal device 10 in the system 100 or a server 20.

[0038] Before introducing the specific schemes of the present application, the related background art is exemplarily described.

[0039] The first one is to directly determine the maximum input dimension shape according to the maximum dimension value of the variable dimension, as described in the background art. Further, the maximum output dimension shape of the neural network unit is determined based on the maximum input dimension shape. The maximum output dimension shape is used to apply the display memory. In this first way, if the display memory is applied according to the maximum output dimension shape, since the input data size often presents a normal distribution, about 50% of the display memory will be wasted on average, and a large amount of redundant copying will be generated when copying according to the maximum output space, thereby increasing the inference delay and reducing the throughput.

[0040] The second one is to obtain the input and output mapping relationship of the entire neural network unit by implementing the input and output dimension shape inference logic of each operator. In this second way, if the shape inference of each operator is implemented, the following problems will occur: (1) the workload is huge, and each operator needs to be implemented separately; (2) the expansibility is poor, and when a new operator appears, the input and output mapping logic of the new operator must be additionally implemented.

[0041] Compared with the first and second ways described above, the present application proposes an output dimension shape approximate inference algorithm which is independent of the operator implementation, has low workload, high expansibility, low memory waste and low redundant copying.

[0042] Considering that the input dimension shape and the output dimension shape of most models satisfy a non-strict monotonic increasing relationship (i.e., the output size will increase or remain unchanged when the input size increases), the actual output dimension shape corresponding to a large input can be used as an approximate actual output dimension shape corresponding to a small input. That is, the actual output dimension shape of the grid point output data corresponding to the grid point input data constructed by using the reference dimension shape corresponding to the first grid point is used as an approximate actual output dimension shape of the output data corresponding to the input data. Based on the above premise, some input and output size mapping relationships are recorded at a fixed interval in advance, when the user has an actual input, the closest grid point (i.e., the first grid point) greater than or equal to the user input is found in the record, and then the output size corresponding to the grid point is used as the size of the output in this inference, thereby "guessing" an output size that is closest and redundant.

[0043] Please refer to Figure 2 which shows a schematic diagram of the data amount determination method provided by an embodiment of the present application.

[0044] For a neural network unit, the dimension of the input data is generally fixed. At the same time, the change range of the dimension value of the variable dimension in the input dimension is also generally determined. Of course, when the dimension value of the input dimension of the neural network unit is variable, the input of the neural network unit is also considered as dynamic input, and the corresponding output is dynamic output.

[0045] For example, the input dimension shape of the input data of the neural network unit is obtained. For example, the dimension value of each dimension of the input data is (3, 2, 5), that is, the input data is a matrix with a dimension of 3*2*5.

[0046] For example, among the three dimensions, the dimension where "3" is located is the variable dimension 200, and the dimensions where "2" and "4" are located are fixed dimensions. For example, the maximum dimension value of the variable dimension 200 where "3" is located is 10, and the minimum dimension value is 1. For example, the input dimension shape of the input data can also be (4, 2, 5), (7, 2, 5), etc. Regardless of the change of the input dimension shape of the input data, the dimension value of the fixed dimension always does not change, and the dimension value of the variable dimension is between the maximum dimension value and the minimum dimension value.

[0047] For example, at least one grid point is determined according to the maximum dimension value and the minimum dimension value of the variable dimension. For example, Figure 2 For example, the points corresponding to "1, 4, 7, 10" are considered as at least one grid point. For example, based on the maximum dimension value 10, the minimum dimension value 1, and the sampling interval 3, at least one grid point is determined.

[0048] For example, the grid point where "4" is located is determined as the first grid point, and the dimension value 3 of the input dimension shape in the variable dimension 200 is less than 4 and greater than 1.

[0049] For example, the input data of the first grid point is constructed with (4, 2, 5) as the input dimension shape. The output dimension shape a of the first grid point output data obtained by processing the first grid point input data by the neural network unit. The estimated data amount of the input data is determined by the data amount indicated by the output dimension shape a.

[0050] For example, the reference dimension shape and the output dimension shape corresponding to each grid point are recorded in advance. After the first grid point is determined, the output dimension shape a corresponding to the first grid point is directly obtained to configure the memory space for the input data in advance.

[0051] Exemplarily, based on the reference dimension shape (4, 2, 5) corresponding to the first grid point, the memory space of the output data configured for the input dimension shape (3, 2, 5) of the input data is not only able to meet the demand of the output data corresponding to (3, 2, 5) for memory, but also to reduce the memory waste as much as possible, compared with the memory space configured for the input dimension shape (3, 2, 5) of the input data based on the maximum input dimension shape (10, 2, 5).

[0052] In summary, the technical scheme provided by the embodiment of the present application estimates the output size before the neural network unit infers the input data, guarantees that the estimated result is greater than or equal to the actual output size, and the difference between the estimated result and the actual output size is small. Thus, the memory waste is reduced as much as possible.

[0053] Please refer to Figure 3 Fig. 1 shows a flowchart of a data amount determination method provided by an embodiment of the present application. The execution subject of the method can be the terminal device 10 introduced above, such as the client of the target application program mentioned in the above embodiment, or the server 20 introduced above. In the following method embodiment, for the convenience of description, only the execution subject of each step is described as a “computer device”. The method can include at least one of the following steps (310-330):

[0054] Step 310: Obtain an input dimension shape of input data. The input data is data processed by a neural network unit, and the input data includes N dimensions of data. The input dimension shape includes dimension values corresponding to N dimensions respectively. There is at least one variable dimension in the N dimensions, and N is a positive integer.

[0055] In some embodiments, the input data refers to data input into the neural network unit. Exemplarily, the input data is processed by the neural network unit to obtain output data.

[0056] In some embodiments, the neural network unit includes at least one neural network layer.

[0057] Exemplarily, the neural network unit is implemented as a complete neural network model. Exemplarily, the neural network model includes at least one neural network layer. Exemplarily, the neural network unit includes at least one complete neural network model, i.e., the neural network unit can be composed of multiple neural network models. Exemplarily, the complete neural network model includes at least one of a graph neural network model, a convolutional neural network model, a recurrent neural network model, and a generative adversarial network model.

[0058] Exemplarily, the neural network unit is implemented as an incomplete neural network model, but also has an input and an output. Exemplarily, the incomplete neural network model includes at least one neural network layer. Exemplarily, the neural network layer includes at least one of a convolutional layer, a linear layer, a pooling layer, a hidden layer, etc.

[0059] In some embodiments, the neural network unit is a pre-trained model or a non-pre-trained model.

[0060] In some embodiments, the input data is a plurality of medical data, the neural network unit is a disease diagnosis model, and the output data is a plurality of disease diagnosis results.

[0061] In some embodiments, the input data is a plurality of historical population data of a plurality of regions, the neural network unit is a population prediction model, and the output data is a plurality of expected population data of the plurality of regions.

[0062] In some embodiments, the input data is a plurality of pictures to be repaired, the neural network unit is an image repair model, and the output data is a plurality of repaired pictures.

[0063] In some embodiments, the input data includes N dimensions of data, the input dimension shape includes N dimension values corresponding to N dimensions respectively, and there is at least one variable dimension among the N dimensions. The variable dimension refers to a dimension whose dimension value is variable for different input data.

[0064] In some embodiments, the variable dimension refers to a dimension whose dimension value changes. Exemplarily, the variable dimension includes but is not limited to at least one of the following: batch size, data length, and number of data of a single sample.

[0065] Exemplarily, the batch size can be considered as the amount of data that the neural network unit can process in a batch. For example, if the neural network unit can process 500 pieces of data in a batch, the batch size is 500. Exemplarily, taking the neural network unit as a disease diagnosis model as an example, the batch size indicates the medical data that the disease diagnosis model can process at a time. Exemplarily, taking the neural network unit as a population prediction model as an example, the batch size indicates the number of regions corresponding to the historical population data that the population prediction model can predict at a time. Exemplarily, taking the neural network unit as an image repair model as an example, the batch size indicates the number of pictures to be repaired that the image repair model can repair at a time.

[0066] Exemplarily, the data length can be considered as the length of the input data. For example, the neural network unit can allow input data of different lengths, but the input data of different lengths correspond to different input dimension shapes. Exemplarily, taking the neural network unit as a disease diagnosis model, the data length of the input data indicates the length of the medical data processed by the disease diagnosis model. Exemplarily, taking the neural network unit as a population prediction model, the data length of the input data indicates the length of the historical population data predicted by the population prediction model. Exemplarily, taking the neural network unit as an image repair model, the batch size indicates the size of the picture to be repaired repaired by the image repair model.

[0067] In some embodiments, the input data includes N dimensions of data. In some embodiments, the input dimension shape includes N dimensions corresponding to dimension values respectively, and there are at least one variable dimension in the N dimensions. The variable dimension refers to a dimension whose dimension value is variable for different input data.

[0068] In some embodiments, there are at least one fixed dimension in the N dimensions. The fixed dimension refers to a dimension whose dimension value is constant for different input data.

[0069] In some embodiments, as shown in the figure, taking a matrix of one dimension (3, 2, 5) as an example, the (3, 2, 5) is the input dimension shape of the input data. Among them, the dimension value of the dimension of 3 is variable, so the dimension of 3 is a variable dimension, and the dimension values of the dimensions of 2 and 5 are fixed, so the dimensions of 2 and 5 are fixed dimensions. Figure 2

[0070] Step 320, determining a first reference dimension shape from at least one reference dimension shape according to the input dimension shape, the first reference dimension shape being the smallest reference dimension shape greater than or equal to the input dimension shape in the at least one reference dimension shape, and the determination of the at least one reference dimension shape being related to the at least one variable dimension.

[0071] In some embodiments, the reference dimension shape is a preset dimension shape. Exemplarily, the reference dimension shape includes N dimensions corresponding to dimension values respectively.

[0072] In some embodiments, the first reference dimension shape is the smallest reference dimension shape greater than or equal to the input dimension shape in the at least one reference dimension shape. Exemplarily, for the N dimensions corresponding to the dimension values respectively included in the first reference dimension shape, the dimension values are not less than the N dimensions corresponding to the dimension values respectively included in the input dimension shape.

[0073] ​In some embodiments, the first reference dimension shape is at least one reference dimension shape having a minimum reference dimension shape greater than or equal to the input dimension shape. Illustratively, for N dimensions included in the first reference dimension shape, each corresponding to a dimension value, each is not less than a dimension value corresponding to the N dimension included in the input dimension shape.

[0074] In some embodiments, N dimensions include M variable dimensions and N-M fixed dimensions. Illustratively, a variable dimension refers to a dimension whose dimension value varies for different input data. A fixed dimension refers to a dimension whose dimension value remains unchanged for different input data.

[0075] In some embodiments, for M variable dimensions included in the first reference dimension shape, each corresponding to a dimension value, each is greater than or equal to a dimension value corresponding to the M variable dimension included in the input dimension shape. In some embodiments, for N-M fixed dimensions included in the first reference dimension shape, each corresponding to a dimension value, each is equal to a dimension value corresponding to the N-M fixed dimension included in the input dimension shape.

[0076] In some embodiments, the following is explained for the size comparison between dimension shapes. Illustratively, in comparing a reference dimension shape a and an input dimension shape b, if there is at least one dimension in the reference dimension shape a whose dimension value is greater than a dimension value of the dimension in the input dimension shape b, and dimension values of other dimensions in the reference dimension shape a are not less than dimension values of other dimensions in the input dimension shape b, then the reference dimension shape a can be considered greater than the input dimension shape b. Illustratively, a reference dimension shape (2, 3, 3) is greater than an input dimension shape (2, 2, 3).

[0077] The following describes several ways to determine the first reference dimension shape.

[0078] In a case where N is 1 and the dimension (referred to as a single dimension) is a variable dimension, a variable dimension array preset for the variable dimension in advance is obtained. The variable dimension array includes L dimension values, each corresponding to a reference dimension shape, and a reference dimension shape includes one dimension value. L is a positive integer.

[0079] Illustratively, each dimension value in the variable dimension array is traversed to determine at least one dimension value greater than or equal to a dimension value of the dimension in the input dimension shape. A dimension value with the smallest value is determined from the at least one dimension value, and a reference dimension shape indicated by the dimension value is determined as the first reference dimension shape.

[0080] Method 2: When the number of variable dimensions is M, obtain the variable dimension arrays pre-set for each of the M variable dimensions. Each variable dimension array includes multiple dimension values, which belong to the dimension value range of that variable dimension, that is, less than or equal to the maximum dimension value of that dimension, and greater than or equal to the minimum dimension value of that dimension. M is a positive integer less than or equal to N.

[0081] For example, for the i-th variable dimension among M variable dimensions, determine the smallest dimension value from the array of i-th variable dimensions that is greater than or equal to the dimension value of the i-th variable dimension in the input dimension shape. For example, iterate through the dimension values ​​corresponding to the M variable dimensions to obtain the M smallest dimension values ​​determined from the array of M variable dimensions. These M smallest dimension values ​​are each greater than or equal to the dimension values ​​of the M variable dimensions in the input dimension shape. i is a positive integer less than or equal to M.

[0082] For example, each reference dimension shape includes one dimension value from each variable dimension array, as well as NM fixed dimension values.

[0083] For example, the M minimum dimension values ​​and the NM fixed dimension values ​​are determined as the first reference dimension shape.

[0084] Method 3: Obtain a pre-set array of variable dimensions for each of the N dimensions, with each array containing multiple dimension values.

[0085] For example, for the g-th dimension out of N dimensions, the smallest dimension value that is greater than or equal to the dimension value of the g-th dimension in the input dimension shape is determined from the g-th variable dimension array. For example, the dimension values ​​corresponding to the N dimensions are traversed to obtain the N smallest dimension values ​​determined from the N variable dimension arrays. These N smallest dimension values ​​are each greater than or equal to the dimension values ​​corresponding to the N dimensions in the input dimension shape. g is a positive integer less than or equal to N.

[0086] For example, each reference dimension shape includes one dimension value from each variable dimension array.

[0087] For example, the N smallest dimension values ​​are determined as the first reference dimension shape.

[0088] Method 4: Based on the dimension values ​​of the M variable dimensions included in the input dimension shape, determine a first grid point from at least one grid point. The at least one grid point is determined by sampling from the dimension space formed by the dimension value intervals corresponding to the M variable dimensions. The dimension value interval is the range of variation of the dimension values ​​of the variable dimensions. Different grid points in the at least one grid point indicate different dimension values ​​corresponding to the M variable dimensions. From the reference dimension shapes corresponding to the at least one grid point, determine the reference dimension shape corresponding to the first grid point as the first reference dimension shape. The reference dimension shape corresponding to the grid point includes the different dimension values ​​indicated by the grid point in the M variable dimensions, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape.

[0089] In some embodiments, at least one grid point is determined based on at least one variable dimension. In some embodiments, the at least one grid point is determined in advance.

[0090] In some embodiments, the computer device pre-configures a grid point library for different neural network units. The grid point library records at least one grid point corresponding to the neural network unit, the reference dimension shape corresponding to the grid point, the output dimension shape corresponding to the reference dimension shape, and so on.

[0091] In some embodiments, different neural network units correspond to different inputs and outputs. Therefore, the variable dimension in the input data is different for different neural network units. Since at least one grid point is determined based on the variable dimension, this at least one grid point also changes when the variable dimension changes.

[0092] In some embodiments, at least one grid point is determined based on the maximum and minimum dimension values ​​corresponding to at least one variable dimension. For example, the range of dimension value variation of the variable dimension is sampled through the at least one grid point, that is, the dimension value of any grid point in the variable dimension is between the maximum and minimum dimension values ​​of the variable dimension (inclusive).

[0093] For example, when the number of variable dimensions is 1, the dimensional interval between the maximum and minimum dimensional values ​​of the variable dimension is sampled on the one-dimensional axis where the variable dimension is located to obtain multiple grid points.

[0094] For example, when the number of variable dimensions is 2, in a two-dimensional plane with one variable dimension as the x-axis and the other variable dimension as the y-axis, the region formed by the dimensional interval between the maximum and minimum dimensions corresponding to the two variable dimensions is sampled to obtain multiple grid points.

[0095] For example, when the number of variable dimensions is 3, in a three-dimensional space with one variable dimension as the x-axis, another variable dimension as the y-axis, and yet another variable dimension as the y-axis, the space is sampled from the dimensional intervals between the maximum and minimum dimensions corresponding to the three variable dimensions to obtain multiple grid points.

[0096] In the above embodiments, the grid point determination method is explained using only 1, 2, and 3 variable dimensions as examples. When the number of variable dimensions is greater than 3, the above method is used as a reference and will not be repeated. Of course, the specific grid point determination method can also be found in the following embodiments.

[0097] In some embodiments, different grid points correspond to different reference dimension shapes. In some embodiments, the reference dimension shape corresponding to a grid point can also be considered as an input dimension shape, which has a corresponding output dimension shape. The interval in which the reference dimension shapes of these grid points lie is the interval formed by the minimum input dimension shape to the maximum input dimension shape.

[0098] For example, the maximum reference dimension shape refers to the reference dimension shape when all the dimension values ​​of the variable dimensions are the maximum dimension values ​​of that variable dimension.

[0099] For example, the minimum reference dimension shape refers to the reference dimension shape when all the dimension values ​​of the variable dimensions are the minimum dimension values ​​of that variable dimension.

[0100] For example, if the reference dimension shape corresponding to the first grid point is greater than or equal to the input dimension shape of the input data, it can be understood that at least one dimension in the reference dimension shape corresponding to the first grid point has a dimension value greater than or equal to the dimension value of that dimension in the input dimension shape of the input data, and the dimension values ​​of the other dimensions in the reference dimension shape corresponding to the first grid point, excluding the at least one dimension, are not less than the dimension values ​​of the other dimensions in the input dimension shape of the input data.

[0101] In some embodiments, grid points can only represent variable-dimensional values, and not fixed-dimensional values. In other embodiments, grid points can represent both variable-dimensional and fixed-dimensional values.

[0102] In some embodiments, such as Figure 2 As shown in the first grid point 210, grid point 4 can only represent the dimension value of the variable dimension, but cannot represent the dimension value of the fixed dimension where 2 and 5 are located.

[0103] In some embodiments, regardless of whether a grid point can only represent the dimension value of a variable dimension, the reference dimension shape corresponding to the grid point includes the dimension values ​​of N dimensions, that is, it includes not only the dimension values ​​of a variable dimension, but also the dimension values ​​of a fixed dimension.

[0104] In some embodiments, the reference dimension shape corresponding to the grid point and the input dimension shape of the input data have the same number of dimensions.

[0105] In some embodiments, the first grid point is the grid point among at least one grid point whose corresponding reference dimension shape is greater than or equal to the smallest reference dimension shape among the input dimension shapes of the input data. For example, still using... Figure 2 For example, in at least one grid point, the reference dimension shape corresponding to grid point 4 (first grid point 210) is (4, 2, 5), the reference dimension shape corresponding to grid point 7 is (7, 2, 5), and the reference dimension shape corresponding to grid point 10 is (10, 2, 5). Exemplarily, all three reference dimension shapes are greater than or equal to the input dimension shape of the input data (3, 2, 5). Therefore, it is necessary to determine grid point 4, which has the smallest reference dimension shape (i.e., (4, 2, 5)), from the grid points whose reference dimension shape is greater than or equal to the input dimension shape of the input data, as the first grid point.

[0106] In some embodiments, it is easy to see that the first grid point is a grid point among at least one grid point whose reference dimension shape is greater than or equal to the input dimension shape of the input data, and is the grid point whose reference dimension shape is closest to the input dimension shape of the input data.

[0107] Step 330: Before processing the input data through the neural network unit to obtain the output data, the estimated amount of output data is determined based on the output dimension shape corresponding to the first reference dimension shape. The estimated amount of output data is used to determine the memory space configured for the output data.

[0108] In some embodiments, when the neural network model is actually used to process (or infer) the input data, the output dimension shape corresponding to the reference dimension shape has already been determined. For a specific method of determining the output dimension shape, please refer to the following embodiments, which are merely illustrative examples.

[0109] For example, reference input data is constructed based on the dimension values ​​in each dimension of the first reference dimension shape. The dimension values ​​of this reference input data in each dimension are equal to the dimension values ​​in each dimension of the first reference dimension shape. For example, a neural network unit processes the reference input data to obtain reference output data. For example, the dimension values ​​in each dimension of the reference output data are determined as the output dimension shape corresponding to the first reference dimension shape. For example, if the reference output data is a 5*5*5 matrix, then the output dimension shape corresponding to the first reference dimension shape is (5, 5, 5).

[0110] In some embodiments, before processing the input data through the neural network unit to obtain the output data, the estimated amount of output data is determined based on the output dimension shape of the first grid point, and the estimated amount of output data is used to determine the memory space configured for the output data.

[0111] In some embodiments, when the neural network model is actually used to process (or infer) the input data, the output dimension shape of the first grid point has already been determined. For a specific method of determining the output dimension shape of the first grid point, please refer to the following embodiments, which are merely illustrative examples.

[0112] In some embodiments, the output dimension shape of the first grid point includes the dimension values ​​of the first grid point output data in each dimension obtained by the neural network unit processing the first grid point input data, and the first grid point input data is data constructed based on the reference dimension shape corresponding to the first grid point.

[0113] For example, the reference dimension shape corresponding to the first grid point constructs the input data for the first grid point. For example, by setting each element of the matrix with this input dimension shape to a first value, the input data for the first grid point consists of a matrix where each element is the first value and the input dimension shape is the reference dimension shape corresponding to the first grid point. For example, this first value can be a pre-set value or a random number.

[0114] For example, a neural network unit processes the input data of the first grid point to obtain the output data of the first grid point. For example, the dimension values ​​of the output data of the first grid point in each dimension are determined as the output dimension shape corresponding to the first grid point. For example, if the output data of the first grid point is a 5*5*5 matrix, then the output dimension shape corresponding to the first grid point is (5, 5, 5).

[0115] In some embodiments, the output dimension shape of the first grid point is used as the estimated output dimension shape of the output data, and the estimated data volume of the output data is determined based on the estimated output dimension shape of the output data.

[0116] In some embodiments, the estimated amount of output data is determined based on the product of the dimension values ​​of each dimension included in the output dimension shape of the first grid point. In some embodiments, taking the output dimension shape corresponding to the first grid point as (5, 5, 5) as an example, the estimated amount of output data is determined based on the product of the dimension values ​​of each dimension included in the output dimension shape of the first grid point (5*5*5=125).

[0117] In some embodiments, the product of the dimension values ​​of each dimension included in the output dimension shape of the first grid point represents the number of predicted elements in the output data. Exemplarily, the estimated data volume of the output data is then determined based on the amount of data occupied by each element. Exemplarily, the estimated data volume of the output data is then determined based on the amount of data corresponding to each element. Exemplarily, the product of the number of predicted elements in the output data and the amount of data corresponding to a single element is determined as the estimated data volume of the output data.

[0118] In some embodiments, the data volume corresponding to a single element is 32 bits. Then, based on the product of the dimension values ​​of each dimension included in the output dimension shape of the first grid point (5*5*5=125), the estimated data volume of the output data is determined to be 125*32bit=4000bit.

[0119] The technical solution provided in this application addresses the memory waste problem inherent in related technologies that directly estimate the output data volume based on the maximum dimension value of a variable dimension. Instead, it determines the smallest reference dimension shape (i.e., the first reference dimension shape) from at least one reference dimension shape that is greater than or equal to the input dimension shape, based on the variable dimension in the input dimension shape. The estimated output data volume is then obtained using the output dimension shape derived from this first reference dimension shape. Compared to blindly determining the estimated data volume directly based on the maximum dimension value, this application finds the smallest reference dimension shape greater than or equal to the input dimension shape from multiple reference dimension shapes to further determine the estimated data volume. This makes the estimated data volume more closely match the actual output data volume, thus reducing memory waste.

[0120] Below, in conjunction with Figure 4 The following is an exemplary description of the specific method for determining the first grid point from multiple grid points in this application.

[0121] Please refer to Figure 4This document illustrates a flowchart of a data volume determination method according to another embodiment of this application. The execution subject of this method can be the terminal device 10 described above, such as the client of the target application mentioned in the above embodiments, or the server 20 described above. In the following method embodiments, for ease of description, only the execution subject of each step is described as a "computer device". The method may include at least one of the following steps (410-450):

[0122] Step 410: Obtain the input dimension shape of the input data. The input data is the data processed by the neural network unit. The input data includes data in N dimensions. The input dimension shape includes the dimension values ​​corresponding to the N dimensions. There is at least one variable dimension among the N dimensions. N is a positive integer.

[0123] In some embodiments, the number of variable dimensions is M, where M is a positive integer less than or equal to N.

[0124] In some embodiments, the dimension values ​​corresponding to the M variable dimensions in the input dimension shape of the input data are obtained.

[0125] Step 420: For the i-th variable dimension among the M variable dimensions, determine the first sampling point of the input data in the i-th variable dimension based on the dimension value of the i-th variable dimension in the shape of the input dimension of the input data and the sampling interval of the i-th variable dimension. The sampling point of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​of the i-th variable dimension and the number of sampling points of the i-th variable dimension. The sampling interval of the i-th variable dimension is determined based on the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M.

[0126] In some embodiments, the first grid point needs to be determined based on the dimension values ​​corresponding to the M variable dimensions in the input dimension shape of the input data.

[0127] For example, the reference dimension shape corresponding to the first grid point is greater than or equal to the dimension values ​​corresponding to the M variable dimensions in the input dimension shape of the input data, so as to achieve the purpose of the reference dimension shape corresponding to the first grid point being greater than or equal to the input dimension shape of the input data.

[0128] For example, multiple sampling points from the maximum dimension value to the minimum dimension value are determined on the i-th variable dimension according to the sampling interval of the i-th variable dimension. For example, the multiple sampling points of the i-th variable dimension include the point corresponding to the maximum dimension value of the i-th variable dimension and the point corresponding to the minimum dimension value of the i-th variable dimension.

[0129] For example, the sampling interval between any two adjacent sampling points on the i-th variable dimension may be the same or different.

[0130] In some embodiments, multiple sampling points correspond to each of the M variable dimensions. For example, different sampling points of the i-th variable dimension correspond to different dimension values ​​of the i-th variable dimension. For example, the dimension value corresponding to the first sampling point of the i-th variable dimension is denoted as i. c In some embodiments, the dimension value of the i-th variable dimension in the input dimension shape of the input data is denoted as i. s . Then i c Greater than or equal to i s .

[0131] In some embodiments, the number of sampling points on different variable dimensions may be the same or different.

[0132] In some embodiments, based on the dimension value of the i-th variable dimension in the input dimension shape of the input data and the sampling interval of the i-th variable dimension, the smallest sampling point with a dimension value greater than or equal to the dimension value of the i-th variable dimension in the input dimension shape of the input data and the smallest dimension value is determined from multiple sampling points of the i-th variable dimension; the smallest sampling point is determined as the first sampling point of the input data in the i-th variable dimension.

[0133] For example, from multiple sampling points of the i-th variable dimension, the sampling point whose dimension value is greater than or equal to the dimension value of the i-th variable dimension in the shape of the input dimension of the input data and whose corresponding dimension value is the smallest is determined, and this sampling point is determined as the minimum sampling point.

[0134] In some embodiments, the maximum dimension value of the i-th variable dimension is obtained; the difference between the maximum dimension value of the i-th variable dimension and the dimension value of the i-th variable dimension in the input dimension shape of the input data is divided by the sampling interval of the i-th variable dimension to obtain P sampling intervals, where P is an integer greater than or equal to 0; among the multiple sampling points of the i-th variable dimension, the sampling point with the maximum dimension value of the i-th variable dimension as the sampling starting point and an interval of P sampling intervals is determined as the minimum sampling point.

[0135] For example, the maximum dimension value of the i-th variable dimension is obtained; the difference between the maximum dimension value of the i-th variable dimension and the dimension value of the i-th variable dimension in the input dimension shape of the input data, except that the result obtained by the sampling interval of the i-th variable dimension is an integer, is directly used as the number of sampling intervals P.

[0136] For example, obtain the maximum dimension value of the i-th variable dimension; the difference between the maximum dimension value of the i-th variable dimension and the dimension value of the i-th variable dimension in the input dimension shape of the input data, except that the result obtained by the sampling interval of the i-th variable dimension is not an integer, the result is rounded down to obtain the number of sampling intervals P.

[0137] For example, taking equidistant sampling as an example, calculate (maximum dimension value of the i-th variable dimension - dimension value of the i-th variable dimension in the shape of the input dimension of the input data) / sampling interval of the i-th variable dimension. The result is rounded down to obtain an integer P, where the integer P represents P sampling intervals.

[0138] For example, still using Figure 2 For example, calculate (maximum variable dimension value 10 - variable dimension value 3 in the input dimension shape of the input data) / sampling interval 3 of the variable dimension. The result is rounded down to the integer 2, which represents 2 sampling intervals.

[0139] For example, if the grid point containing the maximum dimension value of the i-th variable dimension is considered to be the 0th sampling point, then the sampling point that is P sampling intervals away from the maximum dimension value of the i-th variable dimension is considered to be the P-th sampling point.

[0140] For example, the minimum sampling point is determined by taking the maximum dimension value of the i-th variable dimension as the sampling starting point and the sampling points spaced P sampling intervals apart. For example, still using... Figure 2 For example, taking the maximum dimension value of 10 (a variable dimension) as the sampling starting point, sampling point 4, which is two sampling intervals apart (it should be understood that sampling point 3 here refers to the sampling point with a dimension value of 4, not necessarily the fourth sampling point; the same applies elsewhere in the context), is determined as the minimum sampling point. For instance, if sampling point 10 is considered the 0th sampling point, then sampling point 4 is the 2nd sampling point.

[0141] In some embodiments, the input dimension shape of the input data is (27, 3, 224, 224). It can be seen that the variable dimension value is 27, and the difference between this and the maximum dimension value of 32 is 32 - 27 = 5. The corresponding sampling grid point number (or the number of sampling intervals) is... Therefore, the closest sampling grid point to the shape of the input dimension greater than or equal to this input data is sampling point 0 (i.e., the determined first grid point mentioned above), which is the grid point corresponding to the maximum dimension value of 32. At this time, the reference dimension shape corresponding to this first grid point is (32, 3, 224, 224). This indicates rounding down to the nearest integer.

[0142] In some embodiments, when the number of M is 1, the minimum sampling point in the i-th dimension is also known as the first grid point. For example, as... Figure 2 As shown, the minimum sampling point 4 is also the first grid point 210.

[0143] In some embodiments, the above steps are performed for each of the M variable dimensions to determine the first sampling point of the input data in each variable dimension.

[0144] Step 430: Determine the first grid point from at least one grid point based on the first sampling points corresponding to the input dimension shape in each of the M variable dimensions.

[0145] In some embodiments, the product of the number of sampling points corresponding to the M dimensions is determined as the total number of at least one grid point.

[0146] For example, such as Figure 2 As shown, M is 1, the number of sampling points is 4, then the number of at least one grid point is 4.

[0147] For example, such as Figure 6 As shown, the number of sampling points in the first variable dimension is 5, and the number of sampling points in the second variable dimension is 5, therefore the number of at least one grid point is 5*5. That is, Figure 6 Any grid point in the grid shown is a grid point. Figure 6 The grid shown represents the region formed by the range of dimensional values ​​of the first and second variable dimensions. In some embodiments, if the input dimension shape of the input data has a dimension value of 5 in the first variable dimension and a dimension value of 900 in the second variable dimension, then the first sampling point of the input data in the first variable dimension is sampling point 610 (dimensional value of 9), and the first sampling point of the input data in the second variable dimension is sampling point 620 (dimensional value of 1040). In some embodiments, a grid point 630 is determined in the grid based on sampling points 610 and 620. Exemplarily, the dimension value of grid point 630 in the first variable dimension is the same as the dimension value corresponding to sampling point 610, and the dimension value of grid point 630 in the second variable dimension is the same as the dimension value corresponding to sampling point 620.

[0148] In some embodiments, the first grid point is a grid point whose dimension value in the M variable dimensions is the same as the dimension value of the first sampling point corresponding to the M variable dimensions.

[0149] In some embodiments, the first grid point is uniquely determined after the first sampling point corresponding to each of the M variable dimensions of the input data.

[0150] In some embodiments, the first grid point indicates only the dimension values ​​of the M variable dimensions. In other embodiments, the first grid point may also indicate the dimension values ​​of the N fixed dimensions in the input data. This application is not limited in this respect.

[0151] Step 440: From the reference dimension shapes corresponding to at least one grid point, determine the reference dimension shape corresponding to the first grid point as the first reference dimension shape. The reference dimension shape corresponding to the grid point includes the different dimension values ​​corresponding to the M variable dimensions indicated by the grid point, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape.

[0152] Step 450: Before processing the input data through the neural network unit to obtain the output data, the estimated amount of output data is determined based on the output dimension shape of the first reference dimension shape. The estimated amount of output data is used to determine the memory space to be configured for the output data.

[0153] The technical solution provided in this application, before determining the first grid point, determines a first sampling point for any one of the variable dimensions. This first sampling point is the sampling point whose dimension value is greater than or equal to the dimension value of the input data in that dimension, and whose dimension value is the smallest. The first grid point determined in this way satisfies the requirement that it is greater than or equal to the dimension value of the input data in each dimension, thereby ensuring that the estimated amount of output data is not less than the actual amount of output data, and that the difference is significant, minimizing memory waste.

[0154] Below, in conjunction with Figure 5 The following are exemplary descriptions of the specific grid point construction method and data volume determination method in this application.

[0155] Please refer to Figure 5 This document illustrates a flowchart of a data volume determination method according to another embodiment of this application. The execution subject of this method can be the terminal device 10 described above, such as the client of the target application mentioned in the above embodiments, or the server 20 described above. In the following method embodiments, for ease of description, the execution subject of each step is only described as a "computer device". The method may include at least one of the following steps (510-580):

[0156] Steps 510 to 550 below describe the grid point construction method (including the determination of the input dimension shape and the output dimension shape). These steps can also be implemented as pre-execution steps.

[0157] Step 510: Based on the dimension value ranges corresponding to the M variable dimensions, determine the maximum and minimum dimension values ​​corresponding to the M variable dimensions.

[0158] In some embodiments, different neural network units correspond to different variable-dimensional input data. For example, a neural network unit is obtained, and the variable dimensions in its input data are determined.

[0159] In some embodiments, a computer device acquires a neural network unit comprising at least one neural network layer. Exemplarily, after acquiring the neural network unit, it needs to be compiled to obtain a compiled neural network unit. Only the compiled neural network unit can run on the computer device to perform inference on the input data (i.e., process the input data). In some embodiments, the process of compiling the neural network unit can also be considered as a format conversion process of the neural network unit, transforming the source code of the neural network unit into compiled code that can be executed by the computer device.

[0160] In some embodiments, steps 510 to 550 can be executed synchronously during the compilation of the neural network unit by the computer device. For example, after the computer device has completed compiling the neural network unit, steps 510 to 550 have also been executed, meaning that at least one grid point, the reference dimension shape corresponding to each grid point, and the output dimension shape have been determined. In some embodiments, at least one grid point, the reference dimension shape corresponding to each grid point, and the output dimension shape are recorded in a grid point library.

[0161] In some embodiments, after compilation, when processing input data using neural network units, the first grid point and the corresponding output dimension shape are directly obtained from the grid point library.

[0162] In some embodiments, when acquiring neural network units, the computer device also acquires the maximum and minimum dimension values ​​corresponding to the M variable dimensions, respectively.

[0163] In other embodiments, when acquiring a neural network unit, the computer device acquires not only the maximum and minimum dimension values ​​corresponding to the M variable dimensions, but also the dimension values ​​corresponding to the NM fixed dimensions. For example, the dimension values ​​of the N dimensions constitute the input dimension shape of the input data for the neural network unit.

[0164] Step 520: Construct at least one grid point based on the maximum and minimum dimension values ​​corresponding to the M variable dimensions.

[0165] In some embodiments, the dimension values ​​indicated by the constructed grid points in the M variable dimensions should be within the region (including the boundary) formed by the maximum and minimum dimension values ​​corresponding to the M variable dimensions respectively.

[0166] In some embodiments, at least one grid point is obtained by randomly sampling within the region (including the boundary) formed by the maximum and minimum dimension values ​​corresponding to the M variable dimensions.

[0167] In some embodiments, for the i-th variable dimension among M variable dimensions, multiple sampling points of the i-th variable dimension are determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M.

[0168] For example, after determining the number of sampling points for the i-th variable dimension, multiple sampling points are sampled from the dimensional value interval between the maximum and minimum dimensional values ​​corresponding to the i-th variable dimension. The dimensional values ​​corresponding to these multiple sampling points belong to the closed interval from the minimum dimensional value to the maximum dimensional value of the i-th variable dimension. This application does not limit the sampling method; it is sufficient to record the dimensional value corresponding to each sampling point.

[0169] In some embodiments, the total number of sampling points is obtained; based on the result of taking the Mth root of the total number of sampling points, the number of sampling points for the i-th variable dimension is determined.

[0170] For example, if the number of sampling points is the same for each of the M variable dimensions, then the number of sampling points for the i-th variable dimension is determined by taking the M-th power of the total number of sampling points. For example, if the number of variable dimensions is 2 and the total number of sampling points is 100, then taking the square root of 100 yields 10. Therefore, the number of sampling points for each variable dimension is 10. For two variable dimensions, a total of 10 * 10 = 100 sampling points can be determined.

[0171] For example, the number of sampling points for each of the M variable dimensions can be different. The number of sampling points for each of the M variable dimensions is set such that the product of the number of sampling points for each of the M variable dimensions equals the total number of sampling points. For example, if the number of variable dimensions is 2, the total number of sampling points is 100, the number of sampling points for the first variable dimension is 5, and the number of sampling points for the second variable dimension is 20, then a total of 5 * 20 = 100 sampling points can be determined for these two variable dimensions.

[0172] For example, the number of sampling points for the i-th variable dimension is related to the size of the dimensional interval formed by the maximum and minimum dimensional values ​​of the i-th variable dimension. For example, the number of sampling points for the i-th variable dimension is positively correlated with the dimensional interval formed by the maximum and minimum dimensional values ​​of the i-th variable dimension. For example, the larger the dimensional interval, the more sampling points there are. The smaller the dimensional interval, the fewer sampling points there are.

[0173] In some embodiments, when the number of sampling points for each variable dimension is the same, it is called equal sampling; when the number of sampling points for each variable dimension is different, it is called unequal sampling.

[0174] The technical solution provided in this application offers two sampling methods: equal sampling and unequal sampling, to meet different user needs. Equal sampling is relatively simple to calculate and can improve data processing efficiency. Unequal sampling, on the other hand, combines the dimensional interval formed by the maximum and minimum dimensional values ​​of the i-th variable dimension to determine different numbers of sampling points. This allows for a more even distribution of grid points, resulting in better performance of at least one grid point. It also makes it easier to find a first grid point that is larger than and closer to the shape of the input dimension, ensuring that the estimated data volume is closer to the actual data volume.

[0175] In some embodiments, the sampling interval of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension; based on the sampling interval of the i-th variable dimension, sampling is performed between the maximum dimension value corresponding to the i-th variable dimension and the minimum dimension value corresponding to the i-th variable dimension, starting from the maximum dimension value corresponding to the i-th variable dimension, to obtain multiple sampling points of the i-th variable dimension.

[0176] For example, when sampling is equidistant (sampling interval is the same), and the points corresponding to the maximum and minimum dimensions of the i-th variable dimension are respectively used as sampling points, the sampling interval = (maximum dimension value corresponding to the i-th variable dimension - minimum dimension value) / (number of sampling points - 1). For example, as... Figure 2 As shown, the number of sampling points is equal to 4, and the sampling interval = (maximum dimension value of variable dimension - minimum dimension value) / (number of sampling points - 1) = (10 - 1) / 3 = 3.

[0177] For example, the sampling interval = (maximum dimension value corresponding to the i-th variable dimension - minimum dimension value) / number of sampling points (excluding the 0th grid point, i.e., points corresponding to the maximum and minimum dimension values ​​are not considered as points to be sampled). For example: if there are 4 sampling grid points, and the input dimension shape of the model (referring to the neural network unit mentioned above) is (n, 3, 224, 224), with a dimension value of n containing one variable dimension, a maximum dimension value of 32, and a minimum dimension value of 1, then the maximum input dimension shape of the input data is (32, 3, 224, 224), and the minimum input dimension shape is (n, 3, 224, 224). The sampling interval = (32-1) / 4 = 31 / 4.

[0178] In other embodiments, sampling may also be non-equidistant (with different sampling intervals). For example, the sampling interval may increase or decrease exponentially. For example, when the magnitude of change in the input data increases or decreases exponentially, the sampling interval may increase or decrease exponentially.

[0179] In other embodiments, sampling includes equidistant sampling and non-equidistant sampling. For example, a portion of the sampling is equidistant, and another portion is non-equidistant. For example, based on the distribution of the variable-dimensional values, equidistant sampling is performed where the distribution changes drastically, while non-equidistant sampling is performed where the distribution changes are not drastically.

[0180] In some embodiments, when sampling is at equal intervals, the value of a single sampling interval can be recorded directly. In other embodiments, when sampling is not at equal intervals, each sampling interval is recorded, or the method for calculating the sampling interval is recorded.

[0181] In some embodiments, for the kth sampling point among multiple sampling points of the i-th variable dimension, where k is an integer greater than or equal to 0, the difference between the first data value and the second data value is used to obtain the dimension value corresponding to the kth sampling point of the i-th variable dimension. The first data value is the maximum dimension value corresponding to the i-th variable dimension, and the second data value is the product of the sampling interval of the i-th variable dimension and k.

[0182] For example, for the kth sampling point among multiple sampling points of the i-th variable dimension, where k is an integer greater than or equal to 0, if the difference between the first data value and the second data value is not an integer, the dimension value corresponding to the kth sampling point of the i-th variable dimension is obtained by rounding up.

[0183] For example, the 0th sampling point has the largest dimension value. The kth sampling point in, This indicates rounding up. For example, still using... Figure 2 For example, the second sampling point (sampling point 4)

[0184] For example, the input data has an input dimension shape of (n, 3, 224, 224), including a variable dimension n, where the maximum dimension value of n is 32 and the minimum dimension value is 1, and the number of sampling points is 4. For the first sampling point, when the sampling interval is 31 / 4, In some embodiments, when only one variable dimension exists, the first sampling point is used as a grid point, indicating the output dimension shape as (25, 3, 224, 224).

[0185] For example, for the kth sampling point among multiple sampling points of the i-th variable dimension, where k is an integer greater than or equal to 0, if the difference between the first data value and the second data value is an integer, the difference between the first data value and the second data value is directly used as the dimension value corresponding to the kth sampling point of the i-th variable dimension.

[0186] In some embodiments, considering that the dimension value must be an integer, it is rounded up to ensure that the obtained value is an integer and relatively large.

[0187] In some embodiments, at least one grid point is constructed based on multiple sampling points corresponding to the M variable dimensions, and each grid point is constructed from one sampling point corresponding to the M variable dimensions.

[0188] For example, the number of at least one grid point is equal to the product of the number of sampling points corresponding to each of the M variable dimensions. For example, as Figure 6 As shown, the first variable dimension corresponds to 5 sampling points (including the points corresponding to the maximum and minimum dimension values ​​respectively), and the second variable dimension corresponds to 5 sampling points (including the points corresponding to the maximum and minimum dimension values ​​respectively), so a total of 5*5 grid points can be constructed.

[0189] In some embodiments, the N dimensions further include NM fixed dimensions, which are dimensions with the same value for different input data; the reference dimension shape corresponding to each grid point includes the dimension values ​​corresponding to the NM fixed dimensions, and the dimension values ​​corresponding to the sampling points of the grid point in the M variable dimensions.

[0190] For example, as in the embodiments described above, the number of dimensions included in the reference dimension shape corresponding to each grid point should be equal to the number of dimensions included in the input dimension shape of the input data, that is, the number of dimensions included in the reference dimension shape corresponding to each grid point is equal to N. For example, the reference dimension shape corresponding to each grid point includes dimension values ​​corresponding to M variable dimensions and dimension values ​​corresponding to NM fixed dimensions. For example, the dimension values ​​corresponding to the sampling points of the grid point in the M variable dimensions are equal to the dimension values ​​corresponding to the sampling points of the input data in the M variable dimensions. For example, the order of the N dimensions in the reference dimension shape corresponding to the grid point is consistent with the order of the N dimensions in the input dimension shape of the input data.

[0191] Step 530: For each grid point in at least one grid point, construct grid point input data based on the reference dimension shape corresponding to the grid point.

[0192] For example, after determining the reference dimension shape corresponding to the grid points, data needs to be filled into the matrix of the input dimension shape. For example, randomly generated values ​​are filled into the matrix of the input dimension shape to obtain the grid point input data.

[0193] In some embodiments, the data type of the input data is obtained; based on the data type of the input data, the data value corresponding to the data type of the input data is determined from the mapping table, wherein the mapping table includes at least one set of data types and data values ​​with corresponding relationships; the data values ​​are used as the data values ​​of each data in the grid point input data, and the grid point input data is constructed based on the reference dimension shape corresponding to the grid point.

[0194] For example, different data values ​​are pre-configured for different data types. For example, when the data type is an integer, the data value is 1. For example, when the data type is a floating-point number, the data value is 0.51. For example, when the data type is a boolean type, the data value is true. For example, integer type and 1 represent a pair of data types and data values ​​with a corresponding relationship. For example, floating-point number type and 0.51 represent a pair of data types and data values ​​with a corresponding relationship. For example, boolean type and true represent a pair of data types and data values ​​with a corresponding relationship.

[0195] For example, the data type of the input data is obtained, and the corresponding data value is determined from the mapping table. For example, when the data type of the input data is an integer, the determined data value is 1. For example, when the data type of the input data is a floating-point number, the determined data value is 0.51. For example, when the data type of the input data is a boolean, the determined data value is true.

[0196] For example, the numerical values ​​are used as the numerical values ​​of each data point in the grid point input data, and the grid point input data is constructed based on the reference dimension shape corresponding to the grid point. For example, when the input data is of integer type, 1 is used as the numerical value of each data point in the grid point input data, and the grid point input data is constructed based on the reference dimension shape corresponding to the grid point. For example, when the input data is of floating-point type, 0.51 is used as the numerical value of each data point in the grid point input data, and the grid point input data is constructed based on the reference dimension shape corresponding to the grid point. For example, when the input data is of boolean type, true is used as the numerical value of each data point in the grid point input data, and the grid point input data is constructed based on the reference dimension shape corresponding to the grid point.

[0197] For example, a matrix corresponding to the reference dimension shape corresponding to the grid points is constructed. The data values ​​are then filled into this blank matrix to obtain the grid point input data.

[0198] Step 540: Process the grid point input data through the neural network unit to obtain the grid point output data.

[0199] For example, before using the neural network unit to infer the input data, the neural network unit first processes the grid point input data to obtain the grid point output data.

[0200] Step 550: Determine the dimension values ​​of the grid point output data in each dimension as the output dimension shape corresponding to the reference dimension shape.

[0201] In some embodiments, the output dimension shape corresponding to a grid point is also the output dimension shape corresponding to a reference dimension shape. In some embodiments, the output dimension shape corresponding to a first grid point is also the output dimension shape corresponding to a first reference dimension shape.

[0202] For example, the output dimension shape corresponding to a grid point includes the dimension values ​​of the grid point output data in each dimension. For example, if the grid point output data includes data in S dimensions, then the output dimension shape corresponding to the grid point includes the dimension values ​​corresponding to each of the S dimensions, where S is a positive integer.

[0203] Step 560: Obtain the input dimension shape of the input data. The input data is the data processed by the neural network unit. The input data includes data in N dimensions. The input dimension shape includes the dimension values ​​corresponding to the N dimensions. Among the N dimensions, there are M variable dimensions, where N is a positive integer.

[0204] Step 570: Based on the input dimension shape, determine a first reference dimension shape from at least one reference dimension shape. The first reference dimension shape is the smallest reference dimension shape among the at least one reference dimension shapes that is greater than or equal to the input dimension shape. The determination of at least one reference dimension shape is related to at least one variable dimension.

[0205] Step 580: Before processing the input data through the neural network unit to obtain the output data, the estimated amount of output data is determined based on the output dimension shape corresponding to the first reference dimension shape. The estimated amount of output data is used to determine the memory space configured for the output data.

[0206] In some embodiments, the data type of the input data is obtained; based on the output dimension shape of the first reference dimension and the data type of the input data, the estimated data volume of the output data is determined.

[0207] The data types of the input data are explained in the above embodiments and will not be repeated here.

[0208] In some embodiments, the estimated data volume of the output data is determined by multiplying the dimension values ​​of each dimension contained in the output dimension shape of the first reference dimension with the data volume of a single data item indicated by the data type of the input data.

[0209] For example, the estimated amount of output data is equal to the dimension values ​​of each dimension contained in the output dimension shape of the first reference dimension multiplied by the amount of data of a single data point indicated by the data type of the input data.

[0210] For example, different data types indicate different amounts of data for a single piece of data.

[0211] For example, when the input data is of integer type, the data size of a single data item indicated by a data value of 1 is the second value. For example, when the input data is of floating-point type, the data size of a single data item indicated by a data value of 0.51 is the third value. For example, when the input data is of boolean type, the data size of a single data item indicated by a data value of true is the fourth value.

[0212] For example, the output dimension shape of the first grid point is (32, 3, 224, 224). For example, when the input data is of integer type, the estimated output data size = 32 * 3 * 224 * 224 * the second value. For example, when the input data is of floating-point type, the estimated output data size = 32 * 3 * 224 * 224 * the third value. For example, when the input data is of boolean type, the estimated output data size = 32 * 3 * 224 * 224 * the fourth value. Of course, the specific values ​​of the second, third, and fourth values ​​are not limited.

[0213] For example, taking the second value as 4 bits, the estimated data size of the output data = 32 * 3 * 224 * 224 * 4 bits = 4816896 bits = 588KB.

[0214] In some embodiments, before processing the input data through the neural network unit, a first instruction is sent to the memory to request memory space, the amount of which is equal to the estimated amount of output data.

[0215] For example, the first instruction is used to request memory space for the estimated size of the output data.

[0216] In other embodiments, a second instruction is sent to the memory, which instructs the memory to copy the output data obtained by processing the input data through the neural network unit.

[0217] For example, the second instruction is the D2H copy instruction.

[0218] For example, when the memory is located in a chip on a computer device, the first instruction is sent to the chip that includes the memory. For example, when the memory is located in a chip on a computer device, the second instruction is sent to the chip that includes the memory.

[0219] This application's embodiments implement general shape inference logic with only a small amount of code. It saves 45% of output video memory, wasting only about 1% compared to the actual output, while also saving D2H time after inference, thus improving throughput and latency. Table 1 below shows the throughput and latency for different input dimension shapes, using the maximum output size and determining the output size based on sampled grid points.

[0220] Table 1 shows the throughput and latency for different input dimensions and shapes, using the maximum output size and determining the output size based on the sampling grid points.

[0221]

[0222]

[0223] In this application embodiment, when reasoning about a dynamic shape deep learning model (i.e., a neural network unit), a method is proposed to obtain the output size of a portion of the sampled grid points through pre-sampling. During model reasoning, the nearest sampled grid point (the first grid point) that is greater than or equal to the actual output is found. Based on the output size obtained by sampling this grid point, output memory is allocated and processed, thereby achieving the effect of saving device memory and reducing redundant copying.

[0224] The following describes application scenario examples.

[0225] In the first application scenario, the neural network unit is a disease diagnosis model. The input data is medical data, and the output data is the disease diagnosis result.

[0226] Please refer to Figure 7 This document illustrates a flowchart of a data volume determination method according to another embodiment of this application. The execution subject of this method can be the terminal device 10 described above, such as the client of the target application mentioned in the above embodiments, or the server 20 described above. In the following method embodiments, for ease of description, the execution subject of each step is only described as a "computer device". The method may include at least one of the following steps (710-730):

[0227] Step 710: Obtain the input dimension shape of the input medical data. The input medical data is the data processed by the disease diagnosis model. The input medical data includes data in N dimensions. The input dimension shape includes the dimension values ​​corresponding to the N dimensions. There is at least one variable dimension among the N dimensions. N is a positive integer.

[0228] Step 720: Based on the input dimension shape, determine a first reference dimension shape from at least one reference dimension shape. The first reference dimension shape is the smallest reference dimension shape among the at least one reference dimension shapes that is greater than or equal to the input dimension shape. The determination of at least one reference dimension shape is related to at least one variable dimension.

[0229] In some embodiments, the number of variable dimensions is M, where M is a positive integer less than or equal to N.

[0230] In some embodiments, a first grid point is determined from at least one grid point based on the dimension values ​​of the M variable dimensions included in the input dimension shape. The at least one grid point is determined by sampling from the dimension space formed by the dimension value intervals corresponding to the M variable dimensions, where the dimension value interval is the range of variation of the dimension values ​​of the variable dimensions, and different grid points in the at least one grid point indicate different dimension values ​​corresponding to the M variable dimensions. From the reference dimension shapes corresponding to the at least one grid point, the reference dimension shape corresponding to the first grid point is determined as the first reference dimension shape. The reference dimension shape corresponding to the grid point includes the different dimension values ​​indicated by the grid point in the M variable dimensions, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape.

[0231] In some embodiments, for the i-th variable dimension among the M variable dimensions, the first sampling point of the input medical data in the i-th variable dimension is determined based on the dimension value of the i-th variable dimension included in the shape of the input dimension and the sampling interval of the i-th variable dimension. The sampling point of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​of the i-th variable dimension and the number of sampling points of the i-th variable dimension. The sampling interval of the i-th variable dimension is determined based on the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. Based on the first sampling points corresponding to the shape of the input dimension in the M variable dimensions, a first grid point is determined from at least one grid point.

[0232] In some embodiments, based on the dimension value of the i-th variable dimension in the input dimension shape and the sampling interval of the i-th variable dimension, the smallest sampling point with a dimension value greater than or equal to the dimension value of the i-th variable dimension in the input dimension shape and the smallest dimension value is determined from multiple sampling points of the i-th variable dimension; the smallest sampling point is determined as the first sampling point of the input medical data in the i-th variable dimension.

[0233] In some embodiments, the maximum dimension value of the i-th variable dimension is obtained; the difference between the maximum dimension value of the i-th variable dimension and the dimension value of the i-th variable dimension in the input dimension shape is divided by the sampling interval of the i-th variable dimension to obtain P sampling intervals, where i is an integer greater than or equal to 0; among the multiple sampling points of the i-th variable dimension, the sampling point with the maximum dimension value of the i-th variable dimension as the sampling starting point and an interval of P sampling intervals is determined as the minimum sampling point.

[0234] In some embodiments, based on the dimensional value ranges corresponding to the M variable dimensions, the maximum and minimum dimensional values ​​corresponding to the M variable dimensions are determined respectively; at least one grid point is constructed according to the maximum and minimum dimensional values ​​corresponding to the M variable dimensions; for each grid point, grid point input medical data is constructed based on the reference dimensional shape corresponding to the grid point; the grid point input medical data is processed by the disease diagnosis model to obtain the grid point output disease diagnosis result; the dimensional values ​​of the grid point output disease diagnosis result in each dimension are determined as the output dimensional shape corresponding to the reference dimensional shape.

[0235] In some embodiments, for the i-th variable dimension among the M variable dimensions, multiple sampling points of the i-th variable dimension are determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. At least one grid point is constructed based on the multiple sampling points corresponding to the M variable dimensions, and each grid point is constructed from one sampling point corresponding to the M variable dimensions.

[0236] In some embodiments, the sampling interval of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension; based on the sampling interval of the i-th variable dimension, sampling is performed between the maximum dimension value corresponding to the i-th variable dimension and the minimum dimension value corresponding to the i-th variable dimension, starting from the maximum dimension value corresponding to the i-th variable dimension, to obtain multiple sampling points of the i-th variable dimension.

[0237] In some embodiments, for the kth sampling point among multiple sampling points of the i-th variable dimension, where k is an integer greater than or equal to 0, the difference between the first data value and the second data value is used to obtain the dimension value corresponding to the kth sampling point of the i-th variable dimension. The first data value is the maximum dimension value corresponding to the i-th variable dimension, and the second data value is the product of the sampling interval of the i-th variable dimension and k.

[0238] In some embodiments, the total number of sampling points is obtained; based on the result of taking the Mth root of the total number of sampling points, the number of sampling points for the i-th variable dimension is determined.

[0239] In some embodiments, a reference dimension shape corresponding to a grid point is determined based on the different dimension values ​​corresponding to the M variable dimensions indicated by the grid point, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape. Based on the data type of the input medical data, data values ​​corresponding to the data type of the input medical data are determined from a mapping table, wherein the mapping table includes at least one set of data types and data values ​​with corresponding relationships. The data values ​​are used as the data values ​​of each data in the grid point input medical data, and the grid point input medical data is constructed based on the reference dimension shape corresponding to the grid point.

[0240] Step 730: Before processing the input medical data through the disease diagnosis model to obtain the output disease diagnosis result, the estimated data volume of the output disease diagnosis result is determined based on the output dimension shape corresponding to the first reference dimension shape. The estimated data volume of the output disease diagnosis result is used to determine the memory space configured for the output disease diagnosis result.

[0241] In some embodiments, the data type of the input medical data is obtained; based on the output dimension shape corresponding to the first reference dimension shape and the data type of the input medical data, the estimated data volume of the output disease diagnosis result is determined.

[0242] In some embodiments, the product of the dimension values ​​of each dimension contained in the output dimension shape corresponding to the first reference dimension shape and the data volume of a single data point indicated by the data type of the input medical data is determined as the estimated data volume of the output disease diagnosis result.

[0243] In some embodiments, before processing the input medical data through the disease diagnosis model, a first instruction is sent to the memory to request memory space, the amount of which is equal to the estimated amount of data for outputting the disease diagnosis results.

[0244] Considering the memory waste problem caused by directly using the maximum dimension value of a variable dimension to obtain the estimated data volume of the output disease diagnosis result in related technologies, this application determines the smallest reference dimension shape (i.e., the first reference dimension shape) that is greater than or equal to the input dimension shape from at least one reference dimension shape, based on the variable dimension in the input dimension shape. The estimated data volume of the output disease diagnosis result is obtained through the output dimension shape of this first reference dimension shape. Compared to blindly determining the estimated data volume directly based on the maximum dimension value, this application finds the smallest reference dimension shape that is greater than or equal to the input dimension shape from multiple reference dimension shapes to further determine the estimated data volume, making the estimated data volume more closely match the actual data volume of the output disease diagnosis result, thus reducing memory waste.

[0245] The second application scenario involves a neural network unit used in a population prediction model. The input data is historical population data, and the output data is the expected population data.

[0246] Please refer to Figure 8 This illustrates a flowchart of a data volume determination method provided in another embodiment of this application. The execution subject of this method can be the terminal device 10 described above, such as the client of the target application mentioned in the above embodiments, or the server 20 described above. In the following method embodiments, for ease of description, only the execution subject of each step is described as a "computer device". The method may include at least one of the following steps (810-830):

[0247] Step 810: Obtain the input dimension shape of the input historical population data. The input historical population data is the data processed by the population prediction model. The input historical population data includes data of N dimensions. The input dimension shape includes the dimension values ​​corresponding to the N dimensions. There is at least one variable dimension among the N dimensions. N is a positive integer.

[0248] Step 820: Based on the input dimension shape, determine a first reference dimension shape from at least one reference dimension shape. The first reference dimension shape is the smallest reference dimension shape among the at least one reference dimension shapes that is greater than or equal to the input dimension shape. The determination of at least one reference dimension shape is related to at least one variable dimension.

[0249] In some embodiments, the number of variable dimensions is M, where M is a positive integer less than or equal to N.

[0250] In some embodiments, a first grid point is determined from at least one grid point based on the dimension values ​​of the M variable dimensions included in the input dimension shape. The at least one grid point is determined by sampling from the dimension space formed by the dimension value intervals corresponding to the M variable dimensions, where the dimension value interval is the range of variation of the dimension values ​​of the variable dimensions, and different grid points in the at least one grid point indicate different dimension values ​​corresponding to the M variable dimensions. From the reference dimension shapes corresponding to the at least one grid point, the reference dimension shape corresponding to the first grid point is determined as the first reference dimension shape. The reference dimension shape corresponding to the grid point includes the different dimension values ​​indicated by the grid point in the M variable dimensions, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape.

[0251] In some embodiments, for the i-th variable dimension among the M variable dimensions, the first sampling point of the input historical population data in the i-th variable dimension is determined based on the dimension value of the i-th variable dimension included in the shape of the input dimension and the sampling interval of the i-th variable dimension. The sampling point of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​of the i-th variable dimension and the number of sampling points of the i-th variable dimension. The sampling interval of the i-th variable dimension is determined based on the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. Based on the first sampling points corresponding to the shape of the input dimension in the M variable dimensions, a first grid point is determined from at least one grid point.

[0252] In some embodiments, based on the dimension value of the i-th variable dimension in the input dimension shape and the sampling interval of the i-th variable dimension, the smallest sampling point with a dimension value greater than or equal to the dimension value of the i-th variable dimension in the input dimension shape and the smallest dimension value is determined from multiple sampling points of the i-th variable dimension; the smallest sampling point is determined as the first sampling point of the input historical population data in the i-th variable dimension.

[0253] In some embodiments, the maximum dimension value of the i-th variable dimension is obtained; the difference between the maximum dimension value of the i-th variable dimension and the dimension value of the i-th variable dimension in the input dimension shape is divided by the sampling interval of the i-th variable dimension to obtain P sampling intervals, where i is an integer greater than or equal to 0; among the multiple sampling points of the i-th variable dimension, the sampling point with the maximum dimension value of the i-th variable dimension as the sampling starting point and an interval of P sampling intervals is determined as the minimum sampling point.

[0254] In some embodiments, based on the dimensional value intervals corresponding to the M variable dimensions, the maximum and minimum dimensional values ​​corresponding to the M variable dimensions are determined respectively; at least one grid point is constructed according to the maximum and minimum dimensional values ​​corresponding to the M variable dimensions; for each of the at least one grid point, historical population data is constructed based on the reference dimensional shape corresponding to the grid point; the historical population data is processed by the grid point input through a population prediction model to obtain the expected population data output by the grid point; the dimensional values ​​of the expected population data output by the grid point in each dimension are determined as the output dimensional shape corresponding to the reference dimensional shape.

[0255] In some embodiments, for the i-th variable dimension among the M variable dimensions, multiple sampling points of the i-th variable dimension are determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. At least one grid point is constructed based on the multiple sampling points corresponding to the M variable dimensions, and each grid point is constructed from one sampling point corresponding to the M variable dimensions.

[0256] In some embodiments, the sampling interval of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension; based on the sampling interval of the i-th variable dimension, sampling is performed between the maximum dimension value corresponding to the i-th variable dimension and the minimum dimension value corresponding to the i-th variable dimension, starting from the maximum dimension value corresponding to the i-th variable dimension, to obtain multiple sampling points of the i-th variable dimension.

[0257] In some embodiments, for the kth sampling point among multiple sampling points of the i-th variable dimension, where k is an integer greater than or equal to 0, the difference between the first data value and the second data value is used to obtain the dimension value corresponding to the kth sampling point of the i-th variable dimension. The first data value is the maximum dimension value corresponding to the i-th variable dimension, and the second data value is the product of the sampling interval of the i-th variable dimension and k.

[0258] In some embodiments, the total number of sampling points is obtained; based on the result of taking the Mth root of the total number of sampling points, the number of sampling points for the i-th variable dimension is determined.

[0259] In some embodiments, a reference dimension shape corresponding to a grid point is determined based on the different dimension values ​​corresponding to the M variable dimensions indicated by the grid point, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape. Based on the data type of the input historical population data, data values ​​corresponding to the data type of the input historical population data are determined from a mapping table, wherein the mapping table includes at least one set of data types and data values ​​with corresponding relationships. The data values ​​are used as the data values ​​of each data in the grid point input historical population data, and the grid point input historical population data is constructed based on the reference dimension shape corresponding to the grid point.

[0260] Step 830: Before processing the input historical population data through the population prediction model to obtain the output expected population data, the estimated data volume of the output expected population data is determined based on the output dimension shape corresponding to the first reference dimension shape. The estimated data volume of the output expected population data is used to determine the memory space configured for the output expected population data.

[0261] In some embodiments, the data type of the input historical population data is obtained; based on the output dimension shape corresponding to the first reference dimension shape and the data type of the input historical population data, the estimated data volume of the output expected population data is determined.

[0262] In some embodiments, the product of the dimension values ​​of each dimension contained in the output dimension shape corresponding to the first reference dimension shape and the data volume of a single data point indicated by the data type of the input historical population data is determined as the estimated data volume of the output expected population data.

[0263] In some embodiments, before processing the input historical population data through a population prediction model, a first instruction is sent to a memory to request memory space, the amount of which is equal to the estimated amount of output expected population data.

[0264] Considering the memory waste problem that directly using the maximum dimension value of a variable dimension to obtain the estimated output population data in related technologies can easily lead to errors, this application determines the smallest reference dimension shape (i.e., the first reference dimension shape) that is greater than or equal to the input dimension shape from at least one reference dimension shape, based on the variable dimension in the input dimension shape. The estimated output population data is then obtained through the output dimension shape of this first reference dimension shape. Compared to blindly determining the estimated data volume directly based on the maximum dimension value, this application finds the smallest reference dimension shape that is greater than or equal to the input dimension shape from multiple reference dimension shapes to further determine the estimated data volume. This makes the estimated data volume more closely match the actual data volume of the output population data, thus reducing memory waste.

[0265] The third application scenario is that the neural network unit is an image restoration model. The input data is the image data to be restored, and the output data is the restored image data.

[0266] Please refer to Figure 9 This illustrates a flowchart of a data volume determination method according to another embodiment of this application. The execution subject of this method can be the terminal device 10 described above, such as the client of the target application mentioned in the above embodiments, or the server 20 described above. In the following method embodiments, for ease of description, only the execution subject of each step is described as a "computer device". The method may include at least one of the following steps (910-930):

[0267] Step 910: Obtain the input dimension shape of the input image data to be repaired. The input image data to be repaired is the data processed by the image repair model. The input image data to be repaired includes data in N dimensions. The input dimension shape includes the dimension values ​​corresponding to the N dimensions. There is at least one variable dimension among the N dimensions, and N is a positive integer.

[0268] Step 920: Based on the input dimension shape, determine a first reference dimension shape from at least one reference dimension shape. The first reference dimension shape is the smallest reference dimension shape among the at least one reference dimension shapes that is greater than or equal to the input dimension shape. The determination of at least one reference dimension shape is related to at least one variable dimension.

[0269] In some embodiments, the number of variable dimensions is M, where M is a positive integer less than or equal to N.

[0270] In some embodiments, a first grid point is determined from at least one grid point based on the dimension values ​​of the M variable dimensions included in the input dimension shape. The at least one grid point is determined by sampling from the dimension space formed by the dimension value intervals corresponding to the M variable dimensions, where the dimension value interval is the range of variation of the dimension values ​​of the variable dimensions, and different grid points in the at least one grid point indicate different dimension values ​​corresponding to the M variable dimensions. From the reference dimension shapes corresponding to the at least one grid point, the reference dimension shape corresponding to the first grid point is determined as the first reference dimension shape. The reference dimension shape corresponding to the grid point includes the different dimension values ​​indicated by the grid point in the M variable dimensions, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape.

[0271] In some embodiments, for the i-th variable dimension among the M variable dimensions, the first sampling point of the input image data to be repaired in the i-th variable dimension is determined based on the dimension value of the i-th variable dimension included in the input dimension shape and the sampling interval of the i-th variable dimension. The sampling point of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​of the i-th variable dimension and the number of sampling points of the i-th variable dimension. The sampling interval of the i-th variable dimension is determined based on the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. Based on the first sampling points corresponding to the input dimension shape in the M variable dimensions, a first grid point is determined from at least one grid point.

[0272] In some embodiments, based on the dimension value of the i-th variable dimension in the input dimension shape and the sampling interval of the i-th variable dimension, the smallest sampling point with a dimension value greater than or equal to the dimension value of the i-th variable dimension in the input dimension shape and the smallest dimension value is determined from multiple sampling points of the i-th variable dimension; the smallest sampling point is determined as the first sampling point of the input image data to be repaired in the i-th variable dimension.

[0273] In some embodiments, the maximum dimension value of the i-th variable dimension is obtained; the difference between the maximum dimension value of the i-th variable dimension and the dimension value of the i-th variable dimension in the input dimension shape is divided by the sampling interval of the i-th variable dimension to obtain P sampling intervals, where i is an integer greater than or equal to 0; among the multiple sampling points of the i-th variable dimension, the sampling point with the maximum dimension value of the i-th variable dimension as the sampling starting point and an interval of P sampling intervals is determined as the minimum sampling point.

[0274] In some embodiments, based on the dimensional value ranges corresponding to the M variable dimensions, the maximum and minimum dimensional values ​​corresponding to the M variable dimensions are determined respectively; at least one grid point is constructed according to the maximum and minimum dimensional values ​​corresponding to the M variable dimensions; for each grid point, based on the reference dimensional shape corresponding to the grid point, the grid point input image data to be repaired is constructed; the grid point input image data to be repaired is processed by the image inpainting model to obtain the grid point output repaired image data; the dimensional values ​​of the grid point output repaired image data in each dimension are determined as the output dimensional shape corresponding to the reference dimensional shape.

[0275] In some embodiments, for the i-th variable dimension among the M variable dimensions, multiple sampling points of the i-th variable dimension are determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. At least one grid point is constructed based on the multiple sampling points corresponding to the M variable dimensions, and each grid point is constructed from one sampling point corresponding to the M variable dimensions.

[0276] In some embodiments, the sampling interval of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension; based on the sampling interval of the i-th variable dimension, sampling is performed between the maximum dimension value corresponding to the i-th variable dimension and the minimum dimension value corresponding to the i-th variable dimension, starting from the maximum dimension value corresponding to the i-th variable dimension, to obtain multiple sampling points of the i-th variable dimension.

[0277] In some embodiments, for the kth sampling point among multiple sampling points of the i-th variable dimension, where k is an integer greater than or equal to 0, the difference between the first data value and the second data value is used to obtain the dimension value corresponding to the kth sampling point of the i-th variable dimension. The first data value is the maximum dimension value corresponding to the i-th variable dimension, and the second data value is the product of the sampling interval of the i-th variable dimension and k.

[0278] In some embodiments, the total number of sampling points is obtained; based on the result of taking the Mth root of the total number of sampling points, the number of sampling points for the i-th variable dimension is determined.

[0279] In some embodiments, a reference dimension shape corresponding to the grid point is determined based on the different dimension values ​​corresponding to the M variable dimensions indicated by the grid point, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape. Based on the data type of the input image data to be repaired, data values ​​corresponding to the data type of the input image data to be repaired are determined from a mapping table, wherein the mapping table includes at least one set of data types and data values ​​with corresponding relationships. The data values ​​are used as the data values ​​of each data in the grid point input image data to be repaired, and the grid point input image data to be repaired is constructed based on the reference dimension shape corresponding to the grid point.

[0280] Step 930: Before processing the input image data to be repaired through the image inpainting model to obtain the output repaired image data, the estimated data volume of the output repaired image data is determined based on the output dimension shape corresponding to the first reference dimension shape. The estimated data volume of the output repaired image data is used to determine the memory space configured for the output repaired image data.

[0281] In some embodiments, the data type of the input image data to be repaired is obtained; based on the output dimension shape corresponding to the first reference dimension shape and the data type of the input image data to be repaired, the estimated data volume of the output repaired image data is determined.

[0282] In some embodiments, the product of the dimension values ​​of each dimension contained in the output dimension shape corresponding to the first reference dimension shape and the data volume of a single data point indicated by the data type of the input image data to be repaired is determined as the estimated data volume of the output repaired image data.

[0283] In some embodiments, before processing the input image data to be repaired through the image restoration model, a first instruction is sent to the memory. The first instruction is used to request memory space, and the amount of memory space is equal to the estimated amount of output image data after restoration.

[0284] Considering the problem that directly using the maximum dimension value of a variable dimension to estimate the output restored image data in related technologies can easily lead to memory waste, this application determines the smallest reference dimension shape (i.e., the first reference dimension shape) that is greater than or equal to the input dimension shape from at least one reference dimension shape, based on the variable dimension in the input dimension shape. The estimated data size of the output restored image data is then obtained through the output dimension shape of this first reference dimension shape. Compared to blindly determining the estimated data size directly based on the maximum dimension value, this application finds the smallest reference dimension shape that is greater than or equal to the input dimension shape from multiple reference dimension shapes to further determine the estimated data size. This makes the estimated data size more closely match the actual data size of the output restored image data, thus reducing memory waste.

[0285] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0286] Please refer to Figure 10 This illustrates a block diagram of a data volume determination apparatus provided in one embodiment of this application. Figure 10 As shown, the device 1000 may include: a shape acquisition module 1010, a shape determination module 1020, and a data volume estimation module 1030.

[0287] The shape acquisition module 1010 is used to acquire the input dimension shape of the input data. The input data is data processed by the neural network unit. The input data includes data of N dimensions. The input dimension shape includes the dimension values ​​corresponding to the N dimensions respectively. At least one of the N dimensions is a variable dimension, and N is a positive integer.

[0288] The shape determination module 1020 is used to determine a first reference dimension shape from at least one reference dimension shape based on the input dimension shape. The first reference dimension shape is the smallest reference dimension shape among the at least one reference dimension shapes that is greater than or equal to the input dimension shape. The determination of the at least one reference dimension shape is related to the at least one variable dimension.

[0289] The data volume estimation module 1030 is used to determine the estimated data volume of the output data based on the output dimension shape corresponding to the first reference dimension shape before processing the input data through the neural network unit to obtain the output data. The estimated data volume of the output data is used to determine the memory space configured for the output data.

[0290] In some embodiments, the number of variable dimensions is M, where M is a positive integer less than or equal to N.

[0291] In some embodiments, the shape determination module 1020 is configured to determine a first grid point from at least one grid point based on the dimension values ​​of the M variable dimensions included in the input dimension shape. The at least one grid point is determined by sampling from a dimension space formed by the dimension value intervals corresponding to the M variable dimensions, where the dimension value interval is the range of variation of the dimension values ​​of the variable dimensions, and different grid points in the at least one grid point indicate different dimension values ​​corresponding to the M variable dimensions. From the reference dimension shapes corresponding to the at least one grid point, the reference dimension shape corresponding to the first grid point is determined as the first reference dimension shape. The reference dimension shape corresponding to the grid point includes the different dimension values ​​indicated by the grid point corresponding to the M variable dimensions, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape.

[0292] In some embodiments, the shape determination module 1020 is configured to, for the i-th variable dimension among the M variable dimensions, determine the first sampling point of the input data in the i-th variable dimension based on the dimension value of the i-th variable dimension included in the input dimension shape and the sampling interval of the i-th variable dimension. The sampling point of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​of the i-th variable dimension and the number of sampling points of the i-th variable dimension. The sampling interval of the i-th variable dimension is determined based on the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. The module also determines the first grid point from the at least one grid point based on the first sampling points corresponding to the input dimension shape in the M variable dimensions.

[0293] In some embodiments, the shape determination module 1020 is configured to determine, based on the dimension value of the i-th variable dimension in the input dimension shape and the sampling interval of the i-th variable dimension, the smallest sampling point whose dimension value is greater than or equal to the dimension value of the i-th variable dimension in the input dimension shape and whose dimension value is the smallest; and to determine the smallest sampling point as the first sampling point of the input data in the i-th variable dimension.

[0294] In some embodiments, the shape determination module 1020 is used to obtain the maximum dimension value of the i-th variable dimension; divide the difference between the maximum dimension value of the i-th variable dimension and the dimension value of the i-th variable dimension in the input dimension shape by the sampling interval of the i-th variable dimension to obtain P sampling intervals, where i is an integer greater than or equal to 0; and determine the minimum sampling point among the multiple sampling points of the i-th variable dimension, with the maximum dimension value of the i-th variable dimension as the sampling starting point and spaced apart by the P sampling intervals.

[0295] In some embodiments, the shape determination module 1020 is configured to: determine the maximum and minimum dimension values ​​corresponding to the M variable dimensions based on the dimension value intervals corresponding to the M variable dimensions; construct the at least one grid point according to the maximum and minimum dimension values ​​corresponding to the M variable dimensions; construct grid point input data for each of the at least one grid point based on the reference dimension shape corresponding to the grid point; process the grid point input data through the neural network unit to obtain grid point output data; and determine the dimension values ​​of the grid point output data in each dimension as the output dimension shape corresponding to the reference dimension shape.

[0296] In some embodiments, the shape determination module 1020 is configured to, for the i-th variable dimension among the M variable dimensions, determine multiple sampling points for the i-th variable dimension based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points for the i-th variable dimension, wherein different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M; and construct the at least one grid point based on the multiple sampling points corresponding to the M variable dimensions, wherein each grid point is constructed from one sampling point corresponding to the M variable dimensions.

[0297] In some embodiments, the shape determination module 1020 is configured to determine the sampling interval of the i-th variable dimension based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension; and based on the sampling interval of the i-th variable dimension, starting from the maximum dimension value corresponding to the i-th variable dimension, sampling is performed between the maximum dimension value corresponding to the i-th variable dimension and the minimum dimension value corresponding to the i-th variable dimension to obtain multiple sampling points of the i-th variable dimension.

[0298] In some embodiments, the shape determination module 1020 is used to, for the kth sampling point among multiple sampling points of the i-th variable dimension, where k is an integer greater than or equal to 0, obtain the dimension value corresponding to the kth sampling point of the i-th variable dimension by taking the difference between the first data value and the second data value, where the first data value is the maximum dimension value corresponding to the i-th variable dimension, and the second data value is the product of the sampling interval of the i-th variable dimension and k.

[0299] In some embodiments, the shape determination module 1020 is used to obtain the total number of sampling points; and to determine the number of sampling points for the i-th variable dimension based on the result of taking the M-th power of the total number of sampling points.

[0300] In some embodiments, the shape determination module 1020 is configured to determine a reference dimension shape corresponding to the grid point based on the different dimension values ​​corresponding to the M variable dimensions indicated by the grid point, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape; determine data values ​​corresponding to the data type of the input data from a mapping table based on the data type of the input data, wherein the mapping table includes at least one set of data types and data values ​​with corresponding relationships; and construct the grid point input data based on the reference dimension shape corresponding to the grid point by using the data values ​​as the data values ​​of each data in the grid point input data.

[0301] In some embodiments, the data volume estimation module 1030 is used to obtain the data type of the input data; and determine the estimated data volume of the output data based on the output dimension shape corresponding to the first reference dimension shape and the data type of the input data.

[0302] In some embodiments, the data volume estimation module 1030 is used to determine the estimated data volume of the output data by multiplying the dimension values ​​of each dimension contained in the output dimension shape corresponding to the first reference dimension shape with the data volume of a single data indicated by the data type of the input data.

[0303] In some embodiments, such asFigure 11 As shown, the device also includes an instruction sending module 1040.

[0304] In some embodiments, the instruction sending module 1040 is configured to send a first instruction to a memory before processing the input data through the neural network unit. The first instruction is configured to request memory space, and the storage capacity of the memory space is equal to the estimated data volume of the output data.

[0305] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the content structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0306] Please refer to Figure 12 This illustration shows a schematic diagram of a computer device according to an embodiment of this application. The computer device can be any electronic device capable of data calculation, processing, and storage. Specifically, it may include the following:

[0307] The computer device 1200 includes a central processing unit (such as a CPU, GPU, or FPGA) 1201, a system memory 1204 including RAM (Random-Access Memory) 1202 and ROM (Read-Only Memory) 1203, and a system bus 1205 connecting the system memory 1204 and the central processing unit 1201. The computer device 1200 also includes a basic input / output system 1206 to facilitate information transfer between various devices within the server, and a large-capacity storage device 1207 for storing the operating system 1213, application programs 1214, and other program modules 1212.

[0308] The basic input / output system 1206 includes a display 1208 for displaying information and an input device 1209 for user input, such as a mouse or keyboard. Both the display 1208 and the input device 1209 are connected to the central processing unit 1201 via an input / output controller 1210 connected to the system bus 1205. The basic input / output system 1206 may also include the input / output controller 1210 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1210 also provides output to a display screen, printer, or other types of output devices.

[0309] The mass storage device 1207 is connected to the central processing unit 1201 via a mass storage controller (not shown) connected to the system bus 1205. The mass storage device 1207 and its associated computer-readable media provide non-volatile storage for the computer device 1200. That is, the mass storage device 1207 may include computer-readable media (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.

[0310] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer storage medium is not limited to the above-mentioned types. The system memory 1204 and mass storage device 1207 described above can be collectively referred to as memory.

[0311] According to an embodiment of this application, the computer device 1200 can also be connected to a remote computer on a network, such as the Internet. That is, the computer device 1200 can be connected to the network 1212 via the network interface unit 1211 connected to the system bus 1205, or the network interface unit 1211 can be used to connect to other types of networks or remote computer systems (not shown).

[0312] The memory also includes a computer program stored in the memory and configured to be executed by one or more processors to implement the above-described data volume determination method.

[0313] In an exemplary embodiment, a computer-readable storage medium is also provided, wherein a computer program is stored in the storage medium, and the computer program, when executed by a processor, implements the above-described data volume determination method. Optionally, the computer-readable storage medium may include: ROM (Read-Only Memory), RAM (Random Access Memory), SSD (Solid State Drives), or optical disc, etc. The random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).

[0314] In an exemplary embodiment, a computer program product is also provided, the computer program product including a computer program stored in a computer-readable storage medium. A processor of a terminal device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the terminal device to perform the aforementioned data volume determination method.

[0315] It should be noted that the collection and processing of relevant data (including input data, etc.) in this application should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.

[0316] It should be understood that "multiple" as used herein refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the step numbers described herein are merely illustrative of one possible execution order. In some other embodiments, the steps may not be executed in numerical order, such as two steps with different numbers being executed simultaneously, or two steps with different numbers being executed in the reverse order of the illustration. This application does not limit this.

[0317] The above description is merely an exemplary embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for determining data volume, characterized in that, The method includes: Obtain the input dimension shape of the input data, wherein the input data is data processed by the neural network unit, the input data includes data of N dimensions, the input dimension shape includes the dimension values ​​corresponding to the N dimensions respectively, and at least one variable dimension exists among the N dimensions, where N is a positive integer; Based on the input dimension shape, a first reference dimension shape is determined from at least one reference dimension shape, wherein the first reference dimension shape is the smallest reference dimension shape among the at least one reference dimension shapes that is greater than or equal to the input dimension shape, and the determination of the at least one reference dimension shape is related to the at least one variable dimension. Before processing the input data through the neural network unit to obtain the output data, the estimated data volume of the output data is determined based on the output dimension shape corresponding to the first reference dimension shape. The estimated data volume of the output data is used to determine the memory space configured for the output data.

2. The method according to claim 1, characterized in that, The number of the variable dimensions is M, where M is a positive integer less than or equal to N; Determining a first reference dimension shape from at least one reference dimension shape based on the input dimension shape includes: Based on the dimension values ​​of the M variable dimensions included in the input dimension shape, a first grid point is determined from at least one grid point. The at least one grid point is determined by sampling from the dimension space formed by the dimension value intervals corresponding to the M variable dimensions respectively. The dimension value interval is the range of variation of the dimension values ​​of the variable dimensions. Different grid points in the at least one grid point indicate different dimension values ​​corresponding to the M variable dimensions respectively. From the reference dimension shapes corresponding to the at least one grid point, the reference dimension shape corresponding to the first grid point is determined as the first reference dimension shape. The reference dimension shape corresponding to the grid point includes the different dimension values ​​indicated by the grid point corresponding to the M variable dimensions, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape.

3. The method according to claim 2, characterized in that, Determining a first grid point from at least one grid point based on the dimension values ​​of the M variable dimensions included in the input dimension shape includes: For the i-th variable dimension among the M variable dimensions, the first sampling point of the input data in the i-th variable dimension is determined according to the dimension value of the i-th variable dimension included in the shape of the input dimension and the sampling interval of the i-th variable dimension. The sampling point of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​of the i-th variable dimension and the number of sampling points of the i-th variable dimension. The sampling interval of the i-th variable dimension is determined based on the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. The first grid point is determined from the at least one grid point based on the first sampling points corresponding to the M variable dimensions of the input dimension shape.

4. The method according to claim 3, characterized in that, Determining the first sampling point of the input data in the i-th variable dimension based on the dimension value of the i-th variable dimension included in the input dimension shape and the sampling interval of the i-th variable dimension includes: Based on the dimension value of the i-th variable dimension in the input dimension shape and the sampling interval of the i-th variable dimension, determine the smallest sampling point from multiple sampling points of the i-th variable dimension whose dimension value is greater than or equal to the dimension value of the i-th variable dimension in the input dimension shape and whose dimension value is the smallest. The minimum sampling point is determined as the first sampling point of the input data in the i-th variable dimension.

5. The method according to claim 4, characterized in that, The step of determining the smallest sampling point from multiple sampling points of the i-th variable dimension, based on the dimension value of the i-th variable dimension in the input dimension shape and the sampling interval of the i-th variable dimension, where the dimension value is greater than or equal to the dimension value of the i-th variable dimension in the input dimension shape and the smallest dimension value, includes: Obtain the maximum dimension value of the i-th variable dimension; The difference between the maximum dimension value of the i-th variable dimension and the dimension value of the i-th variable dimension in the input dimension shape is divided by the sampling interval of the i-th variable dimension to obtain P sampling intervals, where i is an integer greater than or equal to 0. Among the multiple sampling points of the i-th variable dimension, the sampling point with the maximum dimension value of the i-th variable dimension as the sampling starting point and separated by P sampling intervals is determined as the minimum sampling point.

6. The method according to any one of claims 2 to 5, characterized in that, The method further includes: Based on the dimension value ranges corresponding to the M variable dimensions, determine the maximum and minimum dimension values ​​corresponding to the M variable dimensions respectively; Construct the at least one grid point based on the maximum and minimum dimension values ​​corresponding to the M variable dimensions; For each of the at least one grid point, grid point input data is constructed based on the reference dimension shape corresponding to the grid point; The grid point input data is processed by the neural network unit to obtain the grid point output data; The dimension values ​​of the grid point output data in each dimension are determined as the output dimension shape corresponding to the reference dimension shape.

7. The method according to claim 6, characterized in that, The step of constructing the at least one grid point based on the maximum and minimum dimension values ​​corresponding to the M variable dimensions includes: For the i-th variable dimension among the M variable dimensions, multiple sampling points of the i-th variable dimension are determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension. Different sampling points correspond to different dimension values, and i is a positive integer less than or equal to M. Based on the multiple sampling points corresponding to the M variable dimensions, at least one grid point is constructed, and each grid point is constructed from one sampling point corresponding to the M variable dimensions.

8. The method according to claim 7, characterized in that, The step of determining multiple sampling points for the i-th variable dimension based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points for the i-th variable dimension includes: The sampling interval of the i-th variable dimension is determined based on the maximum and minimum dimension values ​​corresponding to the i-th variable dimension and the number of sampling points of the i-th variable dimension. Based on the sampling interval of the i-th variable dimension, starting from the maximum dimension value corresponding to the i-th variable dimension, sampling is performed between the maximum dimension value corresponding to the i-th variable dimension and the minimum dimension value corresponding to the i-th variable dimension to obtain multiple sampling points of the i-th variable dimension.

9. The method according to any one of claims 6 to 8, characterized in that, The method further includes: For the kth sampling point among multiple sampling points of the i-th variable dimension, where k is an integer greater than or equal to 0, the difference between the first data value and the second data value is used to obtain the dimension value corresponding to the kth sampling point of the i-th variable dimension. The first data value is the maximum dimension value corresponding to the i-th variable dimension, and the second data value is the product of the sampling interval of the i-th variable dimension and k.

10. The method according to any one of claims 6 to 9, characterized in that, The method further includes: Get the total number of sampling points; The number of sampling points for the i-th variable dimension is determined based on the result obtained by taking the M-th power of the total number of sampling points.

11. The method according to any one of claims 6 to 10, characterized in that, The process of constructing grid point input data based on the reference dimension shape corresponding to the grid points includes: Based on the different dimension values ​​corresponding to the M variable dimensions indicated by the grid points, and the dimension values ​​corresponding to the NM fixed dimensions included in the input dimension shape, determine the reference dimension shape corresponding to the grid points. Based on the data type of the input data, the data value corresponding to the data type of the input data is determined from the mapping table, wherein the mapping table includes at least one set of data types and data values ​​with corresponding relationships; The data values ​​are used as the data values ​​of each data in the grid point input data, and the grid point input data is constructed based on the reference dimension shape corresponding to the grid point.

12. The method according to any one of claims 1 to 11, characterized in that, The step of determining the estimated data volume of the output data based on the output dimension shape corresponding to the first reference dimension shape includes: Obtain the data type of the input data; Based on the output dimension shape corresponding to the first reference dimension shape and the data type of the input data, the estimated data volume of the output data is determined.

13. The method according to claim 12, characterized in that, The step of determining the estimated data volume of the output data based on the output dimension shape corresponding to the first reference dimension shape and the data type of the input data includes: The estimated data volume of the output data is determined by multiplying the dimension values ​​of each dimension contained in the output dimension shape corresponding to the first reference dimension shape with the data volume of a single data item indicated by the data type of the input data.

14. The method according to claim 12 or 13, characterized in that, The method further includes: Before processing the input data through the neural network unit, a first instruction is sent to the memory, the first instruction being used to request the memory space, the storage capacity of the memory space being equal to the estimated data volume of the output data.

15. A data volume determination device, characterized in that, The device includes: The shape acquisition module is used to acquire the input dimension shape of the input data. The input data is data processed by the neural network unit. The input data includes data in N dimensions. The input dimension shape includes the dimension values ​​corresponding to the N dimensions respectively. At least one of the N dimensions is a variable dimension, and N is a positive integer. A shape determination module is used to determine a first reference dimension shape from at least one reference dimension shape based on the input dimension shape. The first reference dimension shape is the smallest reference dimension shape among the at least one reference dimension shapes that is greater than or equal to the input dimension shape. The determination of the at least one reference dimension shape is related to the at least one variable dimension. The data volume estimation module is used to determine the estimated data volume of the output data based on the output dimension shape corresponding to the first reference dimension shape before processing the input data through the neural network unit to obtain the output data. The estimated data volume of the output data is used to determine the memory space configured for the output data.

16. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program that is loaded and executed by the processor to implement the data volume determination method as described in any one of claims 1 to 14.

17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the data volume determination method as described in any one of claims 1 to 14.

18. A computer program product, characterized in that, The computer program product includes a computer program that is loaded and executed by a processor to implement the data volume determination method as described in any one of claims 1 to 14.