Processing method and device of a computation graph, equipment and storage medium
By using static bucketing compilation, the dynamic shape computation graph is bucketed, which solves the problem of high processor overhead and improves the execution efficiency of the computation graph.
Patent Information
- Application Number
- CN202411983319.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-28
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2044-12-28
AI Technical Summary
Existing technologies result in high processor overhead and low execution efficiency when processing dynamic shape computation graphs.
By using static bucketing compilation, the range of values for dynamic input is divided into buckets to generate multiple buckets. Static compilation is then performed based on the values in each bucket to obtain the compilation results. Finally, the computation graph is executed after the input data is obtained.
It effectively saves processor overhead, improves the execution efficiency of the computation graph, avoids the resource consumption of recompiling after each acquisition of input data, and shortens the execution time.
Smart Images

Figure CN119902771B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Internet, in particular to the technical field of artificial intelligence, and especially relates to a computation graph processing method and device, equipment and storage medium. BACKGROUND
[0002] With the development of artificial intelligence (AI) technology, computation graphs have been widely applied. A computation graph is a graph structure used to represent mathematical calculations or program execution, which is particularly important in the implementation of AI models and can be used to describe the computation process in an AI model. The input of a computation graph can adopt a dynamic shape, which means that the shape of the data input to the computation graph each time is not fixed, i.e., the computation graph can support inputting data of multiple shapes. Such a computation graph can be referred to as a dynamic shape graph.
[0003] For a dynamic shape graph, a common processing method is to compile and execute, i.e., to pre-compile the dynamic shape graph to obtain a compiled result supporting dynamic input, so that when the dynamic shape graph needs to be executed, the input data of the dynamic shape graph is obtained and the dynamic shape graph is executed based on the compiled result. Since the shape of the data input each time is often different, such a processing method is prone to cause a large overhead of the processor and result in low execution efficiency. SUMMARY
[0004] The embodiments of the present application provide a computation graph processing method, device, equipment and storage medium, which can save the overhead of the processor and improve the execution efficiency of the computation graph.
[0005] In one aspect, the embodiments of the present application provide a computation graph processing method, which comprises:
[0006] obtaining a computation graph, the computation graph comprising P dynamic inputs, P being a positive integer; wherein each dynamic input has a dynamic shape, and each dynamic shape has a value range;
[0007] obtaining a bucketing mark of the computation graph, the bucketing mark being used to indicate the group to which each dynamic input belongs and the bucketing manner of each group; wherein the dynamic shapes of the dynamic inputs in the same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed according to the bucketing manner of the corresponding group;
[0008] perform bucketing on the value ranges of the dynamic shapes of the P dynamic inputs according to the indication of the bucketing mark, to obtain a plurality of buckets; each bucket includes P values, and different values in the P values are selected from different value ranges;
[0009] perform static compilation on the computation graph based on the values in each bucket, to obtain a corresponding compilation result of each bucket;
[0010] after obtaining input data of the computation graph, execute the computation graph on the input data based on the corresponding compilation results of the plurality of buckets, to obtain a data computation result of the input data.
[0011] In another aspect, an embodiment of the present application provides a processing apparatus of a computation graph, the apparatus comprising:
[0012] an obtaining unit configured to obtain a computation graph, the computation graph comprising P dynamic inputs, P being a positive integer; wherein each dynamic input has a dynamic shape, and each dynamic shape has a value range;
[0013] the obtaining unit is further configured to obtain a bucketing mark of the computation graph, the bucketing mark being used to indicate: a group to which each dynamic input belongs, and a bucketing manner of each group; wherein the dynamic shapes of the dynamic inputs in a same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed according to the bucketing manner of the corresponding group;
[0014] a processing unit configured to perform bucketing on the value ranges of the dynamic shapes of the P dynamic inputs according to the indication of the bucketing mark, to obtain a plurality of buckets; each bucket includes P values, and different values in the P values are selected from different value ranges;
[0015] the processing unit is further configured to perform static compilation on the computation graph based on the values in each bucket, to obtain a corresponding compilation result of each bucket;
[0016] the processing unit is further configured to, after obtaining input data of the computation graph, execute the computation graph on the input data based on the corresponding compilation results of the plurality of buckets, to obtain a data computation result of the input data.
[0017] In still another aspect, an embodiment of the present application provides a computer device, the computer device comprising an input interface and an output interface, and further comprising:
[0018] a processor and a computer storage medium;
[0019] The processor is adapted to implement one or more instructions, the computer storage medium stores one or more instructions, and the one or more instructions are adapted to be loaded and executed by the processor to implement the processing method of the computing graph mentioned above.
[0020] In another aspect, the embodiments of the present application provide a computer storage medium, which stores one or more instructions, and the one or more instructions are adapted to be loaded and executed by a processor to implement the processing method of the computing graph mentioned above.
[0021] In another aspect, the embodiments of the present application provide a computer program product, which includes one or more instructions; when the one or more instructions in the computer program product are executed by a processor, the processing method of the computing graph mentioned above is implemented.
[0022] The embodiments of the present application can obtain a computing graph including P dynamic inputs and a bucketing mark of the computing graph, the bucketing mark is used to indicate a group to which each dynamic input belongs and a bucketing manner of each group, the dynamic shapes of the dynamic inputs in the same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed according to the bucketing manner of the corresponding group. It can be seen that, by setting the bucketing mark in the form of grouping, the value range of the dynamic shape of each dynamic input in the same group can be recorded by using one piece of information, so that some memory can be avoided to record the bucketing manner of the value range of the dynamic shape of each dynamic input, thereby effectively saving the memory of the processor. Further, before executing the computing graph, the value ranges of the dynamic shapes of the P dynamic inputs can be processed according to the indication of the bucketing mark to obtain a plurality of buckets, and the computing graph is statically compiled based on the values in each bucket, so that after obtaining the input data of the computing graph, the input data is executed on the computing graph based on the compilation results corresponding to the plurality of buckets to obtain the data calculation result of the input data, so that the situation that the processor resources are consumed to compile the computing graph every time the input data is obtained can be avoided, thereby effectively saving the overhead generated by the processor and shortening the execution time of the computing graph, and further improving the execution efficiency of the computing graph. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0024] Figure 1is a process schematic diagram of a method for processing a computation graph provided by an embodiment of the present application;
[0025] Figure 2 is a process schematic diagram of a method for processing a computation graph provided by an embodiment of the present application;
[0026] Figure 3 is a schematic diagram of a bucket processing provided by an embodiment of the present application;
[0027] Figure 4 is a process schematic diagram of a method for processing a computation graph provided by another embodiment of the present application;
[0028] Figure 5a is a schematic diagram of augmented data provided by an embodiment of the present application;
[0029] Figure 5b is a schematic diagram of augmented data and corresponding data computation results provided by an embodiment of the present application;
[0030] Figure 5c is a process schematic diagram of generating a target shape computation formula provided by an embodiment of the present application;
[0031] Figure 5d is another process schematic diagram of generating a target shape computation formula provided by an embodiment of the present application;
[0032] Figure 5e is a framework schematic diagram of a method for processing a computation graph provided by an embodiment of the present application;
[0033] Figure 6 is a structure schematic diagram of a processing apparatus for a computation graph provided by an embodiment of the present application;
[0034] Figure 7 is a structure schematic diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0035] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
[0036] In the embodiments of the present application, the computation graph is a graph structure that can be used to describe the computation process in the AI model. The AI model here refers to a model constructed based on AI technology, and the AI technology refers to the theory, method, technology and application system for simulating, extending and expanding human intelligence using a digital computer or a machine controlled by a digital computer to perceive the environment, acquire knowledge and use knowledge to obtain the best results. For example, the AI model can be, for example, a general neural network model (such as a convolutional neural network model), a large model, etc. The so-called large model can be a large language model (Large Language Model), which specifically refers to a deep neural network with large parameters.
[0037] Specifically, the computation graph can include but is not limited to Q input nodes, R operator nodes, and at least one output node, Q and R being positive integers. The input node is used to represent the input of the computation graph, which can be responsible for inputting the data to be calculated into the computation graph; the operator node is used to represent an operator, which is a general term for a certain mathematical operation, and an operator can represent at least one operation in a network layer in the AI model; the output node is used to represent the output of the computation graph, which is responsible for outputting the execution result of the computation graph (i.e., the data calculation result obtained after calculating the input data). As can be seen, the computation graph can include Q inputs, R operators, and at least one output.
[0038] In addition, the input and output of the computation graph can each have a shape. The shape of the input specifically refers to the shape of the data supported by the input, and the shape of the output specifically refers to the shape of the data supported by the output. The shape is an array used to represent the composition structure of the data, which can specifically include at least one dimension value to describe the size (number of data elements) of the data in at least one dimension in a multi-dimensional space. The data here can be, for example, an image, a voice, a text, etc., which is not limited. For example, the shape of data A is <23xf32>, which can represent that data A is a one-dimensional data with 1 dimension in a multi-dimensional space and contains 23 data elements in the dimension, and each data element has a format of f32 (i.e., 32-bit floating point number). For example, the shape of data B is <23x10xf32>, which can represent that data B is a two-dimensional data with 2 dimensions in a multi-dimensional space, and contains 23 data elements in the first dimension and 10 data elements in the second dimension, and each data element has a format of f32.
[0039] Further, the shape described above can be specifically divided into dynamic shape and static shape. The dynamic shape refers to a shape containing dynamic dimensions, and the static shape refers to a shape not containing dynamic dimensions. The dynamic dimension is a dimension whose index value supports dynamic change, that is, the value of the dynamic dimension is unknown, and a target value (such as -1) can be used in the shape to represent the unknown value. That is, when the value of one or more dimensions in the shape is -1, it means that the value of these dimensions is unknown and can dynamically change. These dimensions can be referred to as dynamic dimensions, and the shape in this case can be referred to as a dynamic shape. For example, the shape [-1, 30] is a dynamic shape. Correspondingly, when the value of each dimension in the shape is not -1, it means that the value of each dimension is known and fixed. The shape in this case is a static shape. For example, the shape [1, 30] is a static shape.
[0040] Based on the classification of the shape described above, the computation graph can be specifically divided into a dynamic shape graph (dynamic computation graph) and a static shape graph (static computation graph). The dynamic shape graph refers to a computation graph in which at least one input shape is a dynamic shape. That is, when the computation graph has at least one input shape that is a static shape, the computation graph can be referred to as a dynamic shape graph. Correspondingly, the static shape graph refers to a computation graph in which each input shape is a static shape. That is, when the computation graph has each input shape that is a static shape, the computation graph can be referred to as a static shape graph. It should be noted that, for convenience of description, the input with the dynamic shape will be referred to as a dynamic input, and the input with the static shape will be referred to as a static input. In addition, the dynamic shape of each dynamic input has its own value range.
[0041] In an AI scenario, for a dynamic shape graph, since the shape of the input involved each time of execution is often different, this easily leads to the need to add many additional judgments in the implementation process of the operators in the dynamic shape graph; and most of the operators supporting multiple inputs usually have requirements on the shape of each input, for example, the add operator, which requires the shapes of the two inputs to be the same, or the shape of one input can be changed to be the same as the shape of the other input through broadcasting, which easily leads to the need to add and process some shape calculation related operators in addition to the operators in the computation graph in the actual calculation to ensure correctness. However, for a static shape graph, since the shape of the input of each operator is known, the foregoing two additional overheads (i.e., the overheads required for additional judgments and the overheads required for processing additional operators) involved in the execution of the dynamic shape graph are not needed, which can make the running time of the static shape graph much faster than that of the dynamic shape graph, i.e., the execution efficiency of the static shape graph is higher than that of the dynamic shape graph.
[0042] Research shows that: for a dynamic shape graph and a static shape graph with the same calculation logic, if the shape of the input data of the dynamic shape graph is expanded to be the same as the shape of the input of the static shape graph when the dynamic shape graph needs to be executed, the static shape graph is executed using the expanded input data, and the corresponding output shape of the input data is predicted according to the shape of the input data (i.e., the shape of the data calculation result obtained after the calculation of the dynamic shape graph), and the data calculation result of the input data is extracted from the execution result of the static shape graph based on the predicted output shape, which can make the extracted data calculation result consistent with the data calculation result calculated through the dynamic shape graph.
[0043] For example, if a dynamic shape graph has two inputs and the shapes of the two inputs are <-1xf32> and <-1xf32> respectively, where the value range of the dimension of -1 is [1, 10]; in addition, there is a static shape graph also having two inputs and the shapes of the two inputs are <10xf32> and <10xf32> respectively; and the calculation logic in the dynamic shape graph and the static shape graph is add. When the dynamic shape graph needs to be executed, the shape of the input data of the dynamic shape graph can be expanded to <10xf32>, and the static shape graph is executed using the expanded input data, the predicted output shape is obtained according to the shape of the actual input data, and the data calculation result of the input data is extracted from the execution result of the static shape graph according to the predicted output shape, so that the extracted data calculation result is consistent with the data calculation result obtained by calculating the input data through the dynamic shape graph.
[0044] Based on the above research results, the embodiments of the present application propose a processing method of a calculation graph for a dynamic shape graph, which can accelerate the execution of the dynamic shape graph through a static bucketing compilation manner. The static bucketing compilation manner refers to performing bucketing processing on the value range of the dynamic shape possessed by at least one input of the dynamic shape graph to obtain a plurality of buckets, each of which includes at least one numerical value and different numerical values are selected from the value range of different dynamic shapes, and performing static compilation on the dynamic shape graph based on the numerical values in each bucket to obtain the compilation result corresponding to each bucket. It can be understood that static compilation refers to compilation using a static shape. Based on this definition, the principle of performing static compilation on the dynamic shape graph based on the numerical values in any bucket is roughly as follows: determining the specific values of each dimension in the dynamic shape possessed by at least one input of the dynamic shape graph based on the numerical values in any bucket to obtain the static shape of the corresponding bucket, so as to compile the dynamic shape graph using the static shape of the bucket.
[0045] Specifically, the method can compile the dynamic shape graph in advance by a static bucketing compilation manner before executing the dynamic shape graph, to obtain a plurality of bucket corresponding compilation results, different compilation results correspond to different static shapes of the buckets, so that after obtaining the actual input data of the dynamic shape graph, one of the compilation results can be selected as a target compilation result, the static shape corresponding to the target compilation result is greater than or equal to the shape of the actual input data, and the dynamic shape graph is executed based on the target compilation result to convert the input of the dynamic shape into the input of the static shape, and convert the execution of the dynamic shape graph into the execution of the static shape, so as to accelerate the execution of the dynamic shape graph, improve the execution efficiency of the dynamic shape graph, and avoid the additional overhead introduced by the dynamic shape processing, thereby saving the overhead of the processor and improving the running efficiency of the processor. It can be understood that any compilation result can be understood as an executable and shape known dynamic shape graph, and the known shape is the static shape corresponding to the compilation result. Therefore, when the dynamic shape graph is executed based on any compilation result, the actual input data is executed using the corresponding compilation result.
[0046] The above method will be described in detail below Figure 1 with a specific example to illustrate the general process of executing the dynamic shape graph by the static bucketing compilation manner.
[0047] Suppose a dynamic shape graph has at least two inputs with dynamic shapes, such as the dynamic shape of Arg0 (the first input) is <-1x1x16xf32> and the dynamic shape of Arg1 (the second input) is <-1x1280xf32>, and the value range of the first dimension in these dynamic shapes is 1-100. If the value range is processed by adopting an exponential bucketing strategy with a base of 2, 1, 2, 4, 8, …, 64, and 100 can be selected as the values in different buckets to obtain a plurality of buckets, and the values in each bucket can be selected as the actual value (specific value) of the dynamic value of the first dimension in the dynamic shape of each input to obtain the static shape of each bucket, such as the static shape of the first bucket includes <1x1x16xf32> corresponding to Arg0 and <1x1280xf32> corresponding to Arg1, and the static shape of the second bucket includes <2x1x16xf32> corresponding to Arg0 and <2x1280xf32> corresponding to Arg1.
[0048] Further, the dynamic shape graph can be statically compiled based on the static shape of each bucket respectively to obtain a corresponding compilation result of each bucket; and in actual running, according to the shape size of each actual input data, the compilation result corresponding to the bucket with the static shape closest to and not less than the shape of the actual input data is selected to execute to obtain the data calculation result of the actual input data. For example, if the value of the first dimension in the shape of the actual input data is 5, i.e., the shape of the actual input data includes <5x1x16xf32> corresponding to Arg0, <5x1280xf32> corresponding to Arg1, etc., it can be determined that the static shape (<8x1x16xf32>, <8x1280xf32>, etc.) of the compilation result corresponding to the bucket containing the value 8 is closest to and not less than the shape of the actual input data, and therefore the compilation result corresponding to the bucket containing the value 8 can be selected to execute to obtain the data calculation result of the actual input data. Similarly, if the value of the first dimension in the shape of the actual input data is 1, i.e., the shape of the actual input data includes <1x1x16xf32> corresponding to Arg0, <1x1280xf32> corresponding to Arg1, etc., the compilation result corresponding to the bucket containing the value 1 can be selected to execute; if the value of the first dimension in the shape of the actual input data is 3, i.e., the shape of the actual input data includes <3x1x16xf32> corresponding to Arg0, <3x1280xf32> corresponding to Arg1, etc., the compilation result corresponding to the bucket containing the value 4 can be selected to execute, and so on.
[0049] Based on the above description, the following points need to be explained:
[0050] (1) The method proposed in the embodiments of the present application can convert the calculation of the dynamic shape graph into the calculation of the static shape graph, thereby effectively reducing the processor overhead in the running of the dynamic shape graph, and further improving the running efficiency of the processor. Although the bucketing processing itself may bring some redundant calculation, by reasonably performing the bucketing, the overhead of the redundant calculation can be reduced, and the execution efficiency of the dynamic shape graph can be ultimately improved.
[0051] (2) The application embodiments do not limit the application scenarios of the methods proposed by the application embodiments, that is, the methods proposed by the application embodiments can be applied to various AI scenarios. For example, in the inference scenario, multiple input data are often grouped into a batch, that is, a batch contains multiple input data, and a batch is provided to a neural network model for execution; since the number of input data contained in a batch is often not fixed, from the perspective of execution of the calculation graph corresponding to the neural network model, it can be considered that this is a case of dynamic shape of input, and the number of input data contained in the batch usually has a value range, so the method proposed by the application embodiments can be used to accelerate the execution of the corresponding calculation graph. For another example, in the large model scenario, the number of tokens (the smallest unit or basic element of text processing, such as a word, a phrase, a punctuation mark, or a character) in the input text is also often not fixed, but there is often an upper limit, so this scenario also belongs to a case where the input of the calculation graph corresponding to the large model has a dynamic shape and the dynamic shape has a value range, so the method proposed by the application embodiments can be used to accelerate the execution of the corresponding calculation graph.
[0052] (3) The application embodiments do not limit the execution subject of the methods proposed by the application embodiments. For example, the method proposed by the application embodiments can be executed by a computer device, which can be a terminal or a server; or the method proposed by the application embodiments can also be executed by a terminal and a server together, which is not limited. The terminal can be a smartphone, a computer (such as a tablet computer, a notebook computer, a desktop computer, etc.), a smart wearable device (such as a smart watch, smart glasses), a smart voice interaction device, a smart home appliance (such as a smart television), a vehicle-mounted terminal, or an aircraft, etc.; the server can be a standalone physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs (Content Delivery Networks), and basic cloud computing services such as big data and artificial intelligence platforms, etc.
[0053] (4) In the application embodiments, if related data such as user information is involved, when any method embodiment proposed by the application embodiments is applied to a specific product or technology, these related data are collected with the consent or agreement of the user, and the collection, use, and processing of the related data comply with relevant laws, regulations, and standards in the relevant region.
[0054] The following will be described in detail with reference to the accompanying drawings. Figure 2The method flowchart shown illustrates the specific implementation process of the processing method of the calculation graph proposed in the embodiments of the present application. In the embodiments of the present application, the processing method of the calculation graph executed by the computer device is taken as an example for illustration. Please refer to Figure 2 As shown, the processing method of the calculation graph can generally include S201-S205:
[0055] S201, obtaining a calculation graph.
[0056] In the embodiments of the present application, the calculation graph obtained through step S201 specifically refers to a dynamic shape graph (i.e. a dynamic calculation graph). The calculation graph can include a plurality of nodes, and the plurality of nodes can specifically include P input nodes, R operator nodes and at least one output node, P and R are both positive integers; wherein one input node represents a dynamic input of the calculation graph, one operator node represents an operator in the calculation graph, and one output node represents an output of the calculation graph.
[0057] It can be seen that the calculation graph mentioned in the embodiments of the present application can include P dynamic inputs. It can be understood that the calculation graph can include a total of Q input nodes (Q is a positive integer), and the P input nodes mentioned above for representing P dynamic inputs belong to all or part of the Q input nodes, that is, the calculation graph can include a total of Q inputs (Q is a positive integer), if each of the Q inputs is a dynamic input, then in this case, P=Q (i.e. the value of P is equal to the total number of inputs included in the calculation graph); or, if there are some inputs that are dynamic inputs and some inputs that are static inputs among the Q inputs included in the calculation graph, then in this case, P<Q (the value of P is less than the total number of inputs included in the calculation graph).
[0058] Each dynamic input has a dynamic shape, and the dynamic shape of any dynamic input can include numerical values of N dimensions, and there are dynamic dimensions (i.e. dimensions whose numerical values support dynamic changes) among the N dimensions, and N is a positive integer. It can be understood that the number of dimensions (i.e. the value of N) in the dynamic shape of different dynamic inputs can be the same or different, which is not limited. For example, the dynamic shape of the first dynamic input includes numerical values of 3 dimensions (i.e. the number of dimensions in the first dynamic shape is 3), and the dynamic shape of the second dynamic input includes numerical values of 1 dimension (i.e. the number of dimensions in the dynamic shape of the second dynamic input is 1, in this case, the number of dimensions in the first dynamic input is different from the number of dimensions in the second dynamic input.
[0059] Furthermore, each dynamic shape has a value range. Specifically, the value range of a dynamic shape may refer to: the value range of the dynamic dimension in the dynamic shape; for example, if the dynamic shape is <-1x10xf32>, where the dynamic dimension is the first dimension and the value range of the first dimension is 0-100, then the value range of the dynamic shape is 0-100. Alternatively, the value range of a dynamic shape may refer to: a range consisting of multiple preset static shapes, where any static shape in the range is obtained by setting the value of the dynamic dimension in the dynamic shape to the preset value; for example, if the dynamic shape is still <-1x10xf32>, the preset values may include 1, 5, 8, 10, etc., then the value range of the dynamic shape may include the following static shapes: <1x10xf32>, <5x10xf32>, <8x10xf32>, <10x10xf32>, etc.
[0060] S202: Obtain the bucket labels of the computation graph.
[0061] For a given computation graph (dynamic shape graph), in order to accelerate the execution of the computation graph using static bucket compilation, it is necessary to obtain the computation graph's bucket mark. This bucket mark allows us to know the bucketing method for the value range of the dynamic shape of each dynamic input of the computation graph, so that we can subsequently accurately bucket the value range of each dynamic shape based on the corresponding bucketing method.
[0062] In a specific implementation, the embodiment of the present application proposes a bucket marking method for shape groups to simply and efficiently mark how to bucket the value ranges of each dynamic input dynamic shape of a dynamic shape map. Specifically, the principle of the bucket marking method is as follows:
[0063] S11, grouping each dynamic input based on the value range of the dynamic shape of each dynamic input to obtain the group to which each dynamic input belongs. Specifically, dynamic inputs corresponding to dynamic shapes with the same value range may be grouped together to obtain the group to which each dynamic input belongs.
[0064] s12, respectively, configure a bucketing manner for each group. Specifically, for any group, a bucketing manner can be configured for the group based on business requirements or experience values. The bucketing manner can be, for example, an exponential bucketing manner with a first value (such as value 2) as the base, a multiple bucketing manner with a second value (such as value 5) as the reference, and the like. Alternatively, a bucketing manner can also be configured for the corresponding group based on the historical value distribution of the dynamic shape of each dynamic input in the group, so that after subsequent bucketing processing of the value range of the dynamic shape of the corresponding dynamic input based on the bucketing manner, the values in each bucket obtained are historical frequently occurring values, so that the static shape determined based on the values in each bucket is a historical frequently occurring shape, which is most likely the same or similar to the shape of the actual input data of the computational graph. This can to some extent reduce the subsequent expansion of the input data due to shape differences and the like, thereby saving the processing resources of the processor and improving the performance of the processor.
[0065] s13, generate the bucketing mark of the computational graph based on the group to which each dynamic input belongs and the bucketing manner of each group. Specifically, the group mark of each dynamic input can be obtained by marking the corresponding dynamic input based on the group to which each dynamic input belongs, and the attribute mark of each group can be obtained by marking the corresponding group based on the bucketing manner of each group, so as to construct the bucketing mark of the computational graph by using the group mark of each dynamic input and the attribute mark of each group.
[0066] Based on the above description of s11-s13, it can be seen that the bucketing mark generated by the bucketing marking method of the shape group can be used to indicate the group to which each dynamic input belongs and the bucketing manner of each group. Specifically, it can include the group mark of each dynamic input and the attribute mark of at least one group. Among them, the dynamic shape of each dynamic input in the same group has the same value range, and the value range of the dynamic shape of each dynamic input is processed by the bucketing manner of the corresponding group. It can be seen that the present application embodiment can record the bucketing manner of the value range of the dynamic shape of each dynamic input in the same group by using one piece of information, which can avoid occupying some memory to record the bucketing manner of the value range of the dynamic shape of each dynamic input, thereby effectively saving the memory of the processor.
[0067] The group to which the dynamic input belongs can refer to a group to which a dynamic dimension in a dynamic shape of the dynamic input belongs. In this case, the group attribute of the dynamic input is used to indicate the dynamic dimension in the dynamic shape of the dynamic input and the group to which the corresponding dynamic dimension belongs. For example, the group attribute of the dynamic input can include but is not limited to at least one of the following information: a node identifier (such as a node name) used to represent an input node of the dynamic input, output information of the input node, a dynamic shape, and a group to which a dynamic dimension in the dynamic shape belongs, and the like. For example, the group attribute of the dynamic input can represent the following:
[0068] {name: NODE_NAME, index: 0, shape: {-1, 10}, shape_group: {0, -1}}
[0069] name: represents a node name field, used to store a node name of an input node.
[0070] index: represents an output sequence number field, used to store a sequence number of an output of the input node, to indicate the first output of the input node by the stored value, and index: 0 represents the first output.
[0071] shape: represents a shape field, used to store a shape of an output of the input node; where -1 represents that a value of a dimension in which the input node is located is dynamically changed, and other values represent that a value of a dimension in which the input node is located is statically unchanged. It can be understood that, for a computation graph, data output by the input node is input data of the computation graph, and therefore the shape of the output of the input node is the shape of the input of the computation graph.
[0072] shape_group: represents a group field, used to store grouping information of the shape, which specifically includes grouping indication values of each dimension in the shape; where when the grouping indication value of any dimension is a specified value (such as -1), it represents that the dimension is not grouped, and when the grouping indication value of any dimension is a non-specified value (that is, a value other than the specified value), it represents a group to which the dimension belongs, such as the grouping indication value of 0 representing that the corresponding dimension belongs to the 0th group.
[0073] In addition, one group corresponds to one value range, and the attribute of the group is used to indicate the value range corresponding to the group and a bucketing manner of the group. For example, the attribute of the group can include but is not limited to at least one of the following information: a group, a bucketing manner (such as a bucketing algorithm and data required by the bucketing algorithm), a maximum value and a minimum value of the value range, and the like. For example, the attribute of the group can represent the following:
[0074] {shape_group: 0, algo: exponent, value: 2, min: 1, max: 100}
[0075] shape_group: indicates a group field, used to store a group, to indicate the information of which group it is by the stored group;
[0076] algo: indicates an algorithm field, used to store a bucketing algorithm, and exponent indicates an exponential bucketing algorithm;
[0077] value: indicates an algorithm basis field, used to store data required by the bucketing algorithm, for example, 2 stored therein indicates that the base in the exponential bucketing algorithm is 2.
[0078] max_shape: indicates a range maximum value field, used to store a maximum value of a value range, thereby indicating a maximum value of shape.
[0079] min_shape: indicates a range minimum value field, used to store a minimum value of a value range, thereby indicating a minimum value of shape.
[0080] Based on the above description, for example, a computation graph can contain the following input nodes:
[0081] input0: <-1x10x16xf32>
[0082] input1: <-1x2xf32>
[0083] input2: <-1xf32>
[0084] Then, the bucketing mark of the computation graph can be as follows:
[0085] {name: input0, index: 0, shape: {-1, 10, 16}, shape_group: {0, -1, -1}}
[0086] {name: input1, index: 0, shape: {-1, 2}, shape_group: {0, -1}}
[0087] {name: input2, index: 0, shape: {-1}, shape_group: {0}}
[0088] {shape_group: 0, algo: exponent, value: 2, min: 1, max: 100}
[0089] From the above bucketing notation, we can know that the first dimension in the shape of input0 (i.e., the 0th input node), the first dimension in the shape of input1 (i.e., the 1st input node), and the first dimension in the shape of input2 (i.e., the 2nd input node) are all in group 0. Based on the attribute notation of group 0, we can know that the value range of the first dimension in the shape of each input node has a minimum value of 1 and a maximum value of 100, that is, the value range is 1-100; and each value range is bucketed according to the exponential bucketing algorithm with base 2, that is, bucketing is performed according to 1, 2, 4, 8, 16, 32, 64, and 100 as the bucket values.
[0090] It should be noted that the bucketing algorithm in the above-mentioned bucketing tags can be configured as needed and is not limited in this embodiment of the present application. Furthermore, the above description is merely an example of the specific content of the bucketing tags and does not limit them. For example, in other embodiments, each dynamically input group tag in the bucketing tags may include the value range of the corresponding dynamic input. In this case, the group attribute tag does not need to indicate the value range corresponding to the group.
[0091] S203 : Bucketing the value ranges of the dynamic shapes of the P dynamic inputs according to the instructions of the bucketing marks to obtain a plurality of buckets.
[0092] In a specific implementation, the computer device can determine the bucketing method of the value range of the dynamic shape of the p-th dynamic input (p∈[1, P]) according to the indication of the bucketing mark, and then bucket the value range of the dynamic shape of the p-th dynamic input based on the determined bucketing method to obtain multiple numerical values corresponding to the p-th dynamic input; after obtaining the multiple numerical values corresponding to each dynamic input based on this principle, the multiple numerical values corresponding to the P dynamic inputs can be combined to obtain multiple buckets.
[0093] Each bucket contains P values, and different values in the P values are selected from different value ranges. Figure 3 As shown: there are 2 dynamic inputs in total. The value range of the dynamic shape of the first dynamic input is bucketed to obtain two values, value 1 and value 2. The value range of the dynamic shape of the second dynamic input is bucketed to obtain two values, value 4 and value 8. Then, by combining the values corresponding to different dynamic inputs, 4 buckets can be obtained: bucket 1 includes value 1 and value 4, bucket 2 includes value 1 and value 8, bucket 3 includes value 2 and value 4, and bucket 4 includes value 2 and value 8.
[0094] S204: statically compile the computation graph based on the values in each bucket to obtain a compilation result corresponding to each bucket.
[0095] In a specific implementation, if the value range of the dynamic shape of each dynamic input is a range formed by a plurality of preset static shapes, in this case, any value in each bucket is a static shape. Then, when performing S204, the computer device can directly compile the computation graph based on each static shape in each bucket to obtain the compilation result corresponding to each bucket. It can be understood that the specific manner of compiling the computation graph based on the static shape is not limited by the embodiments of the present application, for example, an existing compiler can be used to compile the computation graph based on the static shape.
[0096] In another specific implementation, if the value range of the dynamic shape of each dynamic input is the value range of the dynamic dimension in the corresponding dynamic shape, in this case, any value in each bucket is a specific value of the dynamic dimension. Then, when performing S204, the computer device can traverse the plurality of buckets, determine the kth bucket currently traversed, k is a positive integer and less than or equal to the total number of buckets; respectively take each value in the kth bucket as the value of the dynamic shape of the corresponding dynamic input to obtain the static shape of the kth bucket; wherein, when the pth value in the kth bucket is selected from the value range of the dynamic shape of the pth dynamic input, the pth value corresponds to the pth dynamic input, p∈[1, P]; and the shape determined after the pth value is taken as the value of the dynamic shape of the pth dynamic input can be referred to as the static shape of the pth dynamic input, so it can be seen that the static shape of the kth bucket includes a static shape of each of the P dynamic inputs. Further, after the plurality of buckets are traversed, the computation graph can be statically compiled based on the static shape of each bucket to obtain the compilation result corresponding to each bucket.
[0097] It should be noted that if the inputs of the computation graph include at least one static input (i.e., an input with a static shape) in addition to the P dynamic inputs, the computer device can also add the static shape of each static input to the static shape of each bucket, so that the static shape of each bucket not only includes a static shape of each dynamic input, but also includes the static shape of each static input, to improve the comprehensiveness of the static shape of each bucket, so that the computation graph can be accurately statically compiled based on the static shape of each bucket to obtain the compilation result corresponding to each bucket.
[0098] S205, after obtaining the input data of the computation graph, performing the computation graph on the input data based on the compilation results corresponding to the plurality of buckets to obtain the data computation result of the input data.
[0099] As can be known from the foregoing description, each bucket has a static shape. Moreover, the difference between the static shape of any bucket and the shape of the input data is that the values of the dynamic dimensions are different, i.e., the values in the static dimensions are the same between the static shape of any bucket and the shape of the input data. For example, the dynamic dimension is the first dimension, and then the static shape of any bucket can be <4x10x16xf32>, <8x10x16xf32>, etc., and the shape of the input data can be <5x10x16xf32>.
[0100] Based on this, when performing S205, the computer device can select a target bucket from the plurality of buckets based on the shape of the input data, and the static shape of the target bucket is greater than or equal to the shape of the input data; wherein the static shape of the target bucket is greater than or equal to the shape of the input data means that the value of the dynamic dimension of the static shape of the target bucket is greater than or equal to the value of the dynamic dimension of the input data. Further, when the static shape of the target bucket is equal to or greater than the shape of the input data, it indicates that the compiled result corresponding to the target bucket can recognize and process the input data, and thus the computer device can directly execute the computational graph on the input data based on the compiled result corresponding to the target bucket (i.e., directly use the input data to execute the compiled result corresponding to the target bucket), to obtain the data computation result of the input data.
[0101] When the static shape of the target bucket is greater than the shape of the input data, it indicates that the shape of the input data is not suitable for the shape of the data that the compiled result corresponding to the target bucket supports to recognize and process, and thus the computer device can perform expansion processing on the input data to obtain expanded data (i.e., expanded input data), so that the shape of the expanded data is the same as the static shape in the target bucket, and then execute the computational graph on the expanded data based on the compiled result corresponding to the target bucket to obtain the data computation result of the expanded data, and obtain reference information for shape prediction, the reference information is generated based on the computation logic of the computational graph, so as to predict the target output shape (i.e., the shape of the data computation result corresponding to the input data) according to the shape of the input data and the reference information, and then perform data extraction on the data computation result of the expanded data based on the target output shape to obtain the data computation result corresponding to the input data.
[0102] The specific implementation of the above-mentioned step of performing the computing graph on the augmented data using the compiled result corresponding to the target bucket is: executing the compiled result corresponding to the target bucket using the augmented data. It can be seen that when the static shape of the target bucket is larger than the shape of the input data, the augmented data with a shape that matches the static shape of the target bucket is obtained by augmenting the input data, and the execution of the compiled result corresponding to the target bucket using the augmented data can ensure the successful execution of the target compiled result. By predicting the shape of the data calculation result corresponding to the input data, and then extracting the data calculation result of the augmented data based on the predicted shape, the accuracy of the final data calculation result corresponding to the input data can be ensured.
[0103] It can be understood that in the above implementation, although the input data is augmented, resulting in additional redundant operations, experiments have proved that through reasonable bucketing, the execution efficiency of the static bucketing compilation can still be higher than that of the dynamic shape graph.
[0104] The embodiment of the present application can obtain a computing graph including P dynamic inputs and a bucketing mark of the computing graph, the bucketing mark being used to indicate a group to which each dynamic input belongs and a bucketing manner of each group, the dynamic shapes of the dynamic inputs in the same group having the same value range, and the value ranges of the dynamic shapes of the dynamic inputs being subjected to bucketing processing according to the bucketing manner of the corresponding group. It can be seen that the embodiment of the present application sets the bucketing mark in the form of grouping, and can record the bucketing manner of the value range of the dynamic shape of each dynamic input in the same group by using one piece of information, so that some memory can be avoided to record the bucketing manner of the value range of the dynamic shape of each dynamic input, thereby effectively saving the memory of the processor. Further, the value ranges of the dynamic shapes of the P dynamic inputs can be subjected to bucketing processing according to the indication of the bucketing mark before the execution of the computing graph, to obtain a plurality of buckets, and the computing graph can be statically compiled based on the values in each bucket, so that when the input data of the computing graph is obtained, the computing graph is executed on the input data based on the compiled results corresponding to the plurality of buckets to obtain a data calculation result of the input data, so that the situation that the processor resources are consumed to compile the computing graph every time the input data is obtained can be avoided, thereby effectively saving the overhead generated by the processor and shortening the execution time of the computing graph, and further improving the execution efficiency of the computing graph.
[0105] Based on the above Figure 2 Based on the above
[0106] Please refer to Figure 4 The method for processing the computing graph can generally include S401-S408:
[0107] S401, acquire a computation graph, and acquire a bucketing mark of the computation graph.
[0108] The computation graph can include a plurality of nodes, each node having respective data processing logic, and the data processing logic of the plurality of nodes constitutes operation logic of the computation graph. Specifically, the plurality of nodes can include Q input nodes, R operator nodes, and at least one output node, Q and R are both positive integers; the data processing logic of the input node can be the logic of the input node inputting data into the computation graph, the data processing logic of the operator node can be the data operation logic adopted by the operator node, and the data processing logic of the output node can be the logic of outputting data from the computation graph. Wherein, one input node represents one input, one operator node represents one operator, and one output node represents one output; based on this, it can be known that the computer device can include Q inputs, R operators, and at least one output. Furthermore, there are P dynamic inputs in the Q inputs, each dynamic input has a dynamic shape, each dynamic shape has a value range, and P∈[1, Q].
[0109] The bucketing mark of the computation graph is used to indicate: the group to which each dynamic input belongs, and the bucketing manner of each group; wherein, the dynamic shapes of the dynamic inputs in the same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed by the bucketing manner of the corresponding group. It can be understood that the generation manner of the bucketing mark of the computation graph can refer to the related description of the foregoing method embodiments, which will not be repeated here.
[0110] Optionally, considering that the value ranges of the dynamic shapes of the dynamic inputs of the computation graph are bucketed, and after the computation graph is statically compiled based on the values in each bucket, when the computation graph is executed based on the compilation results corresponding to the plurality of buckets, there can be an operation of expanding the input data, and if there is operation logic of some operators in the computation graph, the accuracy of the final data calculation result of the input data can be affected by the expansion operation. In order to avoid this problem, it can be considered that this type of computation graph does not have bucketability (i.e., the characteristic that the computation graph supports bucketing of the value ranges of the dynamic shapes of the dynamic inputs), thereby prohibiting the bucketing processing of this type of computation graph. Based on this, after the computer device acquires the computation graph, it can detect whether the computation graph has bucketability, so as to execute the bucketing processing in the case that the computation graph is detected to have bucketability; that is, the bucketing processing in the embodiment of the present application is executed in the case that the computation graph is detected to have bucketability.
[0111] Wherein, whether a computation graph has bucketability (i.e., whether the computation graph can be executed by using the bucketing static compilation manner) can be determined by using the following method:
[0112] Suppose the dynamic input of a computation graph is <-1x10xf32>, where the dimension where -1 is located (i.e., the 1st dimension) is a dynamic dimension, and the value range of the dynamic dimension is [1, 100]. If in an execution, the shape of the input data of the computation graph is <23x10xf32>, and the compiled result corresponding to the bucket with the static shape <100x10xf32> is used to execute the input data, it is necessary to use 77 preset data elements in the 1st dimension to expand the input data, so that the shape of the expanded input data is <100x10xf32>, i.e., the expanded input data has 100 data elements in the 1st dimension, as shown in Figure 5a In this case, of the 100 data elements in the 1st dimension of the expanded input data, only the first 23 data elements (i.e., the data elements in the solid line box) are meaningful inputs, and the last 77 data elements (i.e., the data elements in the dashed line box) are meaningless; then, for this expanded input data, if in the execution process of the computation graph, each operator in the computation graph can satisfy the following conditions:
[0113] (1) any data element in the solid line box only operates with other data elements in the solid line box, and any data element in the dashed line box only operates with other data elements in the dashed line box (i.e., the data elements (i.e., preset data elements) in the dashed line box do not participate in the calculation of the data elements (i.e., input data elements) in the solid line box, that is, the calculation operation for the data elements in the dashed line box is irrelevant to the calculation operation for the data elements in the solid line box, and the two calculation operations are independent of each other), as shown in
[0114] add input[0][1], input[0][9]. It represents adding the 1st data element in the 2nd dimension of the input data and the 1st data element in the 2nd dimension of the input data, and it can be seen that when using this operator to calculate the expanded data, the preset data elements used for expansion in the 1st dimension do not participate in the calculation process of the input data, i.e., the calculation operation for the preset data elements is independent of the calculation operation for the input data.
[0115] reduce input, axis=1. It represents reducing (e.g., accumulating) the data elements in the 2nd dimension of the input data, and it can be seen that when using this operator to calculate the expanded data, the preset data elements used for expansion in the 1st dimension do not participate in the calculation process of the input data, i.e., the calculation operation for the preset data elements is independent of the calculation operation for the input data.
[0116] (2) The operation process does not involve the expanded shape (i.e., when the operator calculates the expanded input data after the input data is expanded using the preset data element, the calculation operation for the preset data element is not involved), such as:
[0117] average = (input[0][0] + input[1][1] + … + input[g-1][0]) / g. It represents the mean operation on the first g data elements in the input data in the first dimension, and the value of g refers to the number of data elements in the input data in the first dimension. For example, if the shape of the input data is <23x10xf32>, then g = 23; it can be seen that when the operator calculates the expanded data, the operation process does not involve the calculation operation for the preset data element.
[0118] It can be seen that if the operator satisfies the above conditions, whether the input data with the original input shape <23x10xf32> is expanded in the first dimension does not affect the final calculation result. Only after expansion, there is some redundant data in the result. After removing the redundant data, the result is consistent with the direct execution of the dynamic shape graph.
[0119] Based on this, each operator in the computation graph can be analyzed to determine whether the execution of each operator satisfies the above conditions under static bucketing compilation, so that it can be automatically determined whether a computation graph can be executed by static bucketing compilation (i.e., whether a computation graph has bucketability).
[0120] The following examples are given for several operators:
[0121] ① Matmul (matrix multiplication): the operator has two inputs (which can be lhs and rhs), and the shape of the two inputs is <axb> <bxc>; where B is called contracting dim. According to the semantics of Matmul operator, all data elements in the dimension of contracting dim will be multiplied and then accumulated. If the dimension of contracting dim is expanded, the data elements used for expansion will participate in the operation of input data, resulting in incorrect data computation results of input data. Therefore, for the Matmul operator, the contracting dim of both inputs cannot be batched, that is, the operator does not have the batching condition. Similarly, the general matmul, batching matmul operators and the like also do not have the batching condition.
[0122] ②Reduce (cumulative operation): the operator performs reduce operation on a certain dimension of the input. For example: reduce_sum input <100x10>, 1. The data elements in the input data in the second dimension are added up, that is, for each data element in the first dimension, the corresponding 10 data elements in the second dimension are added up to obtain the data computation result, and the shape of the data computation result is <100>. For such a reduce operator, it can be determined that it cannot be statically batched in the dimension on which the reduce operation is performed, so it is determined that the operator does not have the batching condition.
[0123] ③Gather (gather): the operator mainly has two parameters, input (input data) and indices (index), and its logic is mainly to select appropriate data elements from the input to fill into the data computation result through the value of the indices parameter; it can be seen that when the operator is used to calculate the data obtained by expanding the input data based on the preset data elements, the calculation operation (index lookup) for the preset data elements may be involved, so such an operator cannot be statically batched, so it is determined that the operator does not have the batching condition.
[0124] Based on the above description, the input data includes at least one data element; the computation graph records at least one operator (i.e. the operator represented by the R operator nodes), and the way to detect whether the computation graph has the batchability can be summarized as including the following steps s21-s24:
[0125] s21, traverse each operator recorded in the computation graph, and take the currently traversed operator as the current operator.
[0126] s22, according to the data processing logic of the current operator, predicting whether the preset data element affects the original calculation result of the input data when the current operator calculates the expanded input data after the input data is expanded by using the preset data element, the original calculation result being a result obtained by the current operator calculating the input data. Specifically, according to the data processing logic of the current operator, it can be predicted whether there is a calculation operation for the preset data element when the current operator calculates the expanded input data after the input data is expanded by using the preset data element; if there is no calculation operation for the preset data element, it is determined that the preset data element does not affect the original calculation result of the input data; if there is a calculation operation for the preset data element, according to the data processing logic of the current operator, the calculation correlation between the preset data element and the input data (i.e. the correlation between the calculation operation for the preset data element and the calculation result for the input data) is detected; if the calculation correlation is detected, it is determined that the preset data element affects the original calculation result of the input data; if the calculation correlation is not detected, it is determined that the preset data element does not affect the original calculation result of the input data.
[0127] s23, if the preset data element affects the original calculation result of the input data, it is determined that the current operator does not satisfy the bucketing condition; if the preset data element does not affect the original calculation result of the input data, it is determined that the current operator satisfies the bucketing condition.
[0128] s24, after each operator is traversed, if each operator satisfies the bucketing condition, it is determined that the computation graph has the bucketability, and if there is at least one operator that does not satisfy the bucketing condition, it is determined that the computation graph does not have the bucketability.
[0129] Based on the above description of s21-s24, it can be known that the embodiments of the present application can automatically determine whether the given computation graph has the bucketability to determine whether the computation graph can be executed by the static bucketing compilation manner, so that the manual workload can be effectively reduced and the adaptation efficiency of the computation graph can be improved.
[0130] S402, according to the indication of the bucketing mark, performing the bucketing processing on the value range of the dynamic shape of the P dynamic inputs to obtain a plurality of buckets.
[0131] S403, performing the static compilation on the computation graph based on the values in each bucket to obtain a compilation result corresponding to each bucket.
[0132] In a specific implementation, the specific implementation of steps S402-S403 can refer to the related description of steps S203-S204 in the foregoing method example, which will not be described here again. Moreover, based on the related description of steps S203-S204, it is known that each bucket has a static shape, and the static shape of any bucket can be a set formed by the static shapes of the respective inputs, that is, the static shape of any bucket includes the static shapes of the Q inputs. For example, if the computation graph includes 2 inputs, then the static shape of any bucket includes the static shape of the 1st input <4x1280xf32> and the static shape of the 2nd input <8x1280xf32>.
[0133] S404, after obtaining the input data of the computation graph, selecting a target bucket from the plurality of buckets based on the shape of the input data, the static shape of the target bucket being greater than or equal to the shape of the input data.
[0134] Wherein, the computation graph can include Q inputs, one input for inputting a data to the computation graph, and thus the number of input data of the computation graph is Q. It can be understood that when Q is greater than 1, each of the Q input data has a respective shape, and the shape of the qth input data matches the shape of the qth input; for example, the computation graph includes 2 inputs and each input is a dynamic input, and the dynamic shape of each dynamic input is <-1x1280xf32> and <-1x1280xf32> in turn, then the input data of the computation graph has 2, the shape of the 1st input data can be <3x1280xf32> and the shape of the input data corresponding to the 2nd input can be <6x1280xf32>. Wherein, any input data can include but is not limited to: image, text, voice, etc.
[0135] Since the difference between the static shape of any bucket and the shape of the input data is that the values of the dynamic dimensions are different, the computer device can determine the size relationship between the corresponding bucket and the input data by the size between the values of the dynamic dimensions of the static shape of each bucket and the shape of the input data, and thus select a target bucket from the plurality of buckets based on the size relationship, so that the static shape of the target bucket is greater than or equal to the shape of the input data. Specifically, the computer device can determine from the plurality of buckets the buckets whose static shapes are greater than or equal to the shape of the input data based on the size relationship, and randomly select one of the filtered buckets as the target bucket. Or, select the bucket with the smallest static shape from the filtered buckets as the target bucket, so that the static shape of the target bucket is closest to the shape of the input data, which can reduce the subsequent expansion operation on the input data, thereby saving the processing resources of the processor and improving the running efficiency of the processor.
[0136] It can be understood that when the computation graph includes one input, the static shape of any bucket includes one input and the shape of the input data is also one; in this case, the static shape of the target bucket being greater than or equal to the shape of the input data means that the value in the dynamic dimension of the static shape of the target bucket is greater than or equal to the value in the dynamic dimension of the input data. When the computation graph includes at least two inputs, the static shape of any bucket includes at least two inputs and the shape of the input data is also at least two; in this case, the static shape of the target bucket being greater than or equal to the shape of the input data means that the value in the dynamic dimension of the static shape of any dynamic input included in the target bucket is greater than or equal to the value in the dynamic dimension of the static shape of the input data corresponding to the dynamic input.
[0137] For example, the computation graph includes two dynamic inputs, the static shapes of the two dynamic inputs in bucket 1 are <6x10x80xf32> and <10x1280xf32> in sequence, and the static shapes of the two dynamic inputs in bucket 2 are <10x10x80xf32> and <10x1280xf32> in sequence; if the shapes of the two input data of the computation graph are <7x10x80xf32> and <8x1280xf32> in sequence, since the value in the dynamic dimension (the first dimension) of the static shape of the first dynamic input included in bucket 2 is greater than the value in the dynamic dimension of the static shape of the first input data, and the value in the dynamic dimension (the first dimension) of the static shape of the second dynamic input included in bucket 2 is also greater than the value in the dynamic dimension of the static shape of the second input data, therefore, bucket 2 can be used as the target bucket.
[0138] S405, when the static shape of the target bucket is greater than the shape of the input data, performing expansion processing on the input data to obtain expanded data, the shape of the expanded data being the same as the static shape in the target bucket.
[0139] In a specific implementation, if the static shape of the target bucket is larger than the shape of the input data, the computer device can take the value of the static shape of the target bucket in the dynamic dimension as the first value, take the value of the shape of the input data in the dynamic dimension as the second value, take the difference between the first value and the second value as the target number, and then use the preset data elements of the target number in the dynamic dimension to expand the input data to obtain expanded data, so that the value in the dynamic dimension of the shape of the expanded data is the same as the first value. For example, the static shape of the target bucket is <10x1280xf32> and the shape of the input data is <8x1280xf32>, it can be determined that the first value is 10, the second value is 8, and the difference between the first value and the second value is 2, so 2 preset data elements can be used in the first dimension (i.e., the dynamic dimension) to expand the input data to obtain expanded data, and the value in the first dimension of the shape of the expanded data is 10, i.e., the expanded data has 10 elements in the first dimension.
[0140] It can be understood that the above is described by taking an example that the static shape of the target bucket includes one input static shape and the number of input data is one. When the static shape of the target bucket includes at least two input static shapes and the number of input data is at least two, the computer device can use the above-mentioned manner to expand the input data corresponding to each input respectively to obtain expanded data.
[0141] S406, based on the compilation result corresponding to the target bucket, executing the computation graph on the expanded data to obtain the data computation result of the expanded data.
[0142] S407, obtaining reference information for shape prediction, and predicting a target output shape according to the shape of the input data and the reference information, the target output shape being the shape of the data computation result corresponding to the input data.
[0143] In a specific implementation, since the expanded data is obtained by expanding the input data, reference information for shape prediction needs to be obtained, and a target output shape is predicted according to the shape of the input data and the reference information, so as to determine which data in the data computation result of the expanded data is calculated based on the input data and which data is calculated based on the preset data elements for expansion. For example, see Figure 5b As shown, the input data is expanded from <23xf32> in the first dimension to <100xf32>, and after the expanded data (i.e., the expanded input data) is subjected to the computation graph based on the compilation result corresponding to the target bucket, the shape of the data computation result of the expanded data is <200xf32>. Therefore, it is necessary to determine which data in the data computation result of the expanded data is calculated based on the actual input data and which data is calculated based on the preset data element, so as to accurately extract the data computation result of the input data.
[0144] The reference information mentioned above is generated based on the computation logic of the computation graph, and the computation logic includes the data processing logic of each node in the computation graph.
[0145] In a specific implementation, the reference information can include the computation logic of the computation graph. In this case, when predicting the target output shape based on the shape of the input data and the reference information, the computer device can obtain a shape prediction model that is pre-trained based on AI technology, so as to call the shape prediction model to perform output shape prediction based on the shape of the input data and the computation logic of the computation graph, and obtain the target output shape.
[0146] In another specific implementation, the reference information can include a target shape calculation formula, the variable in the target shape calculation formula is a numerical value in the shape of the input data, and the value of the target shape calculation formula represents the value of the t-th dimension in the target output shape, t is a positive integer and less than or equal to the number of dimensions in the target output shape. In this case, when predicting the target output shape based on the shape of the input data and the reference information, the computer device can call the target shape calculation formula, calculate the value of the t-th dimension in the target output shape based on the numerical value in the shape of the input data, obtain the target value, and obtain the numerical value of each dimension except the t-th dimension from the shape of the data computation result of the expanded data, so as to integrate the obtained numerical value of each dimension and the target value to obtain the target output shape.
[0147] In an embodiment, if the computation graph only includes one operator node, the computer device can directly generate a target shape calculation formula based on the data processing logic of the operator represented by the operator node.
[0148] For example, the input of the computation graph is:
[0149] Input0: <-1xf32>
[0150] Input1: <-1x10xf32>
[0151] The output is:
[0152] Output0: <-1xf32>
[0153] Output1: <-1 x 30 x f32>
[0154] If the data processing logic of the operator in the computation graph includes: directly outputting the input data corresponding to the 0th input (Input0), and performing a multiplication operation of 2 times on the data elements in the 1st dimension in the input data corresponding to the 1st input (Input1); then based on the data processing logic, it can be known that the shape of the 0th output (Output0) is equal to the shape of the 0th input in each dimension, and the shape of the 1st output (Output1) and the shape of the 1st input have a two times relationship in the 1st dimension.
[0155] Based on this, the generated target shape calculation formula can be as follows:
[0156] Output_0_dim_0 = input_0_dim_0
[0157] Output_1_dim_0 = input_1_dim_1 * 2
[0158] The meaning of the formula is that the dynamic shape graph has two outputs, and each output contains a dynamic dim (i.e., the value in the dynamic dimension). The formula uses the dynamic dim in the input to calculate the dynamic dim of the output. And according to the formula, the value of dim 0 of Output0 (i.e., the value of the shape of Output0 in the 1st dimension) is equal to the value of dim0 of input0 (i.e., the value of the shape of Intput0 in the 1st dimension), and the value of dim 0 of Output1 (i.e., the value of the shape of Output1 in the 1st dimension) is twice the value of dim0 of input1 (i.e., the value of the shape of Input1 in the 1st dimension).
[0159] In another implementation, the computation graph includes a plurality of nodes, and the plurality of nodes can specifically include: P input nodes, R operator nodes, and an output node, etc. The process of generating a target shape calculation formula based on the operation logic of the computation graph (i.e., the data processing logic of the plurality of nodes) can include the following s31-s33:
[0160] s31, based on the topology structure of the computation graph, sorting the plurality of nodes in the computation graph to obtain a topological order of the plurality of nodes. Specifically, the topology structure can include the connection relationship between the nodes, and the computer device can take the input node as the starting point (i.e., the starting node) and take the output node as the end point (i.e., the last node) when sorting the plurality of nodes in the computation graph based on the topology structure, to obtain the topological order of the plurality of nodes.
[0161] s32, in the topological order of the plurality of nodes, sequentially processing each node according to the data processing logic of the node to obtain a shape calculation formula of each node. In the shape calculation formula of any node, the variables are values in the shape of the input data. Specifically:
[0162] ①The processing of the i-th input node includes: generating a shape calculation formula of the i-th input node based on the variable x i and the dimension j of the dynamic dimension in the dynamic shape of the i-th input node, recording the generated shape calculation formula on the output shape of the i-th input node, and passing the output shape of the i-th input node to the next node of the i-th input node. The shape calculation formula of the i-th input node is used to indicate that the value of the j-th dimension in the dynamic shape of the i-th input node is the variable x i ; i ∈ [1, P], j is a positive integer. Exemplarily, the shape calculation formula of the i-th input node can be: f(input i , j) = x i ; i represents the i-th input node with a dynamic shape, j represents the j-th dimension in this dynamic shape as a dynamic dimension, and x i represents the i-th variable (i.e., the i-th unknown).
[0163] ②The processing of the r-th operator node includes: deriving the output shape of the r-th operator node according to the data processing logic of the r-th operator node and the shape received by the r-th operator node, and passing the derived output shape to the next node of the r-th operator node, r ∈ [1, R]. Compared with the input formula (i.e., the received shape calculation formula), the possible change of the output formula (i.e., the shape calculation formula in the output shape) of the r-th operator node is that the output formula is equal to the input formula, or the output formula is an arithmetic operation based on the input formula.
[0164] ③The processing of the output node includes: taking the shape received by the output node as the output shape of the output node, recording the shape calculation formula on the output shape of the output node, and saving the shape calculation formula recorded on the output shape (i.e., saving the formula of the dynamic dim of the output shape).
[0165] s33, taking the shape calculation formula of the last node as the target shape calculation formula. It can be understood that, since each input node is a starting node indicated by the topological order, and the output node is the last node indicated by the topological order, the specific implementation of step s33 is to take the shape calculation formula of the output node as the target shape calculation formula.
[0166] Based on the above description of s31-s33, the following will be described in combination with Figure 5c To illustrate the generation process of the target shape computation formula:
[0167] The design graph has two dynamic inputs: input_1 and input_2; and the dynamic shapes of input_1 and input_2 are both <-1x12xf32>. Then the shape computation formula of input_1 can be generated as f(input1, 1) = x1, and the shape computation formula of input_2 can be generated as f(input2, 1) = x2, so that the shape computation formula of each dynamic input is recorded on the output shape of the corresponding dynamic input, and the output shape is passed to the next node add.
[0168] Further, according to the data processing logic of the add operator and the received shape, the corresponding output shape can be derived as <-1x12xf32> and the corresponding shape computation formula can be obtained as f(add, 1) = broadcast(x1, x2), and the derived output shape (carrying the shape computation formula) is passed to the next node reshape (reshaping shape). It can be understood that when processing the add operator, the value in the first dimension of the output shape can be x1 or x2; assuming that the add operator has the semantics of broadcast, the broadcast semantics also needs to be added to the formula when generating the formula.
[0169] Further, according to the data processing logic of the reshape operator (such as reshaping the data elements in the first dimension into two-dimensional data elements) and the received shape, the corresponding output shape can be derived as <2x-1x12xf32> and the corresponding shape computation formula can be obtained as f(reshape, 2) = broadcast(x1, x2) / 2, and the derived output shape (carrying the shape computation formula) is passed to the next node transpose (transposition).
[0170] Further, according to the data processing logic of the transpose operator (such as transposing the data elements in the first dimension and the data elements in the second dimension) and the received shape, the corresponding output shape can be derived as <-1x2x12xf32> and the corresponding shape computation formula can be obtained as f(transpose, 1) = broadcast(x1, x2) / 2, and the derived output shape (carrying the shape computation formula) is passed to the next node tile (tiled).
[0171] Further, the data processing logic of the tile operator and the received shape can be used to derive the corresponding output shape <-1x2x24xf32> and the corresponding shape calculation formula f(tile, 1) = broadcast(x1, x2) / 2*3, and the derived output shape (carrying the shape calculation formula) is passed to the next node output.
[0172] Further, the shape received by the output node can be used as the output shape of the output node, and the shape calculation formula recorded on the output shape of the output node (i.e., <-1x2x24xf32>) can be f(output, 1) = broadcast(x1, x2) / 2*3, so as to use the shape calculation formula as the target shape calculation formula.
[0173] Based on the above, it can be seen that by continuously analyzing each node, a formula containing the dynamic dim of the input as a variable can be accurately generated. In actual execution, as long as the actual shape of the input data is obtained, the actual shape of the output (i.e., the target output shape) can be directly calculated by using the formula, so as to improve the efficiency of obtaining the target output shape. It can be understood that if there is a node that cannot be analyzed, it can be determined that the formula generation fails; in this case, the static bucket compilation of the computation graph can not be performed.
[0174] Based on the above description, it should be further explained that the algorithm for generating the target shape calculation formula needs to derive and calculate the output shape according to the input shape. In addition to the basic algorithm described above, special processing is also needed for some operators related to shape calculation. For example:
[0175] The shape operator obtains the input shape as the output data.
[0176] That is to say, for the processing of general operators, the algorithm only needs to derive the formula based on the shape of the operator input and output. However, when encountering the shape operator above, it passes the input shape as data to the next operator, so that the shape participates in subsequent calculations as data. At this time, if the formula is derived only based on the shape of the operator input and output, then a large number of subsequent operators will not be able to generate shape calculation formulas because the shape calculation formula does not exist in the output shape. In this scenario, the algorithm for generating the target shape calculation formula proposed in the embodiment of the present application can bind the already generated shape calculation formula in its input and its output data together when encountering special operators such as the shape operator, and pass the output data to the next node, so that the next node can derive the shape calculation formula through the output data, and subsequent operations on the output of the shape operator will also perform corresponding processing on the shape calculation formula at the same time, until encountering operators such as reshape.
[0177] Based on this, it can be seen that the shape received by the r-th operator node is represented as the target shape. When the data processing logic of the r-th operator node does not include: when the calculation operation is performed on the target shape, the shape calculation formula in the target shape is recorded on the output shape of the r-th operator node. When the data processing logic of the r-th operator node includes: when the calculation operation is performed on the target shape, the shape calculation formula in the target shape is recorded on the output data of the r-th operator node, then the processing of the r-th operator node also includes: passing the output data of the r-th operator node to the next node of the r-th operator node, so as to realize the normal transmission of the shape calculation formula in the calculation graph, thereby ensuring that each subsequent node can generate its own shape calculation formula, and improving the success rate and accuracy of generating the final target shape calculation formula.
[0178] See for example Figure 5d As shown: Formula f() represents the shape calculation formula of the operator recorded on the output shape of the operator, f value () indicates that the shape calculation formula of the operator is recorded on the output data of the operator. Figure 5d It can be seen that:
[0179] The shape calculation formula f(add, 1) = x of the add operator is recorded in the output shape of the add operator. However, the output shape of the next operator of the add operator (i.e., the shape operator) is <2xi32> (where i32 represents a 32-bit integer). This output shape does not carry the shape calculation formula or any unknown quantity. The shape calculation formula of the shape operator (f value (shape, 1) = x) is recorded on the output data of the shape operator, so the output data and output shape of the shape operator need to be passed to the next node slice.
[0180] Further, according to the data processing logic of the slice operator and the received shape and the output data of the shape operator, the corresponding output shape is derived as <1x32> and the corresponding shape calculation formula is obtained as f(slice, 1) = x, and the derived output shape and the output data recording the corresponding shape calculation formula are passed to the next node concat (concatenate). value (slice, 1) = x, and the derived output shape and the output data recording the corresponding shape calculation formula are passed to the next node concat (concatenate).
[0181] Further, according to the data processing logic of the concat operator and the received shape and the output data of the slice operator, the corresponding output shape is derived as <2x32> and the corresponding shape calculation formula is obtained as f(concat, 1) = x, and the derived output shape and the output data recording the corresponding shape calculation formula are passed to the next node reshape. value (concat, 1) = x, and the derived output shape and the output data recording the corresponding shape calculation formula are passed to the next node reshape.
[0182] Further, according to the data processing logic of the reshape operator and the received shape and the output data of the concat operator, the corresponding output shape is derived as <-1x6xf32> and the corresponding shape calculation formula is obtained as f(reshape, 1) = x, and the derived output shape (recording the corresponding shape calculation formula) is passed to the next node, and so on, until the target shape calculation formula is obtained.
[0183] As can be seen, since the shape calculation formula of each operator is recorded on the output data of the operator from the shape operator (inclusive) to the reshape operator (exclusive), the output data and the output shape of each operator need to be passed to the next node when passing, so that the shape calculation formula of the add operator can be passed to the output shape of the reshape operator, thereby avoiding the problem that the shape calculation formula of the reshape and subsequent operators cannot be derived, and further ensuring the success rate and accuracy of the derivation of the final target shape calculation formula.
[0184] S408, based on the target output shape, data extraction is performed on the data calculation result of the augmented data to obtain the data calculation result corresponding to the input data.
[0185] Specifically, the data corresponding to the target output shape can be extracted from the data calculation result of the augmented data as the data calculation result corresponding to the input data. For example, the target output shape is <2x10xf32>, so the first 2 data elements can be extracted under the first dimension and the first 10 data elements can be extracted under the second dimension in the data calculation result of the augmented data, so as to constitute the data calculation result corresponding to the input data by using the data elements extracted under each dimension.
[0186] Based on the description of steps S401-S408 above, it can be seen that the calculation graph processing method proposed in the embodiment of the present application may include multiple module contents. Figure 5e As shown, the contents of these multiple modules may include but are not limited to: input legitimacy check (i.e., checking whether the input data is legal to ensure the legitimacy of the input data), bucketability analysis (i.e., analyzing whether the calculation graph is bucketable to avoid executing optimization on inapplicable calculation graphs based on static bucketing compilation), output data space calculation (i.e., predicting the shape of the data calculation result corresponding to the input data to ensure that the correct data calculation result is obtained based on the predicted shape), custom operator processing (e.g., processing the dynamic output of the custom operator), bucketing method selection (e.g., based on the distribution of the input, selecting a more targeted bucketing method for the value range of each dynamic input to improve performance), static bucketing compilation (i.e., using the corresponding bucketing method to bucket the value range of each dynamic input, and statically compiling the calculation graph based on the value in each bucket), execution (i.e., selecting the compilation result corresponding to the appropriate bucket according to the shape of the input data and executing it), and result extraction (i.e., extracting the data calculation result of the input data from the execution result of the compilation result based on the shape calculated by the output data space).
[0187] It can be seen that the calculation graph processing method proposed in the embodiment of the present application can confirm that the input calculation graph can be statically bucketed compiled through legality checks and bucketability analysis (for example, through code analysis, it is determined that the calculations of multiple input data will not interfere with each other). Furthermore, the data that the compilation process depends on is determined by modules such as output data space calculation, bucketing strategy selection, and custom operator processing. During the compilation process, multiple static compilations are performed using the bucket values of the bucketing strategy to generate multiple compilation results. When the calculation graph is actually executed, it can be judged according to the shape of the input data, and the appropriate compilation result can be selected to execute the corresponding input data, thereby obtaining the data calculation result of the input data.
[0188] Based on the above, it can be seen that the method proposed in the embodiment of the present application can not only support the execution of dynamic shape graphs using static bucket compilation, but also provide several automatic and efficient methods to ensure the correctness of bucketing. This can better cope with the actual production environment and reduce the additional overhead caused by directly executing the dynamic shape graph when it is needed, thereby potentially achieving better execution efficiency. In addition, the embodiment of the present application is based on practical applications, considering multiple scenarios such as commercial applications and testing, and adopts a simple, convenient, automated, and high-performance design, making it highly feasible in actual production applications.
[0189] Based on the description of the above various method embodiments, the embodiments of the present application further disclose a processing apparatus of a computation graph; the processing apparatus of the computation graph can be a computer program (including one or more instructions) running in a computer device, and the processing apparatus of the computation graph can perform the steps in any of the above method processes. Please refer to Figure 6 The processing apparatus of the computation graph can run the following units:
[0190] The obtaining unit 601 is configured to obtain a computation graph, the computation graph comprising P dynamic inputs, P being a positive integer; wherein each dynamic input has a dynamic shape, and each dynamic shape has a value range;
[0191] The obtaining unit 601 is further configured to obtain a bucketing mark of the computation graph, the bucketing mark being configured to indicate: a group to which each dynamic input belongs, and a bucketing manner of each group; wherein the dynamic shapes of the dynamic inputs in the same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed by the bucketing manner of the corresponding group;
[0192] The processing unit 602 is configured to process the value ranges of the dynamic shapes of the P dynamic inputs according to the indication of the bucketing mark, to obtain a plurality of buckets; each bucket comprising P values, different values in the P values being selected from different value ranges;
[0193] The processing unit 602 is further configured to statically compile the computation graph based on the values in each bucket, to obtain a compilation result corresponding to each bucket;
[0194] The processing unit 602 is further configured to, after obtaining input data of the computation graph, execute the computation graph on the input data based on the compilation results corresponding to the plurality of buckets, to obtain a data computation result of the input data.
[0195] In an implementation manner, when the processing unit 602 is configured to statically compile the computation graph based on the values in each bucket, to obtain a compilation result corresponding to each bucket, the processing unit 602 can be specifically configured to:
[0196] Traverse the plurality of buckets, and determine a kth bucket currently traversed, k being a positive integer and less than or equal to the total number of the buckets;
[0197] Respectively take each value in the kth bucket as a value of a dynamic shape of a corresponding dynamic input, to obtain a static shape of the kth bucket; wherein when a pth value in the kth bucket is selected from a value range of a dynamic shape of a pth dynamic input, the pth value corresponds to the pth dynamic input, p ∈ [1, P];
[0198] After the plurality of buckets are traversed, the computation graph is compiled based on a static shape of each bucket respectively, to obtain a corresponding compilation result of the each bucket.
[0199] In another implementation, the each bucket has a static shape; accordingly, the processing unit 602, when used to execute the computation graph on the input data based on the corresponding compilation result of the plurality of buckets, to obtain a data computation result of the input data, can be specifically used for:
[0200] selecting a target bucket from the plurality of buckets based on a shape of the input data, a static shape of the target bucket being greater than or equal to the shape of the input data;
[0201] when the static shape of the target bucket is greater than the shape of the input data, performing an expansion process on the input data to obtain expanded data, the shape of the expanded data being the same as the static shape in the target bucket;
[0202] executing the computation graph on the expanded data based on the corresponding compilation result of the target bucket, to obtain a data computation result of the expanded data;
[0203] obtaining reference information for shape prediction, the reference information being generated based on a computation logic of the computation graph; and predicting a target output shape according to the shape of the input data and the reference information, the target output shape being a shape of a data computation result corresponding to the input data;
[0204] performing data extraction on the data computation result of the expanded data based on the target output shape, to obtain the data computation result corresponding to the input data.
[0205] In another implementation, the reference information includes a target shape calculation formula, a variable in the target shape calculation formula being a numerical value in the shape of the input data, and a value of the target shape calculation formula representing a value of a t-th dimension in the target output shape, t being a positive integer and less than or equal to a number of dimensions in the target output shape;
[0206] Accordingly, the processing unit 602, when used to predict a target output shape according to the shape of the input data and the reference information, can be specifically used for:
[0207] calling the target shape calculation formula, and calculating the value of the t-th dimension in the target output shape based on the numerical value in the shape of the input data, to obtain a target numerical value;
[0208] obtaining numerical values of each dimension except the t-th dimension from the shape of the data computation result of the expanded data;
[0209] Integrate the obtained values of each dimension and the target value to obtain the target output shape.
[0210] In another implementation, the computation graph includes a plurality of nodes, each node having respective data processing logic, and the data processing logic of the plurality of nodes constitutes the operation logic of the computation graph.
[0211] Correspondingly, the processing unit 602, when generating the target shape calculation formula based on the operation logic of the computation graph, can be specifically configured to:
[0212] Sort the plurality of nodes in the computation graph based on the topological structure of the computation graph to obtain a topological order of the plurality of nodes;
[0213] Process the respective nodes according to the data processing logic of each node in the topological order of the plurality of nodes to obtain a shape calculation formula of each node; wherein the variables in the shape calculation formula of any node are values in the shape of the input data;
[0214] Take the shape calculation formula of the last node as the target shape calculation formula.
[0215] In another implementation, the bucketing processing is performed when it is detected that the computation graph has a bucketable nature.
[0216] The input data includes at least one data element; and the computation graph records at least one operator. Correspondingly, the processing unit 602, when detecting whether the computation graph has the bucketable nature, can be specifically configured to:
[0217] Traverse each operator recorded in the computation graph, and take the currently traversed operator as a current operator;
[0218] According to the data processing logic of the current operator, predict whether the preset data element affects the original calculation result of the input data when the current operator calculates the expanded input data after the input data is expanded by the preset data element; wherein the original calculation result refers to the result obtained by the current operator calculating the input data;
[0219] If the preset data element affects the original calculation result of the input data, it is determined that the current operator does not satisfy the bucketing condition; if the preset data element does not affect the original calculation result of the input data, it is determined that the current operator satisfies the bucketing condition;
[0220] After the traversal of each operator, if each operator satisfies the bucketing condition, it is determined that the computation graph has the bucketable nature; if there is at least one operator that does not satisfy the bucketing condition, it is determined that the computation graph does not have the bucketable nature.
[0221] In another embodiment, the processing unit 602 can be specifically configured to, according to the data processing logic of the current operator, predict whether the preset data element affects the original calculation result of the input data when the current operator calculates the input data after the input data is augmented with the preset data element.
[0222] According to the data processing logic of the current operator, predict whether there is a calculation operation for the preset data element when the current operator calculates the input data after the input data is augmented with the preset data element.
[0223] If there is no calculation operation for the preset data element, it is determined that the preset data element does not affect the original calculation result of the input data.
[0224] In another embodiment, the processing unit 602 can also be configured to:
[0225] If there is a calculation operation for the preset data element, according to the data processing logic of the current operator, detect the calculation association between the preset data element and the input data.
[0226] If the calculation association is detected, it is determined that the preset data element affects the original calculation result of the input data.
[0227] If the calculation association is not detected, it is determined that the preset data element does not affect the original calculation result of the input data.
[0228] According to another embodiment of the present application, Figure 6 The units in the processing apparatus of the illustrated calculation graph can be respectively or all combined into one or several other units to constitute, or some of the units can also be further split into a plurality of units with smaller functions to constitute, which can achieve the same operation without affecting the implementation of the technical effects of the embodiments of the present application. The above units are divided based on logical functions, and in actual application, the function of a unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the processing apparatus based on the calculation graph can also include other units, and in actual application, these functions can also be assisted by other units to be implemented, and can be implemented by multiple units in cooperation.
[0229] According to another embodiment of the present application, the processing apparatus device of the computational graph shown in FIG. 7 can be constructed, and each method of the embodiments of the present application can be implemented, by running a computer program (including one or more instructions) capable of performing each step involved in any of the above methods on a general computing device such as a computer including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), read-only memory (ROM), and the like. Figure 6 The computer program can be recorded on, for example, a computer-readable storage medium, loaded into the above computing device through the computer-readable storage medium, and run therein.
[0230] It should be noted that in the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can include a part of the entire module or unit that functions as the module or unit.
[0231] The embodiments of the present application can obtain a computational graph including P dynamic inputs and a bucketing mark of the computational graph, the bucketing mark being used to indicate a group to which each dynamic input belongs and a bucketing manner of each group, the dynamic shapes of the dynamic inputs in the same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed in a bucketing manner according to the bucketing manner of the corresponding group. It can be seen that the embodiments of the present application can record the bucketing manner of the value ranges of the dynamic shapes of the dynamic inputs in the same group by using one piece of information in the form of grouping, which can avoid occupying some memory to record the bucketing manner of the value ranges of the dynamic shapes of each dynamic input, thereby effectively saving the memory of the processor. Further, the value ranges of the dynamic shapes of the P dynamic inputs can be processed in a bucketing manner according to the indication of the bucketing mark before the computational graph is executed, a plurality of buckets are obtained, and the computational graph is statically compiled based on the values in each bucket, so that after the input data of the computational graph is obtained, the input data is executed on the computational graph based on the compilation results corresponding to the plurality of buckets to obtain a data calculation result of the input data, which can avoid the case that the processor resources are consumed to compile the computational graph every time the input data is obtained, thereby effectively saving the overhead generated by the processor and shortening the execution time of the computational graph, and further improving the execution efficiency of the computational graph.
[0232] Based on the description of the above method embodiments and device embodiments, the embodiments of the present application further provide a computer device. Please refer to Figure 7 The computer device at least includes a processor 701, an input interface 702, an output interface 703, and a computer storage medium 704. Among them, the processor 701, the input interface 702, the output interface 703 and the computer storage medium 704 in the computer device can be connected through a bus or other means. The computer storage medium 704 can be stored in the memory of the computer device, and the computer storage medium 704 is used to store a computer program, the computer program includes one or more instructions, and the processor 701 is used to execute one or more instructions stored in the computer storage medium 704. The processor 701 (or CPU (Central Processing Unit, Central Processing Unit)) is the computing core and control core of the computer device, which is suitable for implementing one or more instructions, and is particularly suitable for loading and executing one or more instructions to realize the corresponding method flow or corresponding function.
[0233] In one embodiment, the processor 701 described in the embodiment of the application can be used for a series of processing of the computation graph, specifically including: obtaining a computation graph, the computation graph including P dynamic inputs, P being a positive integer; wherein each dynamic input has a dynamic shape, and each dynamic shape has a value range; obtaining a bucket marking of the computation graph, the bucket marking being used to indicate: a group to which each dynamic input belongs and a bucketing manner of each group; wherein the dynamic shapes of the dynamic inputs in the same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed according to the bucketing manner of the corresponding group; according to the indication of the bucket marking, the value ranges of the dynamic shapes of the P dynamic inputs are processed to obtain a plurality of buckets; each bucket includes P values, and different values in the P values are selected from different value ranges; based on the values in each bucket, the computation graph is statically compiled to obtain a compilation result corresponding to each bucket; after obtaining input data of the computation graph, based on the compilation results corresponding to the plurality of buckets, the input data is executed on the computation graph to obtain a data computation result of the input data, and the like.
[0234] The embodiment of the present application further provides a computer storage medium (Memory), which is a memory device in a computer device and is used for storing computer programs and data. It can be understood that the computer storage medium herein can include a built-in storage medium in the computer device, and of course can include an extended storage medium supported by the computer device. The computer storage medium provides a storage space, and the storage space stores an operating system of the computer device. Furthermore, the storage space also stores a computer program, and the computer program includes one or more instructions suitable for being loaded and executed by the processor 701, and the instructions can be one or more program codes. It should be noted that the computer storage medium herein can be a high-speed RAM memory, or a non-volatile memory such as at least one disk memory; optionally, the computer storage medium can be at least one computer storage medium located away from the aforementioned processor.
[0235] In one embodiment, one or more instructions stored in the computer storage medium can be loaded and executed by the processor to implement the corresponding steps in any of the method embodiments described above; in a specific implementation, one or more instructions in the computer storage medium can be loaded and executed by the processor to implement the following steps:
[0236] Obtaining a computation graph, the computation graph including P dynamic inputs, P being a positive integer; wherein each dynamic input has a dynamic shape, and each dynamic shape has a value range;
[0237] Obtaining a bucketing mark of the computation graph, the bucketing mark being used for indicating a group to which each dynamic input belongs and a bucketing manner of each group; wherein the dynamic shapes of the dynamic inputs in a same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed by the bucketing manner of the corresponding group;
[0238] According to the indication of the bucketing mark, performing bucketing processing on the value ranges of the dynamic shapes of the P dynamic inputs to obtain a plurality of buckets; each bucket includes P values, and different values in the P values are selected from different value ranges;
[0239] Based on the values in each bucket, performing static compilation on the computation graph to obtain a compilation result corresponding to each bucket;
[0240] After obtaining input data of the computation graph, performing the computation graph on the input data based on the compilation results corresponding to the plurality of buckets to obtain a data computation result of the input data.
[0241] In an embodiment, when the computation graph is statically compiled based on the values in each bucket, the one or more instructions can be loaded and specifically executed by the processor:
[0242] The plurality of buckets are traversed to determine a kth bucket being currently traversed, k being a positive integer and less than or equal to the total number of buckets;
[0243] Each value in the kth bucket is respectively taken as a value of a dynamic shape of a corresponding dynamic input to obtain a static shape of the kth bucket; when a pth value in the kth bucket is selected from a value range of a dynamic shape of a pth dynamic input, the pth value corresponds to the pth dynamic input, p e [1, P];
[0244] After the plurality of buckets are traversed, the computation graph is compiled based on the static shape of each bucket to obtain a corresponding compilation result of each bucket.
[0245] In another embodiment, each bucket has a static shape; accordingly, when the processing unit 602 is used to execute the computation graph on the input data based on the corresponding compilation results of the plurality of buckets to obtain a data computation result of the input data, the processing unit 602 can be specifically used to:
[0246] Based on the shape of the input data, a target bucket is selected from the plurality of buckets, the static shape of the target bucket being greater than or equal to the shape of the input data;
[0247] When the static shape of the target bucket is greater than the shape of the input data, the input data is expanded to obtain expanded data, the shape of the expanded data being the same as the static shape in the target bucket;
[0248] The computation graph is executed on the expanded data based on the corresponding compilation result of the target bucket to obtain a data computation result of the expanded data;
[0249] Reference information for shape prediction is obtained, the reference information being generated based on the computation logic of the computation graph; and a target output shape is predicted according to the shape of the input data and the reference information, the target output shape being the shape of the data computation result corresponding to the input data;
[0250] Based on the target output shape, the data computation result of the expanded data is extracted to obtain the data computation result corresponding to the input data.
[0251] In another implementation, the reference information comprises a target shape calculation formula, a variable in the target shape calculation formula is a value in the shape of the input data, and a value of the target shape calculation formula represents a value of a tthdimension in the target output shape, t is a positive integer and is less than or equal to a number of dimensions in the target output shape;
[0252] Correspondingly, in predicting the target output shape according to the shape of the input data and the reference information, the one or more instructions can be loaded by the processor and specifically executed as follows:
[0253] calling the target shape calculation formula, calculating the value of the tthdimension in the target output shape based on the value in the shape of the input data, to obtain a target value;
[0254] obtaining values of each dimension except the tthdimension from the shape of the data calculation result of the augmented data;
[0255] integrating the obtained values of each dimension and the target value to obtain the target output shape.
[0256] In another implementation, the computation graph comprises a plurality of nodes, each node has a respective data processing logic, and data processing logics of the plurality of nodes constitute an operation logic of the computation graph;
[0257] Correspondingly, in generating the target shape calculation formula based on the operation logic of the computation graph, the one or more instructions can be loaded by the processor and specifically executed as follows:
[0258] sorting the plurality of nodes in the computation graph based on a topology structure of the computation graph to obtain a topology order of the plurality of nodes;
[0259] processing the respective nodes according to the data processing logic of each node in the topology order of the plurality of nodes to obtain a shape calculation formula of each node; wherein, a variable in the shape calculation formula of any node is a value in the shape of the input data;
[0260] taking the shape calculation formula of the last node as the target shape calculation formula.
[0261] In another implementation, the bucketing processing is performed when it is detected that the computation graph has a bucketable property;
[0262] wherein, the input data comprises at least one data element; and the computation graph records at least one operator, and correspondingly, in detecting whether the computation graph has the bucketable property, the one or more instructions can be loaded by the processor and specifically executed as follows:
[0263] traversing each operator recorded by the computation graph, taking the currently traversed operator as a current operator;
[0264] According to the data processing logic of the current operator, it is predicted whether the preset data element affects the original calculation result of the input data when the current operator calculates the expanded input data after the input data is expanded by using the preset data element; wherein the original calculation result refers to the result obtained by the current operator calculating the input data;
[0265] If the preset data element affects the original calculation result of the input data, it is determined that the current operator does not satisfy the bucketing condition; if the preset data element does not affect the original calculation result of the input data, it is determined that the current operator satisfies the bucketing condition;
[0266] After the traversal of each operator, if each operator satisfies the bucketing condition, it is determined that the computation graph has bucketability; if there is at least one operator that does not satisfy the bucketing condition, it is determined that the computation graph does not have bucketability.
[0267] In another implementation, when predicting whether the preset data element affects the original calculation result of the input data when the current operator calculates the expanded input data after the input data is expanded by using the preset data element according to the data processing logic of the current operator, the one or more instructions can be loaded by the processor and specifically executed as follows:
[0268] According to the data processing logic of the current operator, it is predicted whether there is a calculation operation for the preset data element when the current operator calculates the expanded input data after the input data is expanded by using the preset data element;
[0269] If there is no calculation operation for the preset data element, it is determined that the preset data element does not affect the original calculation result of the input data.
[0270] In another implementation, the one or more instructions can be loaded by the processor and specifically executed as follows:
[0271] If there is a calculation operation for the preset data element, the calculation association between the preset data element and the input data is detected according to the data processing logic of the current operator;
[0272] If the calculation association is detected, it is determined that the preset data element affects the original calculation result of the input data;
[0273] If the calculation association is not detected, it is determined that the preset data element does not affect the original calculation result of the input data.
[0274] The embodiment of the present application can obtain a calculation graph including P dynamic inputs and a bucketing mark of the calculation graph, the bucketing mark being used to indicate a group to which each dynamic input belongs and a bucketing manner of each group, the dynamic shapes of the dynamic inputs in the same group having the same value range, and the value ranges of the dynamic shapes of the dynamic inputs being subjected to bucketing processing according to the bucketing manner of the corresponding group. It can be seen that the embodiment of the present application can record the bucketing manner of the value ranges of the dynamic shapes of the dynamic inputs in the same group by using one piece of information in the form of grouping, which can avoid occupying some memory to record the bucketing manner of the value ranges of the dynamic shapes of each dynamic input, thereby effectively saving the memory of the processor. Further, the value ranges of the dynamic shapes of the P dynamic inputs can be subjected to bucketing processing according to the indication of the bucketing mark before the calculation graph is executed, a plurality of buckets are obtained, and the calculation graph is statically compiled based on the values in each bucket, so that, after the input data of the calculation graph is obtained, the input data is executed on the calculation graph based on the compilation results corresponding to the plurality of buckets to obtain the data calculation result of the input data, which can avoid the case that the processor resource is consumed to compile the calculation graph every time the input data is obtained, thereby effectively saving the overhead generated by the processor and shortening the execution time length of the calculation graph, and further improving the execution efficiency of the calculation graph.
[0275] It should be noted that, according to an aspect of the present application, a computer program product or computer program is also provided, the computer program product or computer program including one or more instructions stored in a computer storage medium. The processor of the computer device reads the one or more instructions from the computer storage medium, and the processor executes the one or more instructions, so that the computer device executes the method provided in any of the various optional manners of the method embodiment aspects. It should be understood that the above only discloses the preferred embodiments of the present application, and of course cannot limit the scope of the rights of the present application, so the equivalent changes made according to the claims of the present application still fall within the scope of the present application.< / bxc> < / axb>
Claims
1. A processing method of a computational graph, characterized by, The method comprises the following steps: obtaining a calculation graph, the calculation graph comprising P dynamic inputs, P being a positive integer; wherein each dynamic input has a dynamic shape, and each dynamic shape has a value range; obtaining a bucketing mark of the calculation graph, the bucketing mark being used to indicate: a group to which each dynamic input belongs and a bucketing manner of each group; wherein the dynamic shapes of the dynamic inputs in the same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed by the bucketing manner of the corresponding group; in a case where it is detected that the calculation graph has a bucketability, processing the value ranges of the dynamic shapes of the P dynamic inputs according to the indication of the bucketing mark to obtain a plurality of buckets; each bucket comprising P values, different values in the P values being selected from different value ranges; wherein the input data comprises at least one data element; the calculation graph records at least one operator, and the manner of detecting whether the calculation graph has the bucketability comprises: traversing each operator recorded by the calculation graph, taking the currently traversed operator as a current operator; according to the data processing logic of the current operator, predicting whether a preset data element affects an original calculation result of the input data when the current operator performs calculation on the input data expanded by using the preset data element; wherein the original calculation result refers to a result obtained by the current operator performing calculation on the input data; if the preset data element affects the original calculation result of the input data, it is determined that the current operator does not satisfy a bucketing condition; if the preset data element does not affect the original calculation result of the input data, it is determined that the current operator satisfies the bucketing condition; after the traversal of each operator, if each operator satisfies the bucketing condition, it is determined that the calculation graph has the bucketability, and if there is at least one operator that does not satisfy the bucketing condition, it is determined that the calculation graph does not have the bucketability; statically compiling the calculation graph based on the values in each bucket to obtain a compilation result corresponding to each bucket; after obtaining the input data of the calculation graph, executing the calculation graph on the input data based on the compilation results corresponding to the plurality of buckets to obtain a data calculation result of the input data.
2. The method of claim 1, wherein, The dynamic shape of the dynamic input comprises values of N dimensions, and there is a dynamic dimension in the N dimensions, N being a positive integer; wherein the dynamic dimension is a dimension whose index value supports dynamic change; the value range of the dynamic shape refers to the value range of the dynamic dimension in the dynamic shape.
3. The method of claim 2, wherein, The bucketing mark comprises: a group mark of each dynamic input, and an attribute mark of at least one group; wherein: the group to which the dynamic input belongs refers to the group to which the dynamic dimension in the dynamic shape of the dynamic input belongs; the group mark of the dynamic input is used to indicate: the dynamic dimension in the dynamic shape of the dynamic input and the group to which the corresponding dynamic dimension belongs; one group corresponds to one value range, and the attribute mark of the group is used to indicate: the value range corresponding to the group and the bucketing manner of the group.
4. The method according to any one of claims 1 to 3, characterized in that, The static compilation of the computation graph based on the values in each bucket obtains a corresponding compilation result of each bucket, including: Traversing the plurality of buckets, a kth bucket currently traversed is determined, k is a positive integer and is less than or equal to the total number of buckets; Respectively, each value in the kth bucket is taken as the value of the dynamic shape of the corresponding dynamic input to obtain the static shape of the kth bucket; wherein when the pth value in the kth bucket is selected from the value range of the dynamic shape of the pth dynamic input, the pth value corresponds to the pth dynamic input, p∈[1, P]; After the plurality of buckets are traversed, the computation graph is compiled based on the static shape of each bucket to obtain a corresponding compilation result of each bucket.
5. The method according to any one of claims 1 to 3, wherein Each bucket has a static shape; and the computation graph is executed on the input data based on the corresponding compilation results of the plurality of buckets to obtain a data computation result of the input data, including: Based on the shape of the input data, a target bucket is selected from the plurality of buckets, and the static shape of the target bucket is greater than or equal to the shape of the input data; When the static shape of the target bucket is greater than the shape of the input data, the input data is expanded to obtain expanded data, and the shape of the expanded data is the same as the static shape in the target bucket; Based on the corresponding compilation result of the target bucket, the computation graph is executed on the expanded data to obtain a data computation result of the expanded data; Reference information for shape prediction is obtained, and the reference information is generated based on the computation logic of the computation graph; and a target output shape is predicted according to the shape of the input data and the reference information, and the target output shape is the shape of the data computation result corresponding to the input data; Based on the target output shape, the data computation result of the expanded data is extracted to obtain the data computation result corresponding to the input data.
6. The method of claim 5, wherein, The reference information includes a target shape calculation formula, the variables in the target shape calculation formula are the values in the shape of the input data, and the value of the target shape calculation formula represents the value of the tth dimension in the target output shape, t is a positive integer and is less than or equal to the number of dimensions in the target output shape; The target output shape is predicted according to the shape of the input data and the reference information, including: The target shape calculation formula is called, and the value of the tth dimension in the target output shape is calculated based on the values in the shape of the input data to obtain a target value; From the shape of the data computation result of the expanded data, the values of each dimension except the tth dimension are obtained; The obtained values of each dimension and the target value are integrated to obtain the target output shape.
7. The method of claim 6, wherein, The computation graph includes a plurality of nodes, each node has a respective data processing logic, and the data processing logic of the plurality of nodes constitutes the operation logic of the computation graph; The process of generating the target shape calculation formula based on the operation logic of the computation graph includes: based on the topology of the computation graph, a plurality of nodes in the computation graph are sorted to obtain a topological order of the plurality of nodes; According to the topological order of the plurality of nodes, each node is processed according to the data processing logic of the corresponding node in turn, and the shape calculation formula of each node is obtained; wherein the variable in the shape calculation formula of any node is the value in the shape of the input data; The shape calculation formula of the last node is taken as the target shape calculation formula.
8. The method of claim 7, wherein, The plurality of nodes include: P input nodes, R operator nodes and an output node, R is a positive integer; wherein one input node represents a dynamic input of the computation graph, and the dynamic shape of each input node includes dynamic dimensions; Each input node is a starting node indicated by the topological order, and the output node is the last node indicated by the topological order; wherein: The processing of the i-th input node comprises: generating a shape calculation formula of the i-th input node based on a variable x i and a dimension j of a dynamic dimension in a dynamic shape of the i-th input node, recording the generated shape calculation formula on an output shape of the i-th input node, and transmitting the output shape of the i-th input node to a next node of the i-th input node; wherein the shape calculation formula of the i-th input node is used to indicate that a value of the j-th dimension in the dynamic shape of the i-th input node is the variable x i ; i ∈ [1, P], j is a positive integer; The processing of the rth operator node includes: according to the data processing logic of the rth operator node and the shape received by the rth operator node, the output shape of the rth operator node is derived, and the derived output shape is transmitted to the next node of the rth operator node, r∈[1,R]; The processing of the output node includes: taking the shape received by the output node as the output shape of the output node, and recording the shape calculation formula on the output shape of the output node.
9. The method of claim 8, wherein, The shape received by the rth operator node is represented as a target shape; When the data processing logic of the rth operator node includes: the calculation operation for the target shape, the shape calculation formula in the target shape is recorded on the output data of the rth operator node, then the processing of the rth operator node further includes: transmitting the output data of the rth operator node to the next node of the rth operator node.
10. The method of claim 1, wherein, According to the data processing logic of the current operator, when the input data is expanded by using the preset data element, the current operator is used to calculate the expanded input data, whether the preset data element affects the original calculation result of the input data, including: According to the data processing logic of the current operator, when the input data is expanded by using the preset data element, the current operator is used to calculate the expanded input data, whether there is a calculation operation for the preset data element; If there is no calculation operation for the preset data element, it is determined that the preset data element does not affect the original calculation result of the input data.
11. The method of claim 10, wherein, The method further comprises: If there is a calculation operation for the preset data element, then according to the data processing logic of the current operator, the calculation association between the preset data element and the input data is detected; If the calculation association is detected, it is determined that the preset data element affects the original calculation result of the input data; If the calculation association is not detected, it is determined that the preset data element does not affect the original calculation result of the input data.
12. A processing device for computing a graph, characterized in that including: An acquisition unit is configured to acquire a computation graph, the computation graph comprising P dynamic inputs, P being a positive integer; wherein each dynamic input has a dynamic shape, and each dynamic shape has a value range; The acquisition unit is further configured to acquire a bucketing mark of the computation graph, the bucketing mark being configured to indicate a group to which each dynamic input belongs and a bucketing manner of each group; wherein the dynamic shapes of the dynamic inputs in a same group have the same value range, and the value ranges of the dynamic shapes of the dynamic inputs are processed according to the bucketing manner of the corresponding group; A processing unit is configured to, when it is detected that the computation graph has a bucketability, process the value ranges of the dynamic shapes of the P dynamic inputs according to the indication of the bucketing mark to obtain a plurality of buckets; each bucket comprises P values, and different values in the P values are selected from different value ranges; wherein the input data comprises at least one data element; the computation graph records at least one operator; the manner of detecting whether the computation graph has the bucketability comprises: traversing each operator recorded by the computation graph, taking a currently traversed operator as a current operator; according to a data processing logic of the current operator, predicting whether a preset data element affects an original calculation result of the input data when the current operator calculates the input data expanded by using the preset data element; wherein the original calculation result refers to a result obtained by the current operator calculating the input data; if the preset data element affects the original calculation result of the input data, it is determined that the current operator does not satisfy a bucketing condition; if the preset data element does not affect the original calculation result of the input data, it is determined that the current operator satisfies the bucketing condition; after the traversal of each operator, if each operator satisfies the bucketing condition, it is determined that the computation graph has the bucketability; if there is at least one operator that does not satisfy the bucketing condition, it is determined that the computation graph does not have the bucketability; The processing unit is further configured to perform static compilation on the computation graph based on the values in each bucket to obtain a compilation result corresponding to each bucket; The processing unit is further configured to, after acquiring input data of the computation graph, execute the computation graph on the input data based on the compilation results corresponding to the plurality of buckets to obtain a data calculation result of the input data.
13. A computer device comprising an input interface and an output interface, characterized in that, Further comprising: a processor and a computer storage medium; wherein the processor is adapted to implement one or more instructions, the computer storage medium stores one or more instructions, and the one or more instructions are adapted to be loaded and executed by the processor to implement the processing method of the computation graph according to any one of claims 1-11.
14. A computer storage medium, characterized in that, The computer storage medium stores one or more instructions, and the one or more instructions are adapted to be loaded and executed by the processor to implement the processing method of the computation graph according to any one of claims 1-11.
15. A computer program product, characterised in that, The computer program product comprises one or more instructions; the one or more instructions in the computer program are executed by a processor to implement the processing method of the computational graph according to any one of claims 1-11.
Citation Information
Patent Citations
Compiling method and device, equipment and storage medium
CN118672592A