Task execution method, device and storage medium

By analyzing the execution dependencies between operators and dividing them into parallel and serial operators, corresponding task control classes are constructed to call thread execution operators in the thread pool, the problem of low operator scheduling efficiency in the existing technology is solved, and the task execution speed is improved.

CN119336512BActive Publication Date: 2025-04-04ZHEJIANG DAHUA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411866626.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-04
Estimated Expiration
2044-12-18

AI Technical Summary

Technical Problem

The prior art is difficult to improve the efficiency of operator scheduling in tasks integrated by multiple operators, resulting in limited task execution speed.

Method used

By obtaining the execution dependency between each operator in the operator set, the operators that do not have execution dependencies are divided into parallel operators, and the operators that have execution dependencies are divided into series operators, and the task control class is built separately or uniformly for each series operator and parallel operator, and the thread execution operator in the thread pool is called to obtain the execution result of the target task.

Benefits of technology

By flexibly adjusting the operators allocated by task control, the maximum concurrency of the same batch of data and the concurrency between different batches of data can be ensured at the same time, and the efficiency of task execution can be improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336512B_ABST
    Figure CN119336512B_ABST
Patent Text Reader

Abstract

The present application discloses a task execution method, device and storage medium, the task execution method comprising: in response to a received target task, obtaining an operator set for executing the target task; obtaining the execution dependency between each operator in the operator set, dividing operators that do not have execution dependencies between each other into parallel operators, and dividing operators that have execution dependencies between each other into series operators; for each series operator, separately constructing a task control class, and for parallel operators that are connected in parallel, uniformly constructing a task control class; based on the task control class corresponding to the series operator and / or the task control class corresponding to the parallel operator, calling a thread to execute the series operator and / or the parallel operator to obtain the execution result of the target task, the operator assigned to each task control class can be flexibly adjusted, while ensuring the maximum concurrency of the same batch of data and the concurrency of different batches of data between different operators, thereby improving the efficiency of task execution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a task execution method, device and storage medium. Background Art

[0002] When a computer executes a task, one task can be split into multiple operator tasks. For example, an image analysis task can be split into operator tasks such as image decoding, image feature extraction, and result generation, so as to utilize a multi-core central processing unit (CPU) or graphics processing unit (GPU) for parallel computing and speed up image processing.

[0003] For tasks integrated by multiple operators, how to improve the efficiency of operator scheduling and increase the task execution speed is an urgent problem to be solved by technical personnel in this field. Summary of the invention

[0004] In order to solve the above technical problems, the present application at least provides a task execution method, device and storage medium.

[0005] The first aspect of the present application provides a task execution method, the method comprising: in response to a received target task, obtaining an operator set for executing the target task; obtaining the execution dependency between each operator in the operator set, dividing the operators that do not have execution dependencies between each other into parallel operators, and dividing the operators that have execution dependencies between each other into series operators; for each series operator, separately constructing a task control class, and for parallel operators that are connected in parallel with each other, uniformly constructing a task control class; wherein the task control class is used to call threads in a thread pool, and the threads are used to call computing resources to execute operators; based on the task control class corresponding to the series operator and / or the task control class corresponding to the parallel operator, calling the thread to execute the series operator and / or the parallel operator to obtain the execution result of the target task.

[0006] In one embodiment, an execution dependency relationship between each operator in an operator set is obtained, and operators that do not have an execution dependency relationship between each other are divided into parallel operators, and operators that have an execution dependency relationship between each other are divided into series operators, including: analyzing the input data required for executing each operator in the operator set; if the input data required by the first operator contains the execution result of the second operator, it is determined that the first operator has an execution dependency relationship with the second operator, and the first operator and the second operator are divided into series operators connected in series with each other; if the execution result of the first operator is not the input data required by the second operator, and the execution result of the second operator is not the input data required by the first operator, it is determined that the first operator does not have an execution dependency relationship with the second operator, and the first operator and the second operator are divided into parallel operators connected in parallel with each other.

[0007] In one embodiment, an execution dependency relationship between each operator in an operator set is obtained, and operators that do not have execution dependencies between each other are divided into parallel operators, and operators that have execution dependencies between each other are divided into series operators, including: obtaining a tree structure representation corresponding to the operator set, in which the operators are used as nodes, and the connected edges between the nodes represent the existence of execution dependencies between the nodes; the operators corresponding to the nodes that have connected edges in the tree structure representation are divided into series operators, and the operators corresponding to the nodes that do not have connected edges in the tree structure representation are divided into parallel operators.

[0008] In one embodiment, the task control class stores operator handles corresponding to the serial operator and / or the parallel operator respectively; based on the task control class corresponding to the serial operator and / or the task control class corresponding to the parallel operator, the thread is called to execute the serial operator and / or the parallel operator to obtain the execution result of the target task, including: based on the execution order between the serial operators and / or the parallel operators corresponding to each task control class, the execution order between each task control class is obtained; according to the execution order between each task control class, each task control class is executed in sequence; based on the operator handle stored in the currently executed task control class, the thread corresponding to the serial operator and / or the parallel operator in the thread pool is called to execute the serial operator and / or the parallel operator to obtain the execution result of the currently executed task control class; the execution result of the currently executed task control class is transmitted to the next executed task control class to execute the serial operator and / or the parallel operator; in response to the completion of the execution of all task control classes, the execution result of the target task is obtained.

[0009] In one embodiment, a task control class is deployed with multiple data input channels, and different data input channels are used to process input data corresponding to target tasks from different sources, and each data input channel stores an operator handle corresponding to a serial operator and / or a parallel operator; based on the operator handle stored in the currently executed task control class, the thread corresponding to the serial operator and / or the parallel operator in the thread pool is called to execute the serial operator and / or the parallel operator to obtain the execution result of the currently executed task control class, including: obtaining a data input channel that matches the source of the target task to obtain the target input channel; based on the operator handle corresponding to the target input channel of the currently executed task control class, the thread corresponding to the serial operator and / or the parallel operator in the thread pool is called to execute the serial operator and / or the parallel operator to obtain the execution result of the currently executed task control class.

[0010] In one embodiment, the operator includes a data processing neural network model, different data processing neural network models correspond to different batch sizes, and the batch size is used to limit the amount of data input into the data processing neural network model at a single time; the method also includes: integrating multiple data processing neural network models with different batch sizes to obtain an integrated model; allocating computing resources required for the largest batch size among multiple different batch sizes to the integrated model, and using the integrated model to process the input data corresponding to the operator.

[0011] In one embodiment, the input data corresponding to the operator is processed using an integrated model, including: filtering invalid data on the input data corresponding to the operator to obtain filtered input data; based on the batch size corresponding to the filtered input data, inputting the filtered input data into the integrated model matching the batch size for processing.

[0012] In one embodiment, the target task includes an image analysis task; before obtaining a set of operators for executing the target task in response to the received target task, the method also includes: adding the input image to a corresponding image directory based on the object type of the target object contained in the input image; creating workflows corresponding to each image directory, the workflows read the input images from the corresponding image directories respectively, and adding the read input images to a scheduling queue; in response to the received target task, obtaining a set of operators for executing the target task, including: the workflow creates an image analysis task, the image analysis task extracts the input image from the scheduling queue, and obtains a set of operators for analyzing the input image.

[0013] The second aspect of the present application provides a task execution device, which includes: an operator acquisition module, which is used to respond to a received target task and acquire an operator set for executing the target task; an operator partitioning module, which is used to acquire the execution dependency between each operator in the operator set, and divide the operators that have no execution dependency relationship between each other into parallel operators, and divide the operators that have execution dependency relationship between each other into series operators; a control class construction module, which is used to separately construct a task control class for each series operator, and uniformly construct a task control class for parallel operators that are connected in parallel with each other; wherein the task control class is used to call a thread in a thread pool, and the thread is used to call computing resources to execute the operator; an operator execution module, which is used to call a thread to execute the series operator and / or the parallel operator based on the task control class corresponding to the series operator and / or the task control class corresponding to the parallel operator to obtain the execution result of the target task.

[0014] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned task execution method.

[0015] A fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, which implement the above-mentioned task execution method when the program instructions are executed by a processor.

[0016] The above scheme obtains an operator set for executing the target task in response to the received target task; obtains the execution dependency between each operator in the operator set, divides the operators that have no execution dependency between each other into parallel operators, and divides the operators that have execution dependency between each other into series operators; constructs a task control class separately for each series operator, and uniformly constructs a task control class for parallel operators that are connected in parallel with each other; based on the task control class corresponding to the series operator and / or the task control class corresponding to the parallel operator, calls the thread to execute the series operator and / or the parallel operator to obtain the execution result of the target task, and can flexibly adjust the operators assigned to each task control class to simultaneously ensure the maximum concurrency of the same batch of data and the concurrency of different batches of data between different operators, thereby improving the efficiency of task execution.

[0017] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0019] Figure 1 It is a schematic diagram of a solution implementation environment provided by an embodiment of the present application;

[0020] Figure 2 is a flowchart of a task execution method shown in an exemplary embodiment of the present application;

[0021] Figure 3 is a schematic diagram of the division of series operators and parallel operators shown in an exemplary embodiment of the present application;

[0022] Figure 4 is a schematic diagram of constructing a task control class shown in an exemplary embodiment of the present application;

[0023] Figure 5 is a schematic diagram of a task control class shown in an exemplary embodiment of the present application;

[0024] Figure 6 is a workflow diagram of image analysis shown in an exemplary embodiment of the present application;

[0025] Figure 7 is a block diagram of a task execution device shown in an exemplary embodiment of the present application;

[0026] Figure 8 is a schematic structural diagram of an electronic device shown in an exemplary embodiment of the present application;

[0027] Fig. 9 It is a schematic diagram of the structure of a computer-readable storage medium shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0028] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.

[0029] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.

[0030] The term "and / or" in this article is only an association information describing the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the previous and next associated objects are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.

[0031] The following is a description of the task execution method provided in the embodiments of the present application.

[0032] Please refer to Figure 1 , which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application. The solution implementation environment may include a terminal 110 and a server 120, and the terminal 110 and the server 120 are connected to each other in communication.

[0033] The number of the terminal 110 may be one or more. The terminal 110 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.

[0034] Server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0035] In one example, the server 120 may execute the corresponding target task according to the data obtained from the terminal 110 to obtain the execution result of the target task. Of course, the server 120 may store the execution result of the target task locally, transmit it back to the terminal 110, or transmit it to other terminals.

[0036] It should be noted that, in the task execution method provided in the embodiment of the present application, the execution subject of each step can be the terminal 110 or the server 120, or the execution can be performed by the terminal 110 and the server 120 in interaction, that is, part of the steps of the method are executed by the terminal 110 and the other steps are executed by the server 120.

[0037] See also Figure 2 , Figure 2 is a flowchart of a task execution method shown in an exemplary embodiment of the present application. The task execution method can be applied to Figure 1 It should be understood that the method can also be applied to other exemplary implementation environments and be specifically executed by devices in other implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable.

[0038] like Figure 2 As shown, the task execution method at least includes steps S210 to S240, which are described in detail as follows:

[0039] Step S210: In response to the received target task, obtain an operator set for executing the target task.

[0040] Among them, the target tasks include but are not limited to image recognition tasks, audio processing tasks, text processing tasks, etc. This application does not limit the type of target tasks.

[0041] For each type of target task, an operator set for executing the target task is pre-set. The operator set consists of multiple operators. The operator is used to define the logic of data processing, is responsible for processing elements in the data stream, and performs specific computing tasks.

[0042] For example, an image analysis task can be split into operator tasks such as image decoding, image feature extraction, and result generation.

[0043] Step S220: Obtain the execution dependency relationship between each operator in the operator set, divide the operators that have no execution dependency relationship between each other into parallel operators, and divide the operators that have execution dependency relationship between each other into serial operators.

[0044] There may be execution dependencies between operators in an operator set. That is, if the execution of one operator depends on part or all of the execution results of another operator, it indicates that there is an execution dependency between the two operators, and the two operators are serial operators. On the contrary, if the execution result of one operator is not used for the execution of another operator, it indicates that there is no dependency between the two operators, and the two operators are parallel operators.

[0045] The execution dependency relationship between each operator in the operator set may be pre-stored to directly obtain the execution dependency relationship between each operator, or the dependency relationship between the input data and the output execution result of each operator may be analyzed to obtain the execution dependency relationship between each operator. This application does not limit this.

[0046] For example, see Figure 3 , Figure 3 A schematic diagram of the division of series operators and parallel operators is shown in an exemplary embodiment of the present application, as shown in FIG. Figure 3 As shown, the operator set contains operators A, B, C, D, E, F, G, H, and I. The directed arrows between the operators indicate that there is data transmission, and the transmitted data can be part or all of the execution results of the previous operator. Among them, there is no execution dependency relationship between operators C and D and E, F, G, and H, respectively, and there is no execution dependency relationship between operators E, F, and G and C, D, and H, respectively. There is no execution dependency relationship between operator H and C, D, E, F, and G, respectively. Therefore, C, D, E, F, G, and H are divided into parallel operators, and operators A, B, and I depend on part or all of the execution results of the previous algorithm. Therefore, operators A, B, and I are divided into serial operators.

[0047] It should be noted that although operators D, F, and G also rely on part or all of the execution results of the previous algorithm, since they all rely on the parallel operator unidirectionally, operators D, F, and G are also classified as parallel operators.

[0048] Step S230: for each serial operator, a task control class is constructed separately, and for the parallel operators connected in parallel, a task control class is constructed uniformly; wherein the task control class is used to call threads in the thread pool, and the threads are used to call computing resources to execute operators.

[0049] The task control class (Task) is used to call the thread (Thread) in the thread pool, and the thread is used to call computing resources to execute operators.

[0050] When creating a Task, if each operator is managed by an independent Task, the serial Tasks after multiple parallel Tasks need to synchronize their results. Frequent synchronization management for multi-channel and multi-batch data will cause performance bottlenecks. If all operators are managed and scheduled in one Task, the data flow is directly transmitted between operators during the scheduling process without passing through the queue cache. In order to meet the sequential requirements of the final result data and certain operator inputs under the same channel, it is difficult to control different batches of data to be scheduled at the same time. That is, although managing all operators in one Task can achieve the maximum concurrent scheduling of the same batch of data, it will also affect the concurrency of different batches of data between different operators.

[0051] Taking the above problems into consideration, the present application creates Tasks according to the execution dependency between operators. Specifically, Tasks are constructed separately for each serial operator, and Tasks are constructed uniformly for parallel operators connected in parallel.

[0052] For an example, see Figure 4 , Figure 4 A schematic diagram of constructing a task control class is shown as an exemplary embodiment of the present application, such as Figure 4 As shown, the serial operators include A, B, and I. Task control classes are created for A, B, and I respectively to schedule the threads corresponding to A, B, and I respectively. Operators C, D, E, F, G, and H are parallel operators connected in parallel with each other. Then, a task control class Task is uniformly constructed for operators C, D, E, F, G, and H, and the threads corresponding to operators C, D, E, F, G, and H are uniformly scheduled in the Task.

[0053] In some implementations, in addition to directly assigning all mutually parallel operators to one Task, the number of operators corresponding to the Task can also be flexibly adjusted. For example, the number of batches of data that the target task currently needs to process is obtained, and the number of operators corresponding to the Task is calculated according to the number of batches of data, so as to divide the mutually parallel operators according to the number of operators corresponding to the Task, and obtain one or more parallel operator sets, and construct Tasks for each parallel operator set respectively, wherein the more batches of data there are, the smaller the number of operators corresponding to the Task is, so as to balance the maximum number of concurrent scheduling threads for the same batch of data and the degree of concurrency between different operators for different batches of data. For example, if operators C, D, E, F, G, and H are mutually parallel operators, and the number of operators corresponding to the Task is calculated to be 3 according to the number of batches of data, then the parallel operator sets C, D, and E and the parallel operator sets F, G, and H are obtained by division, and Tasks are uniformly constructed for C, D, and E, and Tasks are uniformly constructed for F, G, and H.

[0054] It should be noted that for all parallel operators, they need to be divided according to the parallel relationship between the parallel operators so as to uniformly construct tasks for the mutually parallel operators. For example, if Figure 4 There are also operators J and K in the corresponding embodiment. Operators J and K are parallel operators connected in parallel with each other. Although operators C, D, E, F, G, H, J, and K are all parallel operators, there is no parallel relationship between operators J, K and operators C, D, E, F, G, and H. Therefore, it is necessary to uniformly construct a task control class Task for operators C, D, E, F, G, and H, and to uniformly construct a task control class Task for operators J and K.

[0055] It should also be noted that in addition to the threads corresponding to each operator, the thread pool also contains threads corresponding to the task control class Task.

[0056] This application flexibly adjusts the operators assigned to each task control class according to the execution dependency between operators, so as to simultaneously ensure the maximum concurrency of the same batch of data and the concurrency of different batches of data between different operators, improve the efficiency of task execution, and facilitate the execution of more target tasks.

[0057] Step S240: Based on the task control class corresponding to the serial operator and / or the task control class corresponding to the parallel operator, the calling thread executes the serial operator and / or the parallel operator to obtain the execution result of the target task.

[0058] According to Task management, the threads corresponding to each operator are scheduled to execute each operator, and finally the execution result of the target task is obtained.

[0059] Next, some embodiments of the present application are described in detail.

[0060] In some embodiments, step S220 obtains the execution dependency between each operator in the operator set, divides the operators that have no execution dependency between each other into parallel operators, and divides the operators that have execution dependency between each other into series operators, including: analyzing the input data required for executing each operator in the operator set; if the input data required by the first operator contains the execution result of the second operator, it is determined that the first operator and the second operator have an execution dependency, and the first operator and the second operator are divided into series operators connected in series with each other; if the execution result of the first operator is not the input data required by the second operator, and the execution result of the second operator is not the input data required by the first operator, it is determined that the first operator and the second operator do not have an execution dependency, and the first operator and the second operator are divided into parallel operators connected in parallel with each other.

[0061] For example, Figure 3As shown, the execution result of operator A needs to be input into operator B, that is, the input data required by operator B contains the execution result of operator A. Therefore, in the actual execution process, operator B needs to wait for operator A to be executed first before executing operator B. It is judged that there is an execution dependency relationship between operator A and operator B, and operator A and operator B are divided into serial operators connected in series with each other; and the execution result of operator C is not the input data required by operator E, and the execution result of operator E is not the input data required by operator C. Therefore, in the actual execution process, operator C and operator E do not have a mandatory execution relationship, and it is judged that there is no execution dependency relationship between operator C and operator E, and operator C and operator E are divided into parallel operators connected in parallel with each other.

[0062] According to the above judgment logic, each operator is judged, and finally the operators in the operator set are divided into serial operators and parallel operators.

[0063] In some embodiments, step S220 obtains the execution dependency between each operator in the operator set, divides the operators that have no execution dependency between each other into parallel operators, and divides the operators that have execution dependency between each other into series operators, including: obtaining a tree structure representation corresponding to the operator set, in which the operators are used as nodes, and the connected edges between the nodes represent the existence of execution dependencies between the nodes; divides the operators corresponding to the nodes that have connected edges in the tree structure representation into series operators, and divides the operators corresponding to the nodes that have no connected edges in the tree structure representation into parallel operators.

[0064] The tree structure representation can be constructed based on a balanced binary tree, a red black tree, or a trie tree, such as Figure 3 The tree structure representation of the operator set is shown in .

[0065] In the tree structure representation, operators are regarded as nodes, and the connected edges between nodes represent the execution dependency between nodes, for example, Figure 7 In the figure, operator A is a node, and there is a connected edge between it and the node corresponding to operator B, which indicates that the input data required by operator B contains the execution result of operator A.

[0066] The operators corresponding to the nodes with connected edges in the tree structure representation are divided into serial operators, and the operators corresponding to the nodes without connected edges in the tree structure representation are divided into parallel operators, such as Figure 3There is no connected edge between operators C, E, and H, so they are classified as mutually parallel parallel operators. There is no connected edge between operators D and F, so they are classified as mutually parallel parallel operators. There is no connected edge between operators D and G, so they are classified as mutually parallel parallel operators. Operators C, E, and F themselves are all parallel operators. Therefore, operators C, D, E, F, G, and H can all be classified as mutually parallel parallel operators. And, according to Figure 3 By checking the connectivity of the edges of each node in , we can find that operators A, B, and I are interconnected, that is, operators A, B, and I have an execution dependency relationship, and operators A, B, and I are divided into serial series operators.

[0067] In some embodiments, the task control class stores operator handles corresponding to the serial operator and / or the parallel operator respectively; in step S240, based on the task control class corresponding to the serial operator and / or the task control class corresponding to the parallel operator, the thread is called to execute the serial operator and / or the parallel operator to obtain the execution result of the target task, including: based on the execution order between the serial operators and / or the parallel operators corresponding to each task control class, the execution order between each task control class is obtained; according to the execution order between each task control class, each task control class is executed in sequence; based on the operator handle stored in the currently executed task control class, the thread corresponding to the serial operator and / or the parallel operator in the thread pool is called to execute the serial operator and / or the parallel operator to obtain the execution result of the currently executed task control class; the execution result of the currently executed task control class is transmitted to the next executed task control class to execute the serial operator and / or the parallel operator; in response to the completion of the execution of all task control classes, the execution result of the target task is obtained.

[0068] For example, see Figure 4 According to the execution order between each operator, the execution order between each task control class Task is obtained as follows: the operator handle is used to identify the operator, and the thread corresponding to the serial operator and / or parallel operator in the thread pool is called through the operator handle to execute the serial operator and / or parallel operator.

[0069] Then, the execution results are transmitted between the tasks, and the execution result of the currently executed task is transmitted to the next executed task to execute the series operator and / or parallel operator.

[0070] When all tasks are executed, the execution result of the target task is obtained through the callback function. The execution result of the target task can be the execution result of the last task or the collection of execution results of multiple tasks. This application does not limit this.

[0071] In some embodiments, the task control class is deployed with multiple data input channels, and different data input channels are used to process input data corresponding to target tasks from different sources, and each data input channel stores an operator handle corresponding to a serial operator and / or a parallel operator; based on the operator handle stored in the currently executed task control class, the thread corresponding to the serial operator and / or the parallel operator in the thread pool is called to execute the serial operator and / or the parallel operator to obtain the execution result of the currently executed task control class, including: obtaining a data input channel that matches the source of the target task to obtain the target input channel; based on the operator handle corresponding to the target input channel of the currently executed task control class, the thread corresponding to the serial operator and / or the parallel operator in the thread pool is called to execute the serial operator and / or the parallel operator to obtain the execution result of the currently executed task control class.

[0072] The business layer can provide multiple operation objects. One operation object corresponds to a data input channel (Channel). The input data is transmitted by calling the operation object, and the input data is processed according to the corresponding task control class to execute the corresponding target task.

[0073] For example, the container mainly provides two types of operations for the target task. One is the initialization operation: creating container objects, attaching associated algorithms, and registering data processing callbacks; the other is the process operation: dynamically creating and destroying operator handles. According to business needs, one or more independent algorithm pipelines can be designed. Each Pipeline corresponds to a container, and the container manages multiple tasks on the pipeline. External business is decoupled from internal control tasks and algorithms through the encapsulation of the container layer, which facilitates rapid and stable development of the business layer.

[0074] Among them, the container is based on the link, such as Figure 4 As shown in the figure, each Link corresponds to a Task, Links can be connected in series, and a Link can contain one or more operators. Operators can be executed concurrently, and operators with execution dependencies are executed in serial. Task is used to manage the scheduling of operators. The thread pool is independent of Task and is shared globally (different threads in the same process) to achieve the effect of balanced allocation of scheduling resources.

[0075] For an example, see Figure 5 , Figure 5 A schematic diagram of a task control class is shown as an exemplary embodiment of the present application. Figure 5 As shown, the business layer can provide multiple operation objects, one operation object corresponds to one data input channel (Channel), for example, Figure 5 The data input channels of each Task in the task include channel 1, channel 2, ..., channel N, a total of N data input channels. According to the tree structure representation corresponding to the channel, one or more operator handles of different contexts associated with each channel are maintained. For example, task control class 1 maintains operator handles of operators A to E, and task control class 2 maintains operator handles of operators F to H. A corresponding cache node is allocated to each channel.

[0076] The external business layer needs to specify specific data input channels for the control messages of the Container and the transmitted input data, which are forwarded by the Container to the corresponding Task to call and operate different operator handles and operators; Tasks use the message mailbox (MailBox) for synchronization and ordinary message communication. The message mailbox can be composed of a pair of FIFO (First Input First Output) message queues. Tasks train the message mailbox in turn and process the command messages in serial order. The command messages include but are not limited to creating channels, destroying channels, parameter configuration, data notification, etc., which ensures the mutual exclusivity of message processing and can achieve lock-free management when managing internal channels, operator objects and input data, reducing complexity and improving stability with little impact on message processing efficiency.

[0077] After receiving the input data corresponding to the target task, the Container obtains the data input channel that matches the source of the target task, obtains the target input channel, and sends the input data to the data input queue of task control class 1 (i.e., the task control class that is executed first), and sends a data notification to the receiving queue of the message mailbox of task control class 1. Task control class 1 responds to the data notification in the receiving queue, obtains the input data from the data input queue, and calls the thread corresponding to the operator in the thread pool according to the operator handle corresponding to the target input channel, processes the input data to obtain the execution result, and stores the execution result in the data queue of task control class 1. Among them, the data queue consists of a non-idle queue (FullQue) and an idle queue (EmptyQue). The non-idle queue and the idle queue contain cache nodes. In response to the existence of execution result storage, the cache node in the idle queue is taken, the execution result is stored in the cache node, and then added to the non-idle queue.

[0078] Combination Figure 5 , taking the interaction steps between task control class 1 and task control class 2 as an example, the interaction process between tasks is described, including:

[0079] Step a: Task control class 1 sends a data notification message to the receiving queue of the message mailbox of task control class 2;

[0080] Step b: Task control class 2 takes a cache node from its own idle queue and stores the data in the node;

[0081] Step c: Task control class 2 takes a cache node from the non-idle queue of task control class 1 to obtain a data extraction node, and copies the data of the data extraction node to the data storage node;

[0082] Step d: Task control class 2 returns the data extraction node to the idle queue of task control class 1;

[0083] Step e: Task control class 2 makes a thread call according to the operator handle corresponding to the target input channel to process the data stored in the data storage node, adds the processed data storage node to the non-idle queue of task control class 2, and sends a data notification message to the receiving queue of the message mailbox of the next task control class Task;

[0084] Optionally, the method further includes step f: if a channel cache exists, sending a data notification to a sending queue of a message mailbox to output the channel cache.

[0085] In some embodiments, the operator includes a data processing neural network model, different data processing neural network models correspond to different batch sizes, and the batch size is used to limit the amount of data that is input into the data processing neural network model at a single time; the method also includes: integrating multiple data processing neural network models with different batch sizes to obtain an integrated model; allocating computing resources required for the largest batch size among multiple different batch sizes to the integrated model, and using the integrated model to process the input data corresponding to the operator.

[0086] Among them, the data processing neural network model is used to realize data processing, such as image processing, audio processing, text processing, etc.

[0087] If the data frame obtained by the data processing neural network model corresponding to the current operator is smaller than the batch size (batch_size) of the data processing neural network model, the hardware resources are still consumed according to the model batch_size. However, due to the limitation of data decoding or operator flow speed, the model inference time becomes longer, and the hardware resources are not fully utilized.

[0088] Therefore, in order to speed up the reasoning, multiple batch_size data processing neural network models are integrated into one model at the same time, and the computing resources of the integrated model are allocated according to the maximum batch_size.

[0089] For example, the data processing neural network models with batch_sizes of 1, 2, 4, 8, and 16 are integrated into an integrated model with batch_size of 16, and the integrated model inference of the corresponding batch_size is automatically selected according to the number of input data frames. For example, when a single input includes 3 or 4 frames of data, the integrated model inference of 4 batch_size is selected.

[0090] In some embodiments, the input data corresponding to the operator is processed using an integrated model, including: filtering invalid data on the input data corresponding to the operator to obtain filtered input data; based on the batch size corresponding to the filtered input data, inputting the filtered input data into an integrated model that matches the batch size for processing.

[0091] In order to avoid wasting resources due to processing invalid data, invalid data is filtered before being input into the model for inference, and then the filtered input data is input into the model in batches for inference.

[0092] Taking the image analysis task as an example, if the image frames are directly sent to the integrated model for reasoning in batches according to batch_size, the image frames containing invalid targets increase the processing time. Therefore, a callback function is set to filter the image frames, filter the image frames containing invalid targets according to business needs, and then send the image frames to the integrated model for reasoning according to batch_size to improve the processing speed.

[0093] In some embodiments, the target task includes an image analysis task; before obtaining a set of operators for executing the target task in response to the received target task, the method also includes: adding the input image to a corresponding image directory based on the object type of the target object contained in the input image; creating workflows corresponding to each image directory, the workflows read the input images from the corresponding image directories respectively, and adding the read input images to a scheduling queue; in response to the received target task, obtaining a set of operators for executing the target task, including: the workflow creates an image analysis task, the image analysis task extracts the input image from the scheduling queue, and obtains a set of operators for analyzing the input image.

[0094] It should be noted that the input image in this application can be a complete image obtained by image acquisition; or it can be an image block obtained by performing target recognition on the complete image obtained by image acquisition and cropping the image area of ​​the recognized target, and this application does not limit this. In addition, the input image includes but is not limited to pictures and videos.

[0095] For example, if the target object types include motor vehicles, non-motor vehicles, license plates, vehicle bodies, etc., image targets corresponding to different object types can be created, and input images of different object types can be input into the corresponding image directory.

[0096] Optionally, if the input image is a cropped image block, in order to perform a comprehensive analysis on the image, a panoramic image directory may be created, where the panoramic image directory is used to store the complete image.

[0097] Optionally, additional image information of each input image may be correspondingly stored in the image object, and the additional image information includes but is not limited to information such as the identification of the input image, the acquisition time and the acquisition location of the input image, etc.

[0098] Optionally, in each image directory, sub-directories can be further divided. For example, all input images in the image directory can be divided into multiple sub-directories according to the time range of the acquisition time, the location range of the acquisition location, etc.; or, all input images in the image directory can be directly split according to a preset data amount to obtain multiple sub-directories.

[0099] Optionally, abnormal data may be removed from the input images first, such as input images with damaged formats, input images with brightness less than a preset brightness, input images with clarity less than a preset clarity, etc., and a directory may be constructed for the removed input images.

[0100] Optionally, to facilitate image reading, each image directory may be uploaded to a designated network disk or local hard disk, a data set corresponding to each image directory may be established, and the name, identifier, version and other information of the data set may be set.

[0101] Then, a workflow is created for each image directory, and the input images in the image directory are read through the workflow to implement image analysis.

[0102] For an example, see Figure 6 , Figure 6 A workflow diagram of image analysis is shown as an exemplary embodiment of the present application. Figure 6As shown in the figure, each image directory corresponds to a different data set, and each image directory contains multiple subdirectories. The selected data set is determined based on the name, identifier, or version of the data set. Then, create a topic and partition in the distributed publish-subscribe messaging system Kafka, obtain the number of input images to be processed based on the selected data set, calculate the number of partitions based on the number of images, such as the number of partitions = the number of images / 500000, and verify whether the calculated number of partitions exceeds the maximum partition capacity of the device, where the number of partitions is greater than or equal to 1 and less than or equal to the maximum number of partitions of the device; and, create different topics according to the object type of the target object contained in the read input image, such as the topic naming format is workflowid_type_px, where workflowid is the task number of the workflow, type indicates different object types, and x is the calculated number of partitions.

[0103] Optionally, you can also create a topic for recording error data to record error data that occurs in other workflows.

[0104] Furthermore, according to the selected data set, all image directories are recursively traversed, and the traversal results are added to the scheduling queue in sequence, and according to the preset single parallel directory number N and parallel task number M, M parallel tasks are created respectively, and each parallel task takes N folders (image directories or subdirectories) from the scheduling queue each time and sends them to the parallel component for processing, wherein a parallel task is a plurality of image analysis tasks executed in parallel, and a parallel component is a component for executing steps S210 to S240; wait for the processing completion signal of each parallel task, if completed, create the next parallel task, and consume the scheduling queue until the scheduling queue is empty; when each image analysis task is successful, the entire parallel task is displayed as successful, otherwise it fails, and this parallel component supports the re-recall of a single parallel task for re-execution.

[0105] The execution steps of a single parallel task may include: parsing the running parameters of the parallel task, and checking whether the number of parallel directories N is greater than batch_size. If it is greater, the task needs to be processed in batches, and batch_size directories are processed each time; querying the topic corresponding to the current task according to the topic naming rules based on the incoming workflowid and task_type; then, creating a Kafka handle, an image analysis operator handle, and connecting to the Remote Procedure Call Protocol (RPC) service (that is, connecting to the specified network disk or local hard disk for storing input images), and creating N-channel image decoding, respectively decoding the input images of the N incoming directories, and registering an error callback function to the decoding handle corresponding to each channel of image decoding to record the failed decoding image, and sending the failed decoding image information and the error cause to the topic in Kafka for recording error data.

[0106] Among them, each image decoding corresponds to one thread processing, which specifically includes: obtaining all input images in the current directory through the RPC interface; traversing the input images, filtering the input images that are not supported by the decoding library according to the file suffix of the input image, and recording the relevant file information and error causes through the error callback function. For supported input images, the RPC interface is called to download the original image information from the specified network disk or local hard disk to the memory, and then transmitted to the decoding interface to start decoding (if the decoding fails, the relevant error information is sent to the topic in Kafka for recording error data), until all input images are sent in for decoding, and finally an empty frame is sent in to represent the end of decoding.

[0107] Get N decoding results from N decoding handles respectively, group them into a batch, and transmit them to the image analysis operator handle for processing. When receiving the signal that the image analysis operator handle has a result, the result processing thread gets the execution result from the image analysis operator handle, assembles the execution result into JavaScript Object Notation (JSON) data, one input image corresponds to one JSON, serializes the JSON into a string, and sends the execution result to the corresponding topic of Kafka according to the topic name.

[0108] Optionally, the partitioning strategy in Kafka can adopt a hashing algorithm, perform a hash operation based on the key or content of the execution result, and then select a partition based on the hash operation result; this ensures that the execution results with the same key or content are always sent to the same partition, thereby ensuring the order of the execution results.

[0109] Optionally, the execution results of the input images may be associated and fused to consume the execution results of each input image, for example, subscribing to a topic in Kafka to consume the execution results in the topic.

[0110] Specifically, the execution results of each input image are analyzed to determine whether there are input images that are related to each other. For example, based on the image additional information of the input image, such as the acquisition time and acquisition location of the input image, it is detected whether the input images are related, the execution results of the related input images are stored in an associated manner, and the corresponding associated relationship is recorded.

[0111] In the above embodiment, by creating a workflow through Kafka, the input data can be limited, and the topic can directly operate on the execution result by representing the execution result in JSON data format, thereby improving the result processing efficiency. By introducing the RPC service, data can be downloaded efficiently, saving the storage space of the intermediate device.

[0112] The task execution method provided by the present application obtains an operator set for executing the target task in response to a received target task; obtains the execution dependency between each operator in the operator set, and divides the operators that have no execution dependency between each other into parallel operators, and divides the operators that have execution dependency between each other into series operators; for each series operator, a task control class is separately constructed, and for parallel operators that are connected in parallel, a task control class is uniformly constructed; based on the task control class corresponding to the series operator and / or the task control class corresponding to the parallel operator, a thread is called to execute the series operator and / or the parallel operator to obtain the execution result of the target task, and the operators assigned to each task control class can be flexibly adjusted to simultaneously ensure the maximum concurrency of the same batch of data and the concurrency of different batches of data between different operators, thereby improving the efficiency of task execution.

[0113] Figure 7 FIG. 1 is a block diagram of a task execution device shown in an exemplary embodiment of the present application. Figure 7 As shown, the exemplary task execution device 700 includes:

[0114] An operator acquisition module 710 is used to acquire an operator set for executing the target task in response to the received target task;

[0115] An operator partitioning module 720 is used to obtain the execution dependency relationship between each operator in the operator set, and to partition operators that do not have execution dependency relationship between each other into parallel operators, and to partition operators that have execution dependency relationship between each other into serial operators;

[0116] The control class construction module 730 is used to construct a task control class for each serial operator separately, and to construct a task control class for parallel operators connected in parallel; wherein the task control class is used to call threads in the thread pool, and the threads are used to call computing resources to execute operators;

[0117] The operator execution module 740 is used to call a thread to execute the serial operator and / or the parallel operator based on the task control class corresponding to the serial operator and / or the task control class corresponding to the parallel operator to obtain the execution result of the target task.

[0118] It should be noted that the task execution device provided in the above embodiment and the task execution method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here. In practical applications, the task execution device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0119] See also Figure 8 , Figure 8 800 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 800 includes a memory 801 and a processor 802, and the processor 802 is used to execute program instructions stored in the memory 801 to implement the steps in any of the above-mentioned task execution method embodiments. In a specific implementation scenario, the electronic device 800 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 800 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.

[0120] Specifically, the processor 802 is used to control itself and the memory 801 to implement the steps in any of the above-mentioned task execution method embodiments. The processor 802 can also be called a central processing unit (CPU). The processor 802 may be an integrated circuit chip with signal processing capabilities. The processor 802 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 802 can be implemented by an integrated circuit chip.

[0121] See also Fig. 9 , Fig. 9 The computer-readable storage medium 900 stores program instructions 910 that can be executed by a processor, and the program instructions 910 are used to implement the steps in any of the above-mentioned task execution method embodiments.

[0122] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0123] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.

[0124] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0125] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.

Claims

1. A task execution method, characterized in that: The method comprises: In response to the received target task, obtaining an operator set for executing the target task; Obtaining the execution dependency relationship between each operator in the operator set, dividing the operators that do not have execution dependency relationship between each other into parallel operators, and dividing the operators that have execution dependency relationship between each other into serial operators; For each of the serial operators, a task control class is constructed separately, and for the parallel operators connected in parallel, a task control class is uniformly constructed; wherein the task control class is used to call threads in a thread pool, and the threads are used to call computing resources to execute the operators; the task control class is uniformly constructed for the parallel operators connected in parallel, including: obtaining the number of batch data that the target task currently needs to process, calculating the number of operators corresponding to the task control class according to the number of batch data, dividing the parallel operators connected in parallel according to the number of operators corresponding to the task control class, obtaining one or more parallel operator sets, and constructing a task control class for each parallel operator set; wherein, the more the number of batch data, the smaller the number of operators corresponding to the task control class; Based on the task control class corresponding to the series operator and / or the task control class corresponding to the parallel operator, the thread is called to execute the series operator and / or the parallel operator to obtain the execution result of the target task.

2. The method according to claim 1, characterized in that The obtaining of the execution dependency relationship between each operator in the operator set, dividing the operators that do not have execution dependency relationship between each other into parallel operators, and dividing the operators that have execution dependency relationship between each other into serial operators, includes: Analyze the input data required to execute each operator in the operator set; If the input data required by the first operator contains the execution result of the second operator, it is determined that the first operator and the second operator have an execution dependency relationship, and the first operator and the second operator are classified as serial operators connected in series with each other; If the execution result of the first operator is not the input data required by the second operator, and the execution result of the second operator is not the input data required by the first operator, it is determined that there is no execution dependency relationship between the first operator and the second operator, and the first operator and the second operator are divided into parallel operators connected in parallel with each other.

3. The method according to claim 1, characterized in that The obtaining of the execution dependency relationship between each operator in the operator set, dividing the operators that do not have execution dependency relationship between each other into parallel operators, and dividing the operators that have execution dependency relationship between each other into serial operators, includes: Obtaining a tree structure representation corresponding to the operator set, wherein the operators are used as nodes in the tree structure representation, and the connected edges between the nodes represent the existence of execution dependency relationships between the nodes; The operators corresponding to the nodes with connected edges in the tree structure representation are classified as serial operators, and the operators corresponding to the nodes without connected edges in the tree structure representation are classified as parallel operators.

4. The method according to claim 1, characterized in that: The task control class stores operator handles corresponding to the serial operator and / or the parallel operator respectively; the task control class corresponding to the serial operator and / or the task control class corresponding to the parallel operator is called based on the thread to execute the serial operator and / or the parallel operator to obtain the execution result of the target task, including: Based on the execution order between the series operators and / or the parallel operators corresponding to each of the task control classes, the execution order between the task control classes is obtained; Execute each of the task control classes in sequence according to the execution order between the task control classes; Based on the operator handle stored in the currently executed task control class, calling the thread corresponding to the series operator and / or the parallel operator in the thread pool to execute the series operator and / or the parallel operator to obtain the execution result of the currently executed task control class; Transmitting the execution result of the currently executed task control class to the next executed task control class to execute the series operator and / or the parallel operator; In response to all task control classes being executed, the execution result of the target task is obtained.

5. The method according to claim 4, characterized in that The task control class is deployed with multiple data input channels, and different data input channels are used to process input data corresponding to target tasks from different sources, and each data input channel stores the operator handle corresponding to the serial operator and / or the parallel operator respectively; the operator handle stored based on the currently executed task control class calls the thread corresponding to the serial operator and / or the parallel operator in the thread pool to execute the serial operator and / or the parallel operator, and obtains the execution result of the currently executed task control class, including: Acquire a data input channel that matches the source of the target task to obtain a target input channel; Based on the operator handle corresponding to the target input channel of the currently executed task control class, the thread corresponding to the series operator and / or the parallel operator in the thread pool is called to execute the series operator and / or the parallel operator to obtain the execution result of the currently executed task control class.

6. The method according to claim 1, characterized in that The operator includes a data processing neural network model, different data processing neural network models correspond to different batch sizes, and the batch size is used to limit the amount of data input into the data processing neural network model at a single time; the method also includes: Integrate multiple data processing neural network models with different batch sizes to obtain an integrated model; Allocate computing resources required for a largest batch size among the multiple different batch sizes to the integrated model, and use the integrated model to process input data corresponding to the operator.

7. The method according to claim 6, characterized in that The using the integrated model to process the input data corresponding to the operator includes: Perform invalid data filtering on the input data corresponding to the operator to obtain filtered input data; Based on the batch size corresponding to the filtered input data, the filtered input data is input into an integrated model matching the batch size for processing.

8. The method according to any one of claims 1 to 7, characterized in that: The target task includes an image analysis task; before acquiring an operator set for executing the target task in response to the received target task, the method further includes: Based on the object type of the target object contained in the input image, adding the input image to the corresponding image directory; Create a workflow corresponding to each image directory, the workflow reads input images from the corresponding image directory, and adds the read input images to the scheduling queue; The step of acquiring, in response to the received target task, a set of operators for executing the target task includes: The workflow creates an image analysis task, and the image analysis task extracts an input image from the scheduling queue and obtains an operator set for analyzing the input image.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the processor is configured to execute program instructions stored in the memory to implement the steps in the method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, and the program instructions can be executed by a processor to implement the steps in the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Task execution method and device, equipment and storage medium

    CN113342500A