Operator execution method, device, electronic device and storage medium

By receiving the status information of the operators to be executed and optimizing their execution order and memory management, the problem of uncertainty and frequent context switching in the memory recycling phase in the dynamic graph computing model is solved, and the data processing efficiency and memory utilization of the neural network are improved. .

CN112631781BActive Publication Date: 2024-09-17SHANGHAI SENSETIME INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011592916.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-29
Publication Date
2024-09-17
Estimated Expiration
2040-12-29

AI Technical Summary

Technical Problem

When a neural network based on a dynamic graph computing model performs data processing tasks, the structure of the neural network is not fixed, which makes it impossible to determine the stage of memory recycling in advance. Existing memory cleaning methods are inefficient, and frequent context switching leads to low data processing efficiency.

Method used

By receiving the status information of the operators to be executed, determining their type and quantity, adding the operators to the target queue based on the status information, and executing them collectively when the quantity threshold is reached, optimizing the execution order and memory management of the operators, reducing context switching, and improving Execution efficiency.

Benefits of technology

It improves the execution efficiency and memory usage efficiency of operators, ensures memory reliability, reduces the waiting time of operators to be executed, and makes full use of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112631781B
    Figure CN112631781B
Patent Text Reader

Abstract

The present disclosure provides an operator execution method, device, electronic device and storage medium, wherein the method includes: an operator execution method, characterized in that it includes: in response to receiving a first operator to be executed, determining the state information of the first operator; and executing or not executing the operator to be executed according to the state information, wherein the operator to be executed includes the first operator and a second operator received before receiving the first operator. The embodiment of the present disclosure can centrally execute the current operator to be executed after determining that the current operator to be executed is to be executed, thereby improving the execution efficiency of the operator.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of deep learning technology, and in particular to an operator execution method, device, electronic device and storage medium. Background Art

[0002] The neural network structure is not fixed when the neural network based on the dynamic graph computing model performs data processing tasks, which makes it impossible to determine the amount of memory required at different stages of the data processing process, and thus it is impossible to set memory recycling nodes for the data processing process in advance. The current memory cleaning method sets memory cleaning operators for the calculation operators and auxiliary operators of the neural network; once a calculation operator or auxiliary operator is executed, the corresponding memory cleaning operator is executed to clean up the memory. This method has the problem of low data processing efficiency. Summary of the invention

[0003] The embodiments of the present disclosure at least provide an operator execution method, device, electronic device, and storage medium.

[0004] In a first aspect, an embodiment of the present disclosure provides an operator execution method, comprising: in response to receiving a first operator to be executed, determining status information of the first operator; and executing or not executing the operator to be executed according to the status information, wherein the operator to be executed includes the first operator and a second operator received before receiving the first operator.

[0005] In this way, after receiving the first operator, the status information of the first operator can be determined, and based on the status information of the first operator, it is determined whether to execute or not to execute the current operator to be executed, so that after determining that the current operator to be executed is to be executed, the current operator to be executed can be executed centrally, thereby improving the execution efficiency of the operator.

[0006] In a possible implementation, the state information includes an operator type, and the operator type includes at least one of a calculation operator, an auxiliary operator, and a memory cleanup operator.

[0007] In a possible implementation, the state information further includes the number of operators corresponding to the operator type in the operators to be executed.

[0008] In one possible implementation, executing or not executing the operator to be executed according to the status information includes: in response to the status information characterizing that the operator type of the first operator is a computing operator or a memory cleanup operator, adding the first operator to a target queue, the target queue being a first queue for storing computing operators or a second queue for storing memory cleanup operators.

[0009] In a possible implementation, after adding the first operator to the target queue, the method further includes: in response to the number of operators in the target queue reaching a quantity threshold, sequentially executing the operators in the first queue and the operators in the second queue among the operators to be executed.

[0010] In this way, the number of computing operators and memory cleaning operators in the operators to be executed can be controlled, so that the operators can maintain benign and efficient execution.

[0011] In a possible implementation, the method is applied to an electronic device, and the quantity threshold is positively correlated with the memory of the electronic device.

[0012] In this way, the reliability of the operator electronic device memory can be ensured through the memory of the electronic device and the threshold value of the number of operators to be executed dynamically.

[0013] In a possible implementation, executing or not executing the to-be-executed operator according to the state information includes:

[0014] In response to the state information indicating that the operator type of the first operator is an auxiliary operator, the operators in the first queue, the first operator, and the operators in the second queue among the operators to be executed are executed in sequence, the first queue is used to store calculation operators, and the second queue is used to store memory cleanup operators.

[0015] In this way, the execution order between auxiliary operators and calculation operators is guaranteed, and the efficiency of operator execution is improved.

[0016] In one possible implementation, the execution of the operator to be executed includes: in the process of executing the third operator in the operator to be executed, determining whether the content pointed to by the object pointer is empty; in response to the content pointed to by the object pointer being non-empty, based on the context corresponding to the third operator and the content pointed to by the object pointer, determining whether to update the content pointed to by the object pointer to execute the third operator.

[0017] In a possible implementation, the determining whether to update the content pointed to by the object pointer to execute the third operator based on the context corresponding to the third operator and the content pointed to by the object pointer includes: in response to the context corresponding to the third operator being the same as the content pointed to by the object pointer, reusing the content pointed to by the object pointer and executing the third operator.

[0018] In this way, by reusing the contexts corresponding to operators of the same type, the time required for context switching is reduced and the execution efficiency of operators is improved.

[0019] In a possible implementation, the method further includes: in response to the content pointed to by the object pointer being non-null, and the context corresponding to the third operator is different from the content pointed to by the object pointer, or, in response to the content pointed to by the object pointer being null, pointing the object pointer to the context corresponding to the third operator, and executing the third operator.

[0020] In a possible implementation, the method further includes: in response to the content pointed to by the object pointer being non-null and the context corresponding to the third operator being different from the content pointed to by the object pointer, reclaiming the memory occupied by the content pointed to by the object pointer.

[0021] Here, after executing a certain type of operator, the memory occupied by the context corresponding to the operator during the execution process can be cleared, thereby ensuring that the current available memory can meet subsequent usage requirements and improving memory usage efficiency.

[0022] In a possible implementation, the context includes a data object for storing local variables and / or flags.

[0023] In a second aspect, an embodiment of the present disclosure further provides an operator execution device, comprising: a determination module, configured to determine state information of a first operator to be executed in response to receiving the first operator to be executed;

[0024] A processing module is used to execute or not execute the to-be-executed operator according to the state information, where the to-be-executed operator includes the first operator and a second operator received before the first operator is received.

[0025] In a possible implementation, the state information includes an operator type, and the operator type includes at least one of a calculation operator, an auxiliary operator, and a memory cleanup operator.

[0026] In a possible implementation, the state information further includes the number of operators corresponding to the operator type in the operators to be executed.

[0027] In a possible implementation manner, when executing or not executing the to-be-executed operator according to the state information, the processing module is configured to:

[0028] In response to the state information indicating that the operator type of the first operator is a computing operator or a memory cleaning operator, the first operator is added to a target queue, where the target queue is a first queue for storing computing operators or a second queue for storing memory cleaning operators.

[0029] In a possible implementation manner, after adding the first operator to the target queue, the processing module is further configured to:

[0030] In response to the number of operators in the target queue reaching a number threshold, operators in the first queue and operators in the second queue among the operators to be executed are executed in sequence.

[0031] In a possible implementation, the method is applied to an electronic device, and the quantity threshold is positively correlated with the memory of the electronic device.

[0032] In a possible implementation manner, when executing or not executing the to-be-executed operator according to the state information, the processing module is configured to:

[0033] In response to the state information indicating that the operator type of the first operator is an auxiliary operator, the operators in the first queue, the first operator, and the operators in the second queue among the operators to be executed are executed in sequence, the first queue is used to store calculation operators, and the second queue is used to store memory cleanup operators.

[0034] In a possible implementation manner, the processing module, when executing the operator to be executed, is used to:

[0035] During the execution of the third operator in the operators to be executed, determining whether the content pointed to by the object pointer is empty;

[0036] In response to the content pointed to by the object pointer being non-null, based on the context corresponding to the third operator and the content pointed to by the object pointer, it is determined whether to update the content pointed to by the object pointer to execute the third operator.

[0037] In a possible implementation, the processing module, when determining whether to update the content pointed to by the object pointer based on the context corresponding to the third operator and the content pointed to by the object pointer to execute the third operator, is configured to:

[0038] In response to the context corresponding to the third operator being the same as the content pointed to by the object pointer, the content pointed to by the object pointer is reused, and the third operator is executed.

[0039] In a possible implementation manner, the processing module is further used to:

[0040] In response to the content pointed to by the object pointer being non-null, and the context corresponding to the third operator is different from the content pointed to by the object pointer, or in response to the content pointed to by the object pointer being null, the object pointer is pointed to the context corresponding to the third operator, and the third operator is executed.

[0041] In a possible implementation manner, the processing module is further used to:

[0042] In response to the content pointed to by the object pointer being non-null, and the context corresponding to the third operator being different from the content pointed to by the object pointer, the memory occupied by the content pointed to by the object pointer is reclaimed.

[0043] In a possible implementation, the context includes a data object for storing local variables and / or flags.

[0044] In a third aspect, an optional implementation of the present disclosure further provides an electronic device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory, and when the machine-readable instructions are executed by the processor, the machine-readable instructions perform the steps of the above-mentioned first aspect, or any possible implementation of the first aspect.

[0045] In a fourth aspect, an optional implementation of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are executed.

[0046] For a description of the effects of the above-mentioned operator execution device, electronic device, and computer-readable storage medium, please refer to the description of the above-mentioned operator execution method, which will not be repeated here.

[0047] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0049] Figure 1 A flowchart of an operator execution method provided by an embodiment of the present disclosure is shown;

[0050] Figure 2 A flowchart showing a specific method for executing an operator to be executed in the operator execution method provided in an embodiment of the present disclosure;

[0051] Figure 3A schematic diagram of an operator execution device provided by an embodiment of the present disclosure is shown;

[0052] Figure 4 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0054] According to research, a neural network based on a dynamic graph computing model (hereinafter referred to as a dynamic model) refers to a computing engine that dynamically adjusts the structure of the neural network used according to the actual situation during the processing process when using the dynamic model to perform data processing tasks on the data to be processed. In this dynamic model, the structure of the dynamic model that performs data processing tasks on different data to be processed may be different; for example, when processing the data to be processed, it will be compared with a preset threshold, and different subsequent processing processes will correspond to different comparison results. Different subsequent processing processes will result in differences in the structure, parameters, quantity, data processing process, etc. of the required network layers, which in turn will cause differences in the network structures determined for different data to be processed.

[0055] The computing nodes in the dynamic model can be classified into computing operators, auxiliary operators, and memory cleaning operators according to their functions. Among them, computing operators are used to undertake actual computing tasks, such as convolution, pooling, full connection, etc.; auxiliary operators are used to provide auxiliary functions, such as data reading, data copying, data synchronization, etc.; memory cleaning operators are used to control the release of memory, such as cleaning up the calculation results. Among them, the execution order of computing operators is certain, and the execution order between computing operators and auxiliary operators is also certain. There is no execution order requirement between memory cleaning operators, and there is a constraint on the execution order between computing operators and corresponding memory cleaning operators. The memory cleaning operator cannot be executed before the corresponding computing operator. When the calculation results of other operators except the memory cleaning operator or the saved intermediate variables are used up at the user level, the memory cleaning operator will be passed to the computing engine. After receiving the memory cleaning operator, the computing engine executes the memory cleaning operator to clean up the calculation results, intermediate variables and other data cached in the memory, so as to ensure that in the subsequent calculation process of other operators, there will be enough space in the memory to store the data generated by the subsequent calculation process.

[0056] Due to the fact that the dynamic model has an unfixed structure, it is impossible to predetermine the stage of memory recovery, and then set the memory cleanup operator for the calculation operator and auxiliary operator of the dynamic model; once a calculation operator or auxiliary operator is executed, the corresponding memory cleanup operator is executed to clean up the memory. Different operator types require the device to switch contexts when executing different operators; and when the device switches contexts, it takes a certain amount of time to schedule resources; the current operator execution method is that each time a calculation operator or auxiliary operator is executed, the corresponding memory cleanup operator will be executed to achieve memory cleanup, and different types of operators have different corresponding contexts, which requires frequent context switching, resulting in low data processing efficiency.

[0057] Based on the above research, the present disclosure provides an operator execution method, which can determine the execution strategy of the operator according to the received status information of the operator to be executed, thereby improving the efficiency of data processing.

[0058] The defects existing in the above solutions are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.

[0059] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0060] To facilitate understanding of this embodiment, an operator execution method disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the operator execution method provided in the embodiment of the present disclosure is generally an electronic device with certain computing capabilities, and the electronic device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the operator execution method can be implemented by a processor calling a computer-readable instruction stored in a memory.

[0061] In the embodiments of the present disclosure, when the electronic device executes the operator execution method provided in the embodiments of the present disclosure, the specific execution subject of the operator is, for example, a computing engine deployed in the electronic device; the application layer of the electronic device can transfer the operator to the computing engine at a certain moment according to the pre-deployed application program. After receiving the operator transferred by the application layer, the computing engine executes the operator according to the operator execution method provided in the embodiments of the present disclosure.

[0062] The operator execution method provided by the embodiment of the present disclosure is described below.

[0063] See also Figure 1 FIG. 1 is a flowchart of an operator execution method provided in an embodiment of the present disclosure, wherein the method includes steps S101 to S102, wherein:

[0064] S101: In response to receiving a first operator to be executed, determining state information of the first operator.

[0065] S102: Execute or not execute a to-be-executed operator according to the state information, where the to-be-executed operator includes the first operator and a second operator received before the first operator is received.

[0066] After receiving the first operator, the embodiment of the present disclosure can determine the status information of the first operator, and based on the status information of the first operator, determine whether to execute or not to execute the current operator to be executed, so that after determining that the current operator to be executed is to be executed, the current operator to be executed can be executed in a concentrated manner, thereby improving the execution efficiency of the operator.

[0067] In a specific implementation, the state information of the first operator, for example, includes: an operator type; the operator type includes at least one of a calculation operator, an auxiliary operator, and a memory cleanup operator.

[0068] After the operator type of the first operator is determined, the strategy for executing the operator may be determined according to the operator type, for example, in the following manner:

[0069] When the operator type of the first operator is a calculation operator, it is determined not to execute the current operator to be executed.

[0070] When the operator type of the first operator is a memory cleanup operator, it is determined not to execute the current to-be-executed operator.

[0071] When the operator type of the first operator is an auxiliary operator, it is determined to execute the current operator to be executed.

[0072] In this way, whether to execute all operators to be executed including the first operator is determined based on the operator type of the currently received first operator.

[0073] In an embodiment of the present disclosure, when executing or not executing an operator to be executed according to status information, for example, in response to the status information characterizing that the operator type of the first operator is a computing operator or a memory cleanup operator, the first operator can be added to a target queue, and the target queue is a first queue for storing computing operators or a second queue for storing memory cleanup operators.

[0074] In this way, the first operator is added to the target queue, and when it is determined to execute the current operator to be executed, each operator to be executed is read from the queue corresponding to each operator type, and the read operator to be executed.

[0075] In another embodiment of the present disclosure, the state information may further include the number of operators corresponding to the operator type of the first operator in the operators to be executed.

[0076] In this case, the quantity threshold corresponding to the operator type of the first operator can be predetermined, and based on the quantity threshold, it is determined whether to execute or not to execute the current operator to be executed. The setting of the quantity threshold can facilitate the management of the first queue and the second queue, that is, based on the number of operators to be executed stored in the first queue or the second queue, it can be determined under what circumstances to execute the operators to be executed stored in the first queue or the second queue.

[0077] For example, the following method can be used to determine the strategy for executing operators according to the number of operators:

[0078] In the case where the operator type of the first operator is a calculation operator, if the number of operators of the type of calculation operators in the operators to be executed is greater than or equal to a first number threshold, it is determined to execute the current operator to be executed; if the number of operators of the type of calculation operators in the operators to be executed is less than the first number threshold, it is determined not to execute the current operator to be executed.

[0079] In the case where the operator type of the first operator is a memory cleanup operator, if the number of operators of the type of the memory cleanup operator in the operators to be executed is greater than or equal to a second number threshold, it is determined to execute the current operator to be executed; if the number of operators of the type of the memory cleanup operator in the operators to be executed is less than the second number threshold, it is determined not to execute the current operator to be executed.

[0080] In the case where the operator type of the first operator is an auxiliary operator, if the number of operators of the auxiliary operator type in the operators to be executed is greater than or equal to a third number threshold, it is determined to execute the current operator to be executed; if the number of operators of the auxiliary operator type in the operators to be executed is less than the third number threshold, it is determined not to execute the current operator to be executed.

[0081] Here, when the target queue is the first queue corresponding to the computing operator, the quantity threshold is the first quantity threshold; when the target queue is the second queue corresponding to the memory cleaning operator, the quantity threshold is the second quantity threshold.

[0082] In this case, in response to the number of operators in the target queue reaching a number threshold, the operators in the first queue and the operators in the second queue among the operators to be executed may be executed in sequence.

[0083] That is, if the number of operators of the calculation operators in the current to-be-executed operators reaches the first number threshold, the calculation operators in the first queue are executed first; after the calculation operators in the first queue are executed, the memory cleanup operators in the current second queue are executed. In this way, the number of calculation operators and memory cleanup operators in the to-be-executed operators can be controlled, so that the execution of the operators is maintained in a benign and efficient manner.

[0084] The execution cycle of an operator is the time from the last time an operator was determined to be executed to the time the operator is determined to be executed. The duration of different cycles may be different or the same depending on the actual situation.

[0085] In addition, since the execution order of auxiliary operators relative to the computing operators is fixed, the third quantity threshold can be set to 1. That is, when the operator type of the first operator received is an auxiliary operator, the current operator to be executed is executed. Therefore, a queue may not be set for auxiliary operators; instead, after the first operator is received, once it is determined that the operator type of the first operator is an auxiliary operator, the current operator to be executed is executed.

[0086] The first quantity threshold and the second quantity threshold can be set according to actual application needs, and can be fixed or dynamically adjusted according to the current operator execution status.

[0087] Exemplarily, when the first quantity threshold and the second quantity threshold are dynamically adjusted according to the current operator execution status, for example, the execution time can be determined for the currently executing operator, and the waiting time can be determined for the currently executed operator; if the execution time of the currently executed operator is less than the waiting time of the currently executed operator, the first quantity threshold and the second quantity threshold can be reduced. In this way, when the application layer of the electronic device transmits operators to the computing engine at a low frequency, resulting in the operators to be executed waiting for a long time to be executed, and the computing resources of the computing engine cannot be fully utilized (that is, the currently executed operator has been executed, but the operator to be executed is still waiting to be executed), reducing the first quantity threshold and the second quantity threshold can reduce the waiting time of the operator to be executed, so that the computing resources of the computing engine can be more fully utilized, and improve the processing efficiency of the operator.

[0088] If the execution time of the currently executing operator is longer than the waiting time of the currently executed operator, the first quantity threshold and the second quantity threshold can be appropriately increased to try to maintain a balance between the execution time of the currently executing operator and the waiting time of the operator to be executed, so that the computing resources of the computing engine can be fully utilized and the operator to be executed will not wait too long and can be processed in time.

[0089] Here, when determining to execute the current operator to be executed, if the number of operators to be executed is too large, the operators to be executed will need to queue for a long time, affecting the processing efficiency of the operators; if the number is too small, the number of operators to be executed will be insufficient, causing the computing engine to still need to switch contexts between different types of operators more frequently, resulting in low operator processing efficiency; therefore, an upper threshold and / or lower threshold can be determined for the first number threshold and the second number threshold, so as to control that when determining to execute the current operator to be executed, the number of operators to be executed will not be too many or too few.

[0090] In another embodiment, the first quantity threshold and the second quantity threshold may also be dynamically determined based on the memory of the electronic device; here, the memory of the electronic device includes, for example, currently available memory. Exemplarily, the first quantity threshold and / or the second quantity threshold are positively correlated with the memory of the electronic device. That is, the larger the memory of the electronic device, the larger the first quantity threshold and / or the second quantity threshold; the smaller the memory of the electronic device, the smaller the first quantity threshold and / or the second quantity threshold. In this way, the number of operators to be executed can be dynamically adjusted based on the memory of the electronic device.

[0091] In another embodiment of the present disclosure, when it is determined that the operator to be executed is to be executed, the operator to be executed may be executed in the following manner, for example:

[0092] In response to the state information indicating that the operator type of the first operator is an auxiliary operator, the operators in the first queue, the first operator, and the operators in the second queue among the operators to be executed are executed in sequence, the first queue is used to store calculation operators, and the second queue is used to store memory cleanup operators.

[0093] Here, since the execution order between the calculation operator and the auxiliary operator is fixed, when the first operator received is an auxiliary operator, the calculation operator in the first operator queue is executed first, then the auxiliary operator, and then the memory cleanup operator in the second queue is executed. This not only ensures the execution order between the calculation operator and the auxiliary operator, but also can execute the memory cleanup operator after the calculation operator and the auxiliary operator in the current operator to be executed are executed, so as to clean up the memory occupied by the current operator to be executed.

[0094] See also Figure 2 As shown, the embodiment of the present disclosure also provides a specific method for executing an operator to be executed, including:

[0095] S201: during the execution of the third operator in the operators to be executed, determining whether the content pointed to by the object pointer is empty;

[0096] S202: In response to the content pointed to by the object pointer being non-null, determine whether to update the content pointed to by the object pointer based on the context corresponding to the third operator and the content pointed to by the object pointer, so as to execute the third operator.

[0097] In a specific implementation, after determining to execute the current operator to be executed, the operator is read according to the operator execution order in the above embodiment, and the read operator is used as the third operator to execute the third operator.

[0098] During the execution of the third operator, it is determined whether the content pointed to by the object pointer is null. Here, the object pointer is used to point to the context of the third operator to be executed when the third operator is to be executed.

[0099] Here, the context includes a data object for storing local variables and / or flags.

[0100] Exemplarily, a context is an abstraction of resources in an electronic device, such as managing temporary resources (local variables) requested when executing an operator, such as video memory resources, graphics processing unit (GPU) resources, memory resources, etc.

[0101] The identification bit can be used, for example, for the state of the electronic device when executing an operator, such as the execution state of the operator, the state of the device, the resources used by the operator, whether the resources are cleared, etc.

[0102] Specifically, the process of executing the third operator is as follows:

[0103] In response to the context corresponding to the third operator being the same as the content pointed to by the object pointer, the content pointed to by the object pointer is reused, and the third operator is executed.

[0104] In this way, by reusing the contexts corresponding to operators of the same type, the time required for context switching is reduced and the execution efficiency of operators is improved.

[0105] In response to the content pointed to by the object pointer being non-null, and the context corresponding to the third operator is different from the content pointed to by the object pointer, or in response to the content pointed to by the object pointer being null, the object pointer is pointed to the context corresponding to the third operator, and the third operator is executed.

[0106] In another embodiment, in response to the content pointed to by the object pointer being non-null and the context corresponding to the third operator being different from the content pointed to by the object pointer, the memory occupied by the content pointed to by the object pointer is reclaimed.

[0107] Here, after executing a certain type of operator, the memory occupied by the context corresponding to the operator during the execution process can be cleared, thereby ensuring that the current available memory can meet subsequent usage requirements and improving memory usage efficiency.

[0108] The present disclosure also provides a specific example of an operator execution method, including the following steps:

[0109] A first operator to be executed is received, and an operator type of the first operator is determined.

[0110] (1) When the operator type of the first operator is a calculation operator, the first operator is added to the first queue, and it is detected whether the first queue is full.

[0111] When the first queue is full, the "first in, first out" principle is followed to execute the calculation operators in the first queue in sequence, and then the memory cleanup operators in the second queue in sequence.

[0112] When the first queue is not full, all the operators to be executed (including the calculation operators in the first queue and the memory cleanup operators in the second queue) may not be executed at present, and the next first operator to be executed may be received.

[0113] (2) When the operator type of the first operator is a memory cleanup operator, the first operator is added to the second queue, and it is detected whether the second queue is full.

[0114] When the second queue is full, the "first in, first out" principle is followed to execute the calculation operators in the first queue in sequence, and then the memory cleanup operators in the second queue in sequence.

[0115] When the second queue is not full, all the operators to be executed (including the calculation operators in the first queue and the memory cleanup operators in the second queue) may not be executed at present, and the next first operator to be executed may be received.

[0116] (3) When the operator type of the first operator is an auxiliary operator, the "first in, first out" principle is followed to execute the calculation operators in the first queue in order, then the auxiliary operators, and then the memory cleanup operators in the second queue in order.

[0117] In the implementation methods mentioned in (1), (2) or (3) above, in the case where an operator needs to be executed, the operator to be executed currently, i.e., the third operator, can be obtained by referring to the order described in (1), (2) or (3) above.

[0118] When the third operator is the first operator executed by the computing engine in this execution cycle (for example, the first operator executed after the computing engine is started), the object pointer points to null. At this time, the object pointer points to the context corresponding to the third operator and executes the third operator.

[0119] When the third operator is not the first operator executed by the computing engine (i.e., at least one operator has been executed after the computing engine is started), if the third operator to be executed is of the same operator type as the last operator executed most recently, the content pointed to by the object pointer is reused and the third operator is executed.

[0120] If the operator type of the third operator to be executed is different from that of the most recently executed operator, the local variables contained in the context pointed to by the object pointer are cleaned up to clear the memory occupied by the context of the previous operator, the object pointer is pointed to the context corresponding to the third operator to implement context switching, and then the third operator is executed.

[0121] Through the above operator execution process, in the above situation (1), the electronic device needs to switch contexts a maximum of 2 times in this execution cycle (at this time, it is assumed that at the beginning of any execution cycle, the object pointer points to null, and the first queue and the second queue are not empty; if the second queue is empty, the number of context switches required is only 1), namely: when the first calculation operator is executed, the object pointer points from null to the context of the first calculation operator; when the first memory cleaning operator is executed, the object pointer is switched from the context of the last calculation operator to the context of the first memory cleaning operator.

[0122] In the above case (2), the electronic device needs to switch contexts a maximum of 2 times in this execution cycle (at this time, it is assumed that at the beginning of any execution cycle, the object pointer points to null, and the first queue and the second queue are not empty), namely: when the first calculation operator is executed, the object pointer points from null to the context of the first calculation operator; when the first memory cleaning operator is executed, the object pointer is switched from the context of the last calculation operator to the context of the first memory cleaning operator.

[0123] In the above case (3), the electronic device needs to switch contexts a maximum of 3 times in this execution cycle (at this time, it is assumed that at the beginning of any execution cycle, the object pointer points to null, and the first queue and the second queue are not empty), namely: when the first calculation operator is executed, the object pointer points from null to the context of the first calculation operator; when the auxiliary operator is executed, the object pointer is switched from the context of the last calculation operator to the context of the auxiliary operator; when the first memory cleaning operator is executed, the object pointer is switched from the context of the auxiliary operator to the context of the first memory cleaning operator.

[0124] It can be known that the operator execution method provided by the embodiment of the present disclosure, for the process of centralized execution of operators of the same type, since the adjacently executed operators belong to the same type, the technical solution provided by the present disclosure can reduce the context switching during the operator execution process by means of context reuse. In particular, for the case of centralized execution of computing operators, the resource consumption and time consumption caused by switching contexts are reduced, which can effectively improve data processing efficiency. In addition, considering that there is no strict definition in the execution order between different memory cleaning operators, therefore, for the case of centralized execution of multiple memory cleaning operators, each memory cleaning operator in the second queue can be executed in parallel, thereby effectively reducing the overall time occupied by data processing and improving data processing efficiency.

[0125] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0126] Based on the same inventive concept, an operator execution device corresponding to the operator execution method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned operator execution method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0127] Reference Figure 3FIG. 1 is a schematic diagram of an operator execution device provided by an embodiment of the present disclosure, wherein the device comprises: a determination module 31 and a processing module 32; wherein:

[0128] A determination module 31, configured to determine state information of a first operator to be executed in response to receiving the first operator to be executed;

[0129] The processing module 32 is used to execute or not execute the to-be-executed operator according to the state information, where the to-be-executed operator includes the first operator and a second operator received before the first operator is received.

[0130] In a possible implementation, the state information includes an operator type, and the operator type includes at least one of a calculation operator, an auxiliary operator, and a memory cleanup operator.

[0131] In a possible implementation, the state information further includes the number of operators corresponding to the operator type in the operators to be executed.

[0132] In a possible implementation manner, the processing module 32, when executing or not executing the to-be-executed operator according to the state information, is configured to:

[0133] In response to the state information indicating that the operator type of the first operator is a computing operator or a memory cleaning operator, the first operator is added to a target queue, where the target queue is a first queue for storing computing operators or a second queue for storing memory cleaning operators.

[0134] In a possible implementation manner, after adding the first operator to the target queue, the processing module 32 is further configured to:

[0135] In response to the number of operators in the target queue reaching a number threshold, operators in the first queue and operators in the second queue among the operators to be executed are executed in sequence.

[0136] In a possible implementation, the method is applied to an electronic device, and the quantity threshold is positively correlated with the memory of the electronic device.

[0137] In a possible implementation manner, the processing module 32, when executing or not executing the to-be-executed operator according to the state information, is configured to:

[0138] In response to the state information indicating that the operator type of the first operator is an auxiliary operator, the operators in the first queue, the first operator, and the operators in the second queue among the operators to be executed are executed in sequence, the first queue is used to store calculation operators, and the second queue is used to store memory cleanup operators.

[0139] In a possible implementation manner, the processing module 32, when executing the operator to be executed, is used to:

[0140] During the execution of the third operator in the operators to be executed, determining whether the content pointed to by the object pointer is empty;

[0141] In response to the content pointed to by the object pointer being non-null, based on the context corresponding to the third operator and the content pointed to by the object pointer, it is determined whether to update the content pointed to by the object pointer to execute the third operator.

[0142] In a possible implementation, the processing module 32, when determining whether to update the content pointed to by the object pointer based on the context corresponding to the third operator and the content pointed to by the object pointer to execute the third operator, is configured to:

[0143] In response to the context corresponding to the third operator being the same as the content pointed to by the object pointer, the content pointed to by the object pointer is reused, and the third operator is executed.

[0144] In a possible implementation manner, the processing module 32 is further configured to:

[0145] In response to the content pointed to by the object pointer being non-null, and the context corresponding to the third operator is different from the content pointed to by the object pointer, or in response to the content pointed to by the object pointer being null, the object pointer is pointed to the context corresponding to the third operator, and the third operator is executed.

[0146] In a possible implementation manner, the processing module 32 is further configured to:

[0147] In response to the content pointed to by the object pointer being non-null, and the context corresponding to the third operator being different from the content pointed to by the object pointer, the memory occupied by the content pointed to by the object pointer is reclaimed.

[0148] In a possible implementation, the context includes a data object for storing local variables and / or flags.

[0149] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0150] The present disclosure also provides an electronic device, such as Figure 4 FIG. 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure, including:

[0151] A processor 11 and a memory 12; the memory 12 stores machine-readable instructions executable by the processor 11, and when the electronic device is running, the machine-readable instructions are executed by the processor to implement the following steps:

[0152] In response to receiving a first operator to be executed, determining state information of the first operator;

[0153] According to the state information, operators to be executed are executed or not executed, where the operators to be executed include the first operator and a second operator received before the first operator is received.

[0154] The specific execution process of the above instructions can refer to the steps of the operator execution method described in the embodiment of the present disclosure, which will not be repeated here.

[0155] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the operator execution method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0156] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the operator execution method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0157] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0158] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0159] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0160] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0161] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0162] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. An operator execution method, characterized in that: include: In response to receiving a first operator to be executed, determining state information of the first operator; executing or not executing the to-be-executed operator according to the state information, the to-be-executed operator including the first operator and the second operator received before the first operator is received; the state information includes an operator type and the number of operators corresponding to the operator type in the to-be-executed operators; the operator type includes at least one of a calculation operator, an auxiliary operator, and a memory cleanup operator; The executing or not executing the to-be-executed operator according to the state information includes: In response to the state information indicating that the operator type of the first operator is a computing operator or a memory cleaning operator, adding the first operator to a target queue, where the target queue is a first queue for storing computing operators or a second queue for storing memory cleaning operators; In response to the number of operators in the target queue reaching a number threshold, operators in the first queue and operators in the second queue among the operators to be executed are executed in sequence.

2. The operator execution method according to claim 1, characterized in that: The method is applied to an electronic device, and the quantity threshold is positively correlated with the memory of the electronic device.

3. The operator execution method according to claim 1 or 2, characterized in that: The executing or not executing the to-be-executed operator according to the state information further includes: In response to the state information indicating that the operator type of the first operator is an auxiliary operator, the operators in the first queue, the first operator, and the operators in the second queue among the operators to be executed are executed in sequence, the first queue is used to store calculation operators, and the second queue is used to store memory cleanup operators.

4. The operator execution method according to claim 1, characterized in that: Executing the operator to be executed includes: During the execution of the third operator in the operators to be executed, determining whether the content pointed to by the object pointer is empty; In response to the content pointed to by the object pointer being non-null, based on the context corresponding to the third operator and the content pointed to by the object pointer, it is determined whether to update the content pointed to by the object pointer to execute the third operator.

5. The operator execution method according to claim 4, characterized in that: The determining, based on the context corresponding to the third operator and the content pointed to by the object pointer, whether to update the content pointed to by the object pointer to execute the third operator includes: In response to the context corresponding to the third operator being the same as the content pointed to by the object pointer, the content pointed to by the object pointer is reused, and the third operator is executed.

6. The operator execution method according to claim 4 or 5, characterized in that: The method further comprises: In response to the content pointed to by the object pointer being non-null, and the context corresponding to the third operator is different from the content pointed to by the object pointer, or in response to the content pointed to by the object pointer being null, the object pointer is pointed to the context corresponding to the third operator, and the third operator is executed.

7. The operator execution method according to claim 6, characterized in that: The method further comprises: In response to the content pointed to by the object pointer being non-null, and the context corresponding to the third operator being different from the content pointed to by the object pointer, the memory occupied by the content pointed to by the object pointer is reclaimed.

8. The operator execution method according to claim 4, characterized in that: The context includes a data object for storing local variables and / or flags.

9. An operator execution device, characterized in that: include: a determination module, configured to determine, in response to receiving a first operator to be executed, state information of the first operator; a processing module, configured to execute or not execute a to-be-executed operator according to the state information, wherein the to-be-executed operator includes the first operator and a second operator received before the first operator is received; the state information includes an operator type and the number of operators corresponding to the operator type in the to-be-executed operators; the operator type includes at least one of a calculation operator, an auxiliary operator, and a memory cleanup operator; The processing module, when executing or not executing the to-be-executed operator according to the state information, is used to: In response to the state information indicating that the operator type of the first operator is a computing operator or a memory cleaning operator, adding the first operator to a target queue, where the target queue is a first queue for storing computing operators or a second queue for storing memory cleaning operators; In response to the number of operators in the target queue reaching a number threshold, operators in the first queue and operators in the second queue among the operators to be executed are executed in sequence.

10. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the processor executes the steps of the operator execution method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program. When the computer program is executed by an electronic device, the electronic device executes the steps of the operator execution method according to any one of claims 1 to 8.