Task scheduling method and device, and electronic device

By introducing red-black trees and multi-linked list structures into the NPU, the task scheduling method is optimized, solving the problem of low task scheduling efficiency and achieving more efficient data processing.

CN116244053BActive Publication Date: 2026-08-25AXERA SEMICON (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310234393.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-09
Publication Date
2026-08-25
Estimated Expiration
2043-03-09

AI Technical Summary

Technical Problem

In existing technologies, NPU task scheduling efficiency is low and scheduling methods have high time complexity, which affects data processing efficiency.

Method used

By employing a red-black tree and multi-linked list structure, the system maintains the red-black tree by obtaining the dynamic parameters, sequence identifier, and model handle of the target task. Based on the red-black tree, the system determines the tasks to be updated and performs parameter updates and scheduling in a preset order, thereby reducing time complexity.

Benefits of technology

This improves task scheduling efficiency and reduces the time complexity of scheduling methods, thereby enhancing the data processing efficiency of the NPU.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116244053B_ABST
    Figure CN116244053B_ABST
Patent Text Reader

Abstract

The present disclosure provides a task scheduling method and device and electronic equipment. The method comprises: adding a target task to an update queue and a linked list corresponding to a target model according to a sequence identifier corresponding to the target task; maintaining a red-black tree according to the linked list corresponding to the target task, the sequence identifier, and a handle of the target model, wherein a node of the red-black tree represents a handle of a model in an idle state, and a key of the node represents a sequence identifier of a first task in a linked list corresponding to a corresponding model of the node; in response to determining that the target task is a target task to be updated according to the red-black tree, performing parameter updating on the target model according to a dynamic parameter corresponding to the target task, and updating the red-black tree; in response to determining that the target task is a task to be executed, pushing the target task from the update queue to a start queue, and executing the target task according to a task execution sequence corresponding to the start queue. The task scheduling efficiency is improved, the time complexity of the scheduling method is reduced, and the data processing efficiency of the NPU is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of chip technology, and in particular to a task scheduling method, apparatus and electronic device. Background Technology

[0002] The NPU (Neural-network Processing Unit) adopts a "data-driven parallel computing" architecture and is particularly good at processing massive amounts of multimedia data such as video and images.

[0003] Currently, the neural network models widely used in the field of artificial intelligence primarily rely on NPU hardware for multimedia data processing. These models reside in memory for extended periods, and a task is a single execution of that task. During model runtime, dynamic parameters such as input and output addresses are updated within the model before the NPU hardware is invoked to execute the task. Given the large number of tasks, efficient task scheduling, which improves scheduling efficiency and reduces the time complexity of scheduling methods, is crucial for enhancing the NPU's data processing efficiency. Summary of the Invention

[0004] This disclosure aims to at least partially address one of the technical problems in the related art.

[0005] This disclosure proposes a task scheduling method to address the technical problems of low task scheduling efficiency and high time complexity of scheduling methods in related technologies.

[0006] According to a first aspect of this disclosure, a task scheduling method is provided, comprising: obtaining dynamic parameters corresponding to a target task, a corresponding sequence identifier, and a handle to a target model; adding the target task to an update queue and a linked list corresponding to the target model in a preset order according to the sequence identifier corresponding to the target task; maintaining a red-black tree according to the linked list corresponding to the target model, the sequence identifier corresponding to the target task, and the handle to the target model, wherein the nodes of the red-black tree represent handles of models in an idle state, and the keys of the nodes of the red-black tree represent the sequence identifier of the first task in the linked list corresponding to the model of the node; in response to determining that the target task is a target task to be updated according to the red-black tree, updating the parameters of the target model according to the dynamic parameters corresponding to the target task, and updating the red-black tree; in response to determining that the target task is a task to be executed according to the position of the target task in the update queue, pushing the target task from the update queue into a start queue, and executing the target task according to the task execution order corresponding to the start queue.

[0007] As a first possible embodiment of this disclosure, maintaining a red-black tree based on the linked list corresponding to the target model, the sequence identifier corresponding to the target task, and the handle of the target model includes: obtaining the working state of the target model when the linked list corresponding to the target model only includes the target task; and maintaining a red-black tree based on the working state, the sequence identifier corresponding to the target task, and the handle of the target model.

[0008] As a second possible embodiment of this disclosure, maintaining the red-black tree based on the working state, the sequence identifier corresponding to the target task, and the handle of the target model includes: when the working state of the target model is idle, inserting the handle of the target model as a first target node into the red-black tree, wherein the sequence identifier corresponding to the target task is used as the key of the first target node.

[0009] As a third possible embodiment of this disclosure, inserting the handle of the target model as the first target node into the red-black tree includes: inserting the handle of the target model as the first target node into the red-black tree according to the arrangement order that the key of the left leaf node of any node is less than the key of the arbitrary node and the key of the right leaf node of any node is greater than the key of the arbitrary node.

[0010] As a fourth possible embodiment of this disclosure, determining the target task as the target task to be updated based on the red-black tree includes: determining the target task as the target task to be updated when the first target node corresponding to the target model is the leftmost leaf node in the red-black tree.

[0011] As a fifth possible embodiment of this disclosure, updating the red-black tree includes: deleting the first target node corresponding to the target model from the red-black tree.

[0012] As a sixth possible embodiment of this disclosure, the method further includes: in response to the completion of the target task, determining whether the linked list corresponding to the target model is empty; if the linked list corresponding to the target model is not empty, inserting the handle of the target model as a second target node into the red-black tree, wherein the sequence identifier corresponding to the second task in the linked list corresponding to the target model is used as the key of the second target node.

[0013] As a seventh possible embodiment of this disclosure, the method further includes: obtaining a task cancellation instruction, the task cancellation instruction including a sequence identifier corresponding to the third task to be cancelled; and setting the status of the third task to invalid according to the sequence identifier corresponding to the third task.

[0014] According to a second aspect of the present disclosure, a task scheduling apparatus is provided, comprising: a task acquisition module, configured to acquire dynamic parameters corresponding to a target task, a corresponding sequence identifier, and a handle to a corresponding target model; a first processing module, configured to add the target task to an update queue and a linked list corresponding to the target model in a preset order according to the sequence identifier corresponding to the target task; a maintenance module, configured to maintain a red-black tree according to the linked list corresponding to the target model, the sequence identifier corresponding to the target task, and the handle to the target model, wherein the nodes of the red-black tree represent handles of models in an idle state, and the keys of the nodes of the red-black tree represent the sequence identifier of the first task in the linked list corresponding to the model of the node; an update module, configured to, in response to determining that the target task is a target task to be updated according to the red-black tree, update the parameters of the target model according to the dynamic parameters corresponding to the target task, and update the red-black tree; and a second processing module, configured to, in response to determining that the target task is a task to be executed according to the position of the target task in the update queue, push the target task from the update queue into a start queue, and execute the target task according to the task execution order corresponding to the start queue.

[0015] As a first possible embodiment of this disclosure, the maintenance module includes: an acquisition unit, configured to acquire the working state of the target model when the linked list corresponding to the target model only includes the target task; and a maintenance unit, configured to maintain a red-black tree based on the working state, the sequence identifier corresponding to the target task, and the handle of the target model.

[0016] As a second possible embodiment of this disclosure, the maintenance unit is specifically used to: insert the handle of the target model as a first target node into the red-black tree when the working state of the target model is an idle state, wherein the sequence identifier corresponding to the target task is used as the key of the first target node.

[0017] As a third possible embodiment of this disclosure, the maintenance unit is further configured to: insert the handle of the target model as the first target node into the red-black tree according to the arrangement order in which the key of the left leaf node of any node is less than the key of the arbitrary node and the key of the right leaf node of any node is greater than the key of the arbitrary node.

[0018] As a fourth possible embodiment of this disclosure, the apparatus further includes: a determining module, configured to determine the target task as the target task to be updated when the first target node corresponding to the target model is the leftmost leaf node in the red-black tree.

[0019] As a fifth possible embodiment of this disclosure, the update module includes: an update unit, configured to delete the first target node corresponding to the target model from the red-black tree.

[0020] As a sixth possible embodiment of this disclosure, the apparatus further includes: a judgment module, configured to determine whether the linked list corresponding to the target model is empty in response to the completion of the target task; the maintenance module is further configured to insert the handle of the target model as a second target node into the red-black tree when the linked list corresponding to the target model is not empty, wherein the sequence identifier corresponding to the second task in the linked list corresponding to the target model is used as the key of the second target node.

[0021] As a seventh possible embodiment of this disclosure, the apparatus further includes: an instruction acquisition module, configured to acquire a task cancellation instruction, the task cancellation instruction including a sequence identifier corresponding to the third task to be cancelled; and a third processing module, configured to set the status of the third task to invalid according to the sequence identifier corresponding to the third task.

[0022] According to a third aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a task scheduling method proposed in an embodiment of the first aspect of this disclosure.

[0023] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the task scheduling method proposed in the first aspect of this disclosure.

[0024] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor of an electronic device, enables the electronic device to perform the task scheduling method proposed in the first aspect embodiment.

[0025] Additional aspects and advantages of this disclosure will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this disclosure. Attached Figure Description

[0026] The above and / or additional aspects and advantages of this disclosure will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, in which:

[0027] Figure 1 This is a queue diagram of task scheduling methods in related technologies;

[0028] Figure 2 This is a flowchart illustrating a task scheduling method according to an exemplary embodiment;

[0029] Figure 3 This is a queue diagram illustrating a task scheduling method according to an exemplary embodiment;

[0030] Figure 4 This is a flowchart illustrating another task scheduling method according to an exemplary embodiment;

[0031] Figure 5 This is a schematic diagram of the structure of a task scheduling device according to an exemplary embodiment;

[0032] Figure 6 This is a block diagram of an electronic device illustrating a task scheduling method according to an exemplary embodiment. Detailed Implementation

[0033] Embodiments of this disclosure are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting this disclosure.

[0034] To clearly explain the task scheduling method, apparatus and electronic equipment provided in this disclosure, the technical names involved in this disclosure will first be explained.

[0035] A handle is an identifier used to identify an object or item. In this embodiment of the disclosure, the handle corresponds to a specific neural network model (hereinafter referred to as the model) and is used to uniquely identify the corresponding model.

[0036] A task is an execution of the model. A task has corresponding dynamic parameters, such as input address and output address. The task updates the dynamic parameters into the model during model runtime and then calls the NPU hardware to execute the task.

[0037] Different tasks may correspond to the same model or different models. For example, task 1 might be an execution of model 1, and task 2 might also be an execution of model 1. The dynamic parameters for task 1 need to be updated in model 1 before the NPU hardware is invoked to execute task 1. After task 1 completes, the dynamic parameters for task 2 need to be updated in model 1 before the NPU hardware is invoked to execute task 2. Similarly, task 3 might be an execution of model 1, and task 4 might be an execution of model 2. The dynamic parameters for task 3 need to be updated in model 1 before the NPU hardware is invoked to execute task 1, and the dynamic parameters for task 4 need to be updated in model 2 before the NPU hardware is invoked to execute task 4.

[0038] Each task has three states: running, ready, and idle. A task cannot be executed while its dynamic parameters have not yet been updated in the model; in this state, the task is idle. After the task is updated in the model by the update thread, it can be executed, transitioning from idle to ready and awaiting hardware execution. While the task is being executed by hardware, it is in the running state and cannot be canceled.

[0039] Each model has two working states: busy and idle. When a model is in a busy state (e.g., while being run by hardware or modified and awaiting scheduling), it cannot be modified; that is, dynamic parameters corresponding to any task cannot be updated to that model. When a model is in a non-busy (idle) state, it can be modified; that is, dynamic parameters corresponding to any task can be updated to that model.

[0040] For example, suppose the dynamic parameters corresponding to task1 are updated in model 1, and the NPU hardware is invoked to execute task1. Then, the user submits task2, which is also an execution of model 1. Since model 1 has already been modified by task1 and is being run by the hardware, model 1 is in a busy state and cannot update the dynamic parameters corresponding to task2. It needs to wait for task1 to finish executing and for model 1 to be released before the dynamic parameters corresponding to task2 can be updated. In other words, for each execution of each model, the dynamic parameters corresponding to the task are first updated in the model, then the hardware is invoked to execute the task, and after the task is completed, the dynamic parameters corresponding to the next task are updated in the model, and then the hardware is invoked to execute the next task.

[0041] In related technologies, NPUs primarily use a FIFO (First Input First Output) scheduling strategy for task scheduling. Specifically, user-submitted tasks are first placed in an update queue. The update thread performs update operations on these tasks, updating the corresponding model parameters based on the task's dynamic parameters. Then, tasks in the ready state at the head of the update queue are pushed into the launch queue. The launch thread executes tasks on the hardware in the order from head to tail of the launch queue. When updating tasks in the update queue, the update thread first finds tasks that are idle and whose corresponding models are also idle, and updates them in FIFO order. This process involves multi-condition searching, typically traversing the entire update queue to find suitable tasks for processing.

[0042] The following is for reference. Figure 1 The task scheduling methods of the NPU in related technologies are explained. Among them, Figure 1 Each box in the diagram represents a task, and H0, H1, H2, H3, and H4 represent the handles of the corresponding models. Dark handles, such as H0, H1, and H4, indicate that the corresponding models are busy, while light handles indicate that the corresponding models are idle. In the update queue, dark boxes indicate that tasks are idle, and light boxes indicate that tasks are ready. All tasks in the launch queue are ready. Tasks being executed by the hardware are in the running state. Since the model corresponding to H0 is being run by the hardware, and the models corresponding to H4 and H1 have been modified and are waiting to be scheduled, the models corresponding to H0, H1, and H4 are in the busy state. It should be noted that updating a task or updating a task in the embodiments of this disclosure refers to updating the model parameters according to the dynamic parameters corresponding to the task.

[0043] refer to Figure 1 User-submitted tasks are first placed in the update queue, with newly submitted tasks located at the tail of the update queue. The update thread then transforms idle tasks in the update queue into ready tasks and pushes them into the startup queue. (See reference) Figure 1During the execution of the update thread, the model cannot be directly updated based on the dynamic parameters corresponding to the task at the head of the update queue, because the model corresponding to the task at the head of the queue is in a busy state and cannot be modified. Instead, the update thread must search towards the back of the queue, using the condition that the model corresponding to the task is in an idle state. Tasks closer to the front of the queue (the closer to the front, the earlier the task was created) whose corresponding models are in an idle state are identified as tasks to be updated. For example, if the model corresponding to H2 is in an idle state, for the two tasks corresponding to H2, the earlier task must be updated first, then the later task. That is, first update the parameters of the model corresponding to H2 based on the dynamic parameters corresponding to the task at position 2, and then update the parameters of the model corresponding to H2 based on the dynamic parameters corresponding to the task at position 3. Figure 1 In the update queue shown, since the models corresponding to the tasks at positions 1, 2, and 3 are in an idle state, and the task at position 1 is closest to the front of the queue, the task at position 1 is updated first, that is, the model corresponding to H3 is updated according to the dynamic parameters corresponding to the task at position 1. Then the task at position 2 is updated, that is, the model corresponding to H2 is updated according to the dynamic parameters corresponding to the task at position 2. Then the task at position 3 is updated, that is, the model corresponding to H2 is updated according to the dynamic parameters corresponding to the task at position 3.

[0044] It should be noted that the process of pushing updated tasks from the update queue into the startup queue is performed concurrently while traversing the update queue, in order to avoid disrupting the FIFO characteristic. Figure 1 Although the second task in the update queue (task at position 4) is ready, it cannot be pushed into the startup queue until the first task (task at position 5) becomes ready. Furthermore, the update thread does not continuously iterate through the update queue. After one iteration and finding no tasks to update, the thread enters a sleep state, waiting to be awakened by the createtask interface or the launch thread.

[0045] In addition, the launch thread mainly takes a task from the head of the launch queue and then executes it.

[0046] The time complexity of key process nodes in the above task scheduling process is explained below.

[0047] First, for the task creation process, simply push the task to the end of the update queue; the time complexity of this process node is O(1). For the task update process, since the update queue needs to be traversed from beginning to end, the time complexity of this process node is O(n), where n represents the number of tasks in the update queue. For the process of pushing a task from the update queue to the launch queue, it essentially checks whether the first task in the update queue is in a ready state; the time complexity of this process node is O(1). Furthermore, for the cleanup process after the launch thread completes the task's execution on the hardware, which mainly refers to the model's working state changing from busy to idle, since simply processing the flag bit is sufficient, the time complexity of this process node is O(1). For the task cancellation process, simply set the state of the task to be cancelled to invalid, and then perform the actual deletion operation while the update thread and launch thread process the task; the time complexity of this process node is O(1).

[0048] As can be seen from the above analysis, the time complexity of updating tasks in the above-mentioned task scheduling method in the related technology is O(n), so the overall time complexity of the scheduling method is O(n).

[0049] To improve task scheduling efficiency, reduce the time complexity of scheduling methods, and thus improve the data processing efficiency of the NPU, this disclosure proposes a task scheduling method, apparatus, and electronic device. By acquiring the dynamic parameters, sequence identifier, and handle of the target model corresponding to the target task, the target task is added to the update queue and the linked list corresponding to the target model according to the sequence identifier and a preset order. A red-black tree is maintained based on the linked list, the sequence identifier, and the handle of the target model. The nodes of the red-black tree represent the handles of models in an idle state, and the keys of the nodes represent the sequence identifier of the first task in the linked list corresponding to the node's model. In response to determining the target task as a target to be updated based on the red-black tree, the target model is updated according to the dynamic parameters corresponding to the target task, and the red-black tree is updated. In response to determining the target task as a task to be executed based on its position in the update queue, the target task is pushed from the update queue to the start queue, and executed according to the task execution order in the start queue. This improves task scheduling efficiency, reduces the time complexity of scheduling methods, and thus improves the data processing efficiency of the NPU.

[0050] The task scheduling method, apparatus, and electronic equipment provided in this disclosure will now be described in detail with reference to the accompanying drawings.

[0051] Figure 2This is a flowchart illustrating a task scheduling method according to an exemplary embodiment. It should be noted that this task scheduling method can be applied to a task scheduling device. The task scheduling device can be, for example, a chip in an electronic device, or an NPU within a chip, and can be configured according to actual needs; this disclosure does not impose any limitations on it.

[0052] like Figure 2 As shown, the task scheduling method includes the following steps:

[0053] Step 201: Obtain the dynamic parameters, sequence identifier, and handle of the target model corresponding to the target task.

[0054] The target task can be any task submitted by the user that requires execution by a neural network model.

[0055] Dynamic parameters are the dynamic parameters required by the model when performing tasks, such as input address and output address.

[0056] Sequence identifier, used to uniquely identify the corresponding task, can be determined according to the time sequence of task creation.

[0057] The target model is the model corresponding to the target task. That is, the dynamic parameters corresponding to the target task need to be updated into the target model before the NPU hardware is called to execute the target task.

[0058] One possible implementation is to add sequence identifiers to tasks, with the sequence identifiers increasing in ascending order according to the time the tasks were created. For example, the first task submitted by a user could have a sequence identifier of nice1, the second task nice2, the third task nice3, and so on.

[0059] Step 202: Based on the sequence identifier corresponding to the target task, add the target task to the update queue and the linked list corresponding to the target model in a preset order.

[0060] The update queue is a queue consisting of all the tasks that need to be updated.

[0061] In this embodiment of the disclosure, after obtaining the target task, the target task can be added to the update queue in a preset order. The preset order for adding the target task to the update queue can be set as needed, for example, by placing newly submitted tasks at the end of the update queue, or by setting other orders; this disclosure does not limit this.

[0062] Furthermore, in this embodiment, identical models can be linked together, so that each model has a linked list, which holds the tasks submitted to the model in a preset order. The preset order in which the target tasks are added to the linked list corresponding to the target model can be set as needed, for example, newly submitted tasks can be arranged at the end of the linked list corresponding to that model, or other orders can be set, which is not limited in this disclosure.

[0063] As one possible implementation, the update queue can be FIFO, that is, the target task is added to the tail of the update queue according to the sequence identifier corresponding to the target task, and the target task can be added to the tail of the linked list corresponding to the target model.

[0064] Step 203: Maintain a red-black tree based on the linked list corresponding to the target model, the sequence identifier corresponding to the target task, and the handle of the target model. The nodes of the red-black tree represent the handles of the models in the idle state, and the keys of the nodes represent the sequence identifiers of the first tasks in the linked list corresponding to the model of the node.

[0065] A red-black tree is a self-balancing binary search tree where each node has a color attribute, which is used to maintain the balance of the tree.

[0066] The first task in the linked list is the task created earliest. The position of the first task in the linked list depends on the preset order in which newly submitted tasks are added. For example, if newly submitted tasks are at the tail of the linked list, the first task at the head of the list is the task created earliest.

[0067] In the embodiments of this disclosure, a red-black tree and multiple linked lists can be introduced into the task scheduling method. The nodes of the red-black tree represent the handles of the models in the idle state, and the keys of the nodes of the red-black tree represent the sequential identifiers of the first tasks in the linked lists corresponding to the model of the node, such as the sequential identifiers of the first tasks at the head of the linked lists. Thus, after obtaining the target task, the red-black tree can be maintained according to the linked lists corresponding to the target model, the sequential identifiers corresponding to the target task, and the handles of the target model.

[0068] refer to Figure 3It can add sequence identifiers to tasks, which increment in ascending order according to the time of task creation. Identical models are linked together, so each model will have a linked list. This linked list holds the tasks submitted to the model in a preset order. A red-black tree is constructed based on the handles of models in an idle state. The nodes of the red-black tree represent the handles of models in an idle state, and the keys of the nodes represent the sequence identifier of the first task in the linked list corresponding to the model of the node. Thus, after obtaining the target task, the red-black tree can be maintained based on the linked list corresponding to the target model, the sequence identifier of the target task, and the handle of the target model.

[0069] Step 204: In response to determining the target task as the target task to be updated based on the red-black tree, update the parameters of the target model according to the dynamic parameters corresponding to the target task, and update the red-black tree.

[0070] Among them, the target task to be updated is the task identified from the update queue that is to be updated.

[0071] In the embodiments of this disclosure, since the nodes in the red-black tree represent the handles of the models in the idle state, and the keys of the nodes represent the sequential identifiers of the first tasks in the linked lists corresponding to the models of the nodes, the task with the earliest creation time among the tasks corresponding to the models in the idle state can be determined based on the nodes in the red-black tree and the keys of the nodes, and this task can be identified as the task to be updated.

[0072] In the embodiments of this disclosure, in response to determining the target task as the target task to be updated based on the red-black tree, the target model can be updated with parameters based on the dynamic parameters corresponding to the target task. Specifically, before updating the target model with parameters based on the dynamic parameters corresponding to the target task, the target task is in an idle state; after updating the target model with parameters based on the dynamic parameters corresponding to the target task, the target task transitions from an idle state to a ready state.

[0073] Furthermore, since the target task is identified as the task to be updated, the target model must be in an idle state and capable of modification before updating its parameters according to the dynamic parameters corresponding to the target task. The handle of the target model has a corresponding node in the red-black tree. After updating the target model's parameters according to the dynamic parameters corresponding to the target task, the target model changes from an idle state to a busy state. Because the working state of the target model changes, the red-black tree needs to be updated.

[0074] Step 205: In response to determining that the target task is a task to be executed based on its position in the update queue, the target task is pushed from the update queue into the start queue, and the target task is executed according to the task execution order corresponding to the start queue.

[0075] Among them, the tasks to be executed are those that have entered the ready state, are waiting to be executed, and can be pushed into the start queue.

[0076] As one possible implementation, the update queue can be FIFO, which means that when the first task at the head of the update queue is ready, the first task at the head of the update queue is determined as the task to be executed.

[0077] Correspondingly, in response to the target task changing from an idle state to a ready state, and the target task being the first task at the head of the update queue, the target task can be determined as a task to be executed, and thus the target task is pushed from the update queue into the start queue.

[0078] The startup queue is a queue consisting of tasks that are in a ready state and waiting to be executed.

[0079] The task execution order is the order in which tasks in the start queue are executed. It can be set as needed, for example, executing tasks in the order from the head to the tail of the start queue.

[0080] As one possible implementation, the start queue can be FIFO, which would allow the target task to be pushed from the update queue to the tail of the start queue, and the target task to be executed when it is the first task in the start queue.

[0081] Through the above steps, the scheduling process for any task submitted by the user that requires execution by a neural network model is realized. Steps 201-203 correspond to the task creation process nodes. Since they involve the process of inserting tasks into the update queue and linked list, as well as the maintenance of the red-black tree, the time complexity of inserting tasks into the update queue and linked list is O(1), and the time complexity of searching, inserting, deleting, etc. in the red-black tree is O(logm), where m is the number of nodes in the red-black tree, i.e. the number of models in the idle state. Therefore, the time complexity of this process node is at most O(logm). Step 204 corresponds to the task update process node. Since it is not necessary to traverse the update queue from beginning to end, but to determine the target task to be updated based on the red-black tree, and since this process node involves the update of the red-black tree, the time complexity of this process node does not exceed O(logm). Step 205 corresponds to the task push from the update queue to the start queue and the task execution. Since the task to be executed can be directly determined based on the position of the task in the update queue, and the task to be executed can be determined based on the task execution order corresponding to the start queue, the time complexity of this process node is O(1). Therefore, the time complexity of the entire task scheduling method from task creation to task execution is O(logm). Since m is the number of models, and the number of models is much smaller than the number of tasks n in the update queue, the time complexity O(logm) is much smaller than the time complexity O(n).

[0082] In summary, the task scheduling method provided in this disclosure improves task scheduling efficiency and reduces the time complexity of the scheduling method by obtaining the dynamic parameters, sequence identifier, and handle of the target model corresponding to the target task. Based on the sequence identifier, the target task is added to the update queue and the linked list corresponding to the target model in a preset order. A red-black tree is maintained based on the linked list, the sequence identifier, and the handle of the target model. In the red-black tree, each node represents the handle of an idle model, and the key of each node represents the sequence identifier of the first task in the linked list corresponding to the model. In response to determining the target task as a target to be updated based on the red-black tree, the target model's parameters are updated according to the dynamic parameters corresponding to the target task, and the red-black tree is updated. In response to determining the target task as a task to be executed based on its position in the update queue, the target task is pushed from the update queue to the start queue. The target task is then executed according to the task execution order corresponding to the start queue.

[0083] To illustrate how the task scheduling method provided in this embodiment maintains a red-black tree, the following will be combined with... Figure 4 The task scheduling method provided in the embodiments of this disclosure will be further explained.

[0084] Figure 4 This is a flowchart illustrating a task scheduling method according to another exemplary embodiment. Figure 4 As shown, the task scheduling method includes the following steps:

[0085] Step 401: Obtain the dynamic parameters, sequence identifier, and handle of the target model corresponding to the target task.

[0086] Step 402: Based on the sequence identifier corresponding to the target task, add the target task to the update queue and the linked list corresponding to the target model in a preset order.

[0087] The specific implementation process and principle of steps 401-402 can be found in the descriptions of other embodiments, and will not be repeated here.

[0088] Step 403: If the linked list corresponding to the target model only includes the target task, obtain the working status of the target model.

[0089] The target model's working states include idle state and busy state.

[0090] The linked list corresponding to the target model only includes the target task, meaning that the linked list corresponding to the target model is empty before the target task is added to it; the linked list corresponding to the target model includes the target task and other tasks, meaning that the linked list corresponding to the target model is not empty before the target task is added to it.

[0091] Step 404: Maintain a red-black tree based on the working status, the sequence identifier corresponding to the target task, and the handle of the target model. The nodes of the red-black tree represent the handles of the models in the idle state, and the keys of the nodes represent the sequence identifiers of the first tasks in the linked list corresponding to the model of the node.

[0092] It is understandable that if the linked list corresponding to the target model only includes the target task, it means that the linked list corresponding to the target model is empty before the target task is added to the linked list corresponding to the target model. That is, there is no task that needs to update the dynamic parameters to the target model, so the red-black tree must not have the node corresponding to the target model.

[0093] In this embodiment of the disclosure, it can be determined whether a node corresponding to the target model needs to be inserted into the red-black tree based on the working state of the target model. Specifically, if the working state of the target model is idle, it can be determined that a node corresponding to the target model needs to be inserted into the red-black tree, and then the node corresponding to the target model can be inserted into the red-black tree according to the sequence identifier corresponding to the target task and the handle of the target model; if the working state of the target model is busy, it can be determined that no node corresponding to the target model needs to be inserted into the red-black tree, and no processing is performed.

[0094] Step 404 can be implemented as follows: when the working state of the target model is idle, insert the handle of the target model as the first target node into the red-black tree, where the sequence identifier corresponding to the target task is used as the key of the first target node.

[0095] Inserting the handle of the target model as the first target node into the red-black tree can be achieved in the following way:

[0096] The handle of the target model is inserted into the red-black tree as the first target node, following the order in which the key of the left leaf node of any node is less than the key of any node, and the key of the right leaf node of any node is greater than the key of any node.

[0097] The above process corresponds to the task creation process node. Since the linked list corresponding to the target model only includes the target task and the working state of the target model is idle, it involves the process of inserting and updating the task queue and linked list, as well as the process of inserting nodes in the red-black tree. The time complexity of inserting and updating the task queue and linked list is O(1), and the time complexity of the insertion operation in the red-black tree is O(logm), where m is the number of nodes in the red-black tree, that is, the number of models in the idle state. Therefore, when the linked list corresponding to the target model only includes the target task and the working state of the target model is idle, the time complexity of this process node is O(logm).

[0098] In addition, if the linked list corresponding to the target model only includes the target task and the working state of the target model is busy, the process node for creating the task only needs to insert the task into the update queue and the linked list. In this case, the time complexity of the process node is O(1).

[0099] In addition, if the linked list corresponding to the target model includes the target task and other tasks, and the other tasks are tasks created before the target task, then when the target model is in a busy state, there is no need to insert the corresponding node of the target model into the red-black tree. When the target model is in an idle state, the corresponding node of the target model has already been inserted into the red-black tree according to the other tasks, so the target task will not affect the change of the red-black tree. Therefore, in this case, it is only necessary to insert the task into the update queue and the linked list. In this case, the time complexity of this process node is O(1).

[0100] Step 405: In response to determining the target task as the target task to be updated based on the red-black tree, update the parameters of the target model according to the dynamic parameters corresponding to the target task, and delete the first target node corresponding to the target model from the red-black tree.

[0101] In the embodiments of this disclosure, for any task, in the case of inserting the node corresponding to the handle of the model corresponding to the task into the red-black tree according to the arrangement order that the key of the left leaf node of any node is less than the key of any node and the key of the right leaf node of any node is greater than the key of any node, the first task in the linked list of the model corresponding to the leftmost leaf node of the red-black tree (i.e. the task with the earliest creation time) is the task to be updated.

[0102] In this embodiment of the disclosure, each time the red-black tree is updated, the model corresponding to the leftmost leaf node in the red-black tree can be recorded, so that the first task in the linked list of the model can be directly determined as the task to be updated.

[0103] Therefore, in this embodiment of the disclosure, if the first target node corresponding to the target model is the leftmost leaf node in the red-black tree, the target task can be determined as the target task to be updated.

[0104] It should be noted that the leaf nodes in this embodiment are valid nodes in a red-black tree.

[0105] Furthermore, in response to determining the target task as the target task to be updated based on the red-black tree, the target model's parameters can be updated according to the dynamic parameters corresponding to the target task. Additionally, since the target task is determined to be the target task to be updated, the target model must be in an idle state before updating its parameters according to the dynamic parameters corresponding to the target task, allowing for modification. The handle of the target model has a corresponding node in the red-black tree. After updating the target model's parameters according to the dynamic parameters corresponding to the target task, the target model changes from an idle state to a busy state. Because the target model's working state changes from idle to busy, and the nodes in the red-black tree correspond to models in an idle state, the first target node corresponding to the target model needs to be deleted from the red-black tree.

[0106] In this process, the process shown in step 405 above corresponds to the process node of the update task. Since it is not necessary to traverse the update queue from beginning to end, but directly determine the leftmost leaf node in the recorded red-black tree as the node to be updated, and the process of updating the red-black tree is to directly delete the node in the red-black tree, the time complexity of this process node is O(1).

[0107] Step 406: In response to determining that the target task is a task to be executed based on its position in the update queue, the target task is pushed from the update queue into the start queue, and the target task is executed according to the task execution order corresponding to the start queue.

[0108] Understandably, after the target task is completed, the working state of the target model changes from busy to idle. Since the node corresponding to the target model has been deleted from the red-black tree in step 405, in the embodiments of this disclosure, it is also necessary to determine whether the node corresponding to the target model needs to be inserted into the red-black tree.

[0109] Accordingly, the embodiments of this disclosure may also include:

[0110] In response to the completion of the target task, determine whether the linked list corresponding to the target model is empty;

[0111] If the linked list corresponding to the target model is not empty, insert the handle of the target model as the second target node into the red-black tree, where the sequence identifier of the second task in the linked list corresponding to the target model is used as the key of the second target node.

[0112] In the embodiments of this disclosure, after the target task is completed, the linked list corresponding to the target model is empty, meaning there are no tasks that need to update the dynamic parameters to the target model, so no processing is required. If the linked list corresponding to the target model is not empty after the target task is completed, it means there are still tasks that need to update the dynamic parameters to the target model, in which case a node corresponding to the target model needs to be inserted into the red-black tree. Specifically, the handle of the target model can be inserted into the red-black tree as a second target node, where the sequence identifier of the second task in the linked list corresponding to the target model is used as the key of the second target node.

[0113] The second task is the task with the earliest creation time in the linked list corresponding to the target model. The position of the second task in the linked list corresponding to the target model is related to the preset order in which newly submitted tasks are added to the linked list. For example, if newly submitted tasks are arranged at the end of the linked list, the first task at the head of the linked list corresponding to the target model is the task with the earliest creation time.

[0114] Since the nodes corresponding to the model may be different when the timing of inserting the corresponding nodes in the red-black tree is different for the same model, the first target node and the second target node can be different nodes or the same node.

[0115] Among them, the process of inserting the node corresponding to the target model into the red-black tree after the target task is completed and the linked list corresponding to the target model is not empty corresponds to the post-processing process after the launch thread completes the task on the hardware. Since it is necessary to insert the node into the red-black tree, and the time complexity of the insertion operation in the red-black tree is O(logm), the time complexity of this process node is at most O(logm).

[0116] Furthermore, for any task that is not currently being executed, the execution of the task can be cancelled. Therefore, in this embodiment of the disclosure, it may also include:

[0117] Obtain the task cancellation instruction, which includes the sequence identifier of the third task to be cancelled;

[0118] Based on the sequence identifier corresponding to the third task, the status of the third task is set to invalid.

[0119] In this embodiment, the state of the third task can be set to invalid according to the sequence identifier corresponding to the third task, and the actual deletion operation can be performed while the update thread and launch thread process the task. The time complexity of this process node is O(1).

[0120] In summary, by obtaining the dynamic parameters, sequence identifiers, and handles of the target model corresponding to the target task, and adding the target task to the update queue and the linked list corresponding to the target model in a preset order according to the sequence identifier, and when the linked list corresponding to the target model only contains the target task, the working state of the target model is obtained. Based on the working state, the sequence identifiers of the target task, and the handles of the target model, a red-black tree is maintained. The nodes of the red-black tree represent the handles of models in an idle state, and the keys of the nodes represent the sequence identifiers of the first task in the linked list corresponding to the model of the node. In response to determining that the target task is a target task to be updated based on the red-black tree, the parameters of the target model are updated according to the dynamic parameters corresponding to the target task, and the first target node corresponding to the target model is deleted from the red-black tree. In response to determining that the target task is a target task to be executed based on its position in the update queue, the target task is pushed from the update queue to the start queue, and the target task is executed according to the task execution order corresponding to the start queue. This improves the scheduling efficiency of tasks, reduces the time complexity of the scheduling method, and thus improves the data processing efficiency of the NPU.

[0121] Figure 5 This is a schematic diagram of the structure of a task scheduling device according to an exemplary embodiment.

[0122] like Figure 5 As shown, the task scheduling device 500 includes: a task acquisition module 510, a first processing module 520, a maintenance module 530, an update module 540, and a second processing module 550.

[0123] Among them, the task acquisition module 510 is used to acquire the dynamic parameters, the corresponding sequence identifier, and the handle of the corresponding target model corresponding to the target task.

[0124] The first processing module 520 is used to add the target task to the update queue and the linked list corresponding to the target model in a preset order according to the sequence identifier corresponding to the target task.

[0125] The maintenance module 530 is used to maintain a red-black tree based on the linked list corresponding to the target model, the sequence identifier corresponding to the target task, and the handle of the target model. The nodes of the red-black tree represent the handles of the models in the idle state, and the keys of the nodes of the red-black tree represent the sequence identifier of the first task in the linked list corresponding to the model of the node.

[0126] The update module 540 is used to respond to the determination of the target task as the target task to be updated based on the red-black tree, update the parameters of the target model according to the dynamic parameters corresponding to the target task, and update the red-black tree.

[0127] The second processing module 550 is used to determine the target task as a task to be executed based on the position of the target task in the update queue, push the target task from the update queue into the start queue, and execute the target task according to the task execution order corresponding to the start queue.

[0128] As one possible implementation of this disclosure, the maintenance module 530 includes:

[0129] The acquisition unit is used to acquire the working status of the target model when the linked list corresponding to the target model only includes the target task.

[0130] The maintenance unit is used to maintain the red-black tree based on the working status, the sequence identifier corresponding to the target task, and the handle of the target model.

[0131] As one possible implementation of this disclosure, the maintenance unit is specifically used for:

[0132] When the target model is in an idle state, the handle of the target model is inserted into the red-black tree as the first target node, and the sequence identifier corresponding to the target task is used as the key of the first target node.

[0133] As one possible implementation of this disclosure, the maintenance unit is further configured to:

[0134] The handle of the target model is inserted into the red-black tree as the first target node, following the order in which the key of the left leaf node of any node is less than the key of any node, and the key of the right leaf node of any node is greater than the key of any node.

[0135] As one possible implementation of this disclosure, the device 500 further includes:

[0136] The determination module is used to determine the target task as the target task to be updated when the first target node corresponding to the target model is the leftmost leaf node in the red-black tree.

[0137] As one possible implementation of this disclosure, the update module 540 includes:

[0138] The update unit is used to delete the first target node corresponding to the target model from the red-black tree.

[0139] As one possible implementation of this disclosure, the device 500 further includes:

[0140] The judgment module is used to determine whether the linked list corresponding to the target model is empty in response to the completion of the target task.

[0141] The maintenance module is also used to insert the handle of the target model as the second target node into the red-black tree when the linked list corresponding to the target model is not empty, wherein the sequence identifier of the second task in the linked list corresponding to the target model is used as the key of the second target node.

[0142] As one possible implementation of this disclosure, the device 500 further includes:

[0143] The instruction acquisition module is used to acquire task cancellation instructions, which include the sequence identifier of the third task to be cancelled;

[0144] The third processing module is used to invalidate the status of the third task according to the sequence identifier corresponding to the third task.

[0145] The task scheduling device of this embodiment obtains the dynamic parameters, sequence identifier, and handle of the target model corresponding to the target task. Based on the sequence identifier, it adds the target task to the update queue and the linked list corresponding to the target model in a preset order. It maintains a red-black tree based on the linked list, the sequence identifier, and the handle of the target model. Each node in the red-black tree represents the handle of an idle model, and the key of each node represents the sequence identifier of the first task in the linked list corresponding to the model. In response to determining the target task as a target to be updated based on the red-black tree, it updates the parameters of the target model and updates the red-black tree based on the dynamic parameters corresponding to the target task. In response to determining the target task as a task to be executed based on its position in the update queue, it pushes the target task from the update queue into the start queue and executes the target task according to the task execution order corresponding to the start queue. This improves task scheduling efficiency, reduces the time complexity of the scheduling method, and thus improves the data processing efficiency of the NPU.

[0146] To implement the above embodiments, this disclosure also proposes an electronic device, such as... Figure 6 As shown, Figure 6 This is a block diagram of an electronic device illustrating a task scheduling method according to an exemplary embodiment. Figure 6 As shown, the aforementioned electronic device 600 may include:

[0147] The system includes a memory 610 and a processor 620, and a bus 630 connecting different components (including the memory 610 and the processor 620). The memory 610 stores a computer program, and when the processor 620 executes the program, it implements the task scheduling method described in the embodiments of this disclosure.

[0148] Bus 630 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0149] Electronic device 600 typically includes a variety of computer-readable media. These media can be any available media that can be accessed by electronic device 600, including volatile and non-volatile media, removable and non-removable media.

[0150] Memory 610 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 640 and / or cache memory 650. Electronic device 600 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 660 can be used to read and write non-removable, non-volatile magnetic media (… Figure 6 Not shown; usually referred to as a "hard drive"). Although Figure 6 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 630 via one or more data media interfaces. Memory 610 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this disclosure.

[0151] A program / utility 680 having a set (at least one) of program modules 670 may be stored in, for example, memory 610. Such program modules 670 include—but are not limited to—an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 670 typically perform the functions and / or methods described in the embodiments of this disclosure.

[0152] Electronic device 600 can also communicate with one or more external devices 690 (e.g., keyboard, pointing device, display 691, etc.), and with one or more devices that enable a user to interact with the electronic device 600, and / or with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed through input / output (I / O) interface 692. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) through network adapter 693. Figure 6 As shown, network adapter 693 communicates with other modules of electronic device 600 via bus 630. It should be understood that, although... Figure 6 As not shown in the diagram, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0153] The processor 620 executes various functional applications and data processing by running programs stored in the memory 610.

[0154] It should be noted that the implementation process and technical principles of the electronic device in this embodiment are explained in the foregoing description of the task scheduling method of this disclosure embodiment, and will not be repeated here.

[0155] The electronic device provided in this disclosure improves task scheduling efficiency and reduces the time complexity of the scheduling method by acquiring the dynamic parameters, sequence identifier, and handle of the target model corresponding to the target task. Based on the sequence identifier, the target task is added to the update queue and the linked list corresponding to the target model in a preset order. A red-black tree is maintained based on the linked list, the sequence identifier, and the handle of the target model. In the red-black tree, each node represents the handle of a model in an idle state, and the key of each node represents the sequence identifier of the first task in the linked list corresponding to the node's model. In response to determining the target task as a target to be updated based on the red-black tree, the target model's parameters are updated according to the dynamic parameters corresponding to the target task, and the red-black tree is updated. In response to determining the target task as a task to be executed based on its position in the update queue, the target task is pushed from the update queue to the start queue, and executed according to the task execution order corresponding to the start queue. This improves task scheduling efficiency, reduces the time complexity of the scheduling method, and thus improves the data processing efficiency of the NPU.

[0156] To implement the above embodiments, this disclosure also proposes a computer-readable storage medium.

[0157] Specifically, when the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is able to perform the task scheduling method as described above.

[0158] To implement the above embodiments, this disclosure also provides a computer program product that, when executed by the processor of an electronic device, enables the electronic device to perform the task scheduling method as described above.

[0159] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0160] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A task scheduling method, characterized in that, include: Obtain the dynamic parameters, sequence identifier, and handle of the target model corresponding to the target task; Based on the sequence identifier corresponding to the target task, the target task is added to the update queue and the linked list corresponding to the target model in a preset order; A red-black tree is maintained based on the linked list corresponding to the target model, the sequence identifier corresponding to the target task, and the handle of the target model. The nodes of the red-black tree represent the handles of the models in an idle state, and the keys of the nodes represent the sequence identifiers of the first tasks in the linked list corresponding to the model of the node. In response to determining the target task as a target task to be updated based on the red-black tree, the target model is updated with parameters based on the dynamic parameters corresponding to the target task, and the red-black tree is updated accordingly; In response to determining that the target task is a task to be executed based on its position in the update queue, the target task is pushed from the update queue into the start queue, and the target task is executed according to the task execution order corresponding to the start queue.

2. The method according to claim 1, characterized in that, Maintaining a red-black tree based on the linked list corresponding to the target model, the sequence identifier corresponding to the target task, and the handle of the target model includes: If the linked list corresponding to the target model contains only the target task, obtain the working status of the target model; Maintain a red-black tree based on the working state, the sequence identifier corresponding to the target task, and the handle of the target model.

3. The method according to claim 2, characterized in that, Maintaining a red-black tree based on the working state, the sequence identifier corresponding to the target task, and the handle of the target model includes: When the target model is in an idle state, the handle of the target model is inserted into the red-black tree as the first target node, wherein the sequence identifier corresponding to the target task is used as the key of the first target node.

4. The method according to claim 3, characterized in that, The step of inserting the handle of the target model as the first target node into the red-black tree includes: The handle of the target model is inserted into the red-black tree as the first target node, following the order in which the key of the left leaf node of any node is less than the key of the arbitrary node, and the key of the right leaf node of any node is greater than the key of the arbitrary node.

5. The method according to claim 4, characterized in that, The step of determining the target task as the target task to be updated based on the red-black tree includes: If the first target node corresponding to the target model is the leftmost leaf node in the red-black tree, then the target task is determined to be the target task to be updated.

6. The method according to any one of claims 1-5, characterized in that, The update of the red-black tree includes: The first target node corresponding to the target model is deleted from the red-black tree.

7. The method according to claim 6, characterized in that, The method further includes: In response to the completion of the target task, determine whether the linked list corresponding to the target model is empty; If the linked list corresponding to the target model is not empty, the handle of the target model is inserted into the red-black tree as the second target node, wherein the sequence identifier corresponding to the second task in the linked list corresponding to the target model is used as the key of the second target node.

8. The method according to any one of claims 1-5, characterized in that, The method further includes: Obtain a task cancellation instruction, wherein the task cancellation instruction includes a sequence identifier corresponding to the third task to be cancelled; Based on the sequence identifier corresponding to the third task, the status of the third task is set to invalid.

9. A task scheduling device, characterized in that, include: The task acquisition module is used to acquire the dynamic parameters, sequence identifier, and handle of the target model corresponding to the target task. The first processing module is used to add the target task to the update queue and the linked list corresponding to the target model in a preset order according to the sequence identifier corresponding to the target task; The maintenance module is used to maintain a red-black tree based on the linked list corresponding to the target model, the sequence identifier corresponding to the target task, and the handle of the target model. The nodes of the red-black tree represent the handles of the models in an idle state, and the keys of the nodes of the red-black tree represent the sequence identifier of the first task in the linked list corresponding to the model of the node. An update module is used to respond to determining the target task as a target task to be updated based on the red-black tree, updating the parameters of the target model based on the dynamic parameters corresponding to the target task, and updating the red-black tree; The second processing module is configured to, in response to determining that the target task is a task to be executed based on its position in the update queue, push the target task from the update queue into the start queue, and execute the target task according to the task execution order corresponding to the start queue.

10. The apparatus according to claim 9, characterized in that, The maintenance module includes: The acquisition unit is used to acquire the working status of the target model when the linked list corresponding to the target model only includes the target task; The maintenance unit is used to maintain the red-black tree according to the working status, the sequence identifier corresponding to the target task, and the handle of the target model.

11. The apparatus according to claim 10, characterized in that, The maintenance unit is specifically used for: When the target model is in an idle state, the handle of the target model is inserted into the red-black tree as the first target node, wherein the sequence identifier corresponding to the target task is used as the key of the first target node.

12. The apparatus according to claim 11, characterized in that, The maintenance unit is further configured to: The handle of the target model is inserted into the red-black tree as the first target node, following the order in which the key of the left leaf node of any node is less than the key of the arbitrary node, and the key of the right leaf node of any node is greater than the key of the arbitrary node.

13. The apparatus according to claim 12, characterized in that, The device further includes: The determination module is used to determine the target task as the target task to be updated when the first target node corresponding to the target model is the leftmost leaf node in the red-black tree.

14. The apparatus according to any one of claims 9-13, characterized in that, The update module includes: The update unit is used to delete the first target node corresponding to the target model from the red-black tree.

15. The apparatus according to claim 14, characterized in that, The device further includes: The judgment module is used to determine whether the linked list corresponding to the target model is empty in response to the completion of the target task. The maintenance module is further configured to insert the handle of the target model as a second target node into the red-black tree when the linked list corresponding to the target model is not empty, wherein the sequential identifier of the second task in the linked list corresponding to the target model is used as the key of the second target node.

16. The apparatus according to any one of claims 9-13, characterized in that, The device further includes: The instruction acquisition module is used to acquire a task cancellation instruction, wherein the task cancellation instruction includes a sequence identifier corresponding to the third task to be cancelled; The third processing module is used to set the status of the third task to invalid according to the sequence identifier corresponding to the third task.

17. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the task scheduling method according to any one of claims 1-8.

18. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the task scheduling method as described in any one of claims 1-8.

19. A computer program product comprising a computer program that, when executed by a processor of an electronic device, enables the electronic device to perform the task scheduling method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Resource allocation method, resource allocation device, electronic equipment and storage medium

    CN113254192A

  • Apparatus and method for executing recurrent neural network and LSTM computations

    EP3451239A1