• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef MINDSPORE_CCSRC_BACKEND_SESSION_EXECUTOR_MANAGER_H_
17 #define MINDSPORE_CCSRC_BACKEND_SESSION_EXECUTOR_MANAGER_H_
18 #include <set>
19 #include <map>
20 #include <string>
21 #include <memory>
22 #include "backend/common/session/executor.h"
23 #include "include/backend/visible.h"
24 
25 namespace mindspore::session {
26 class Executor;
27 class BACKEND_EXPORT ExecutorManager {
28  public:
29   static ExecutorManager &Instance();
30   std::shared_ptr<Executor> GetExecutor(const std::string &device_name, uint32_t device_id);
31   void OnEvent(const ExecutorEvent &event);
32   void Clear();
ClearDoneTasks()33   void ClearDoneTasks() {
34     for (const auto &item : executors_) {
35       auto &executor = item.second;
36       if (executor != nullptr) {
37         executor->ClearDoneTasks();
38       }
39     }
40   }
41 
42  private:
43   ExecutorManager() = default;
44   ~ExecutorManager() = default;
45   DISABLE_COPY_AND_ASSIGN(ExecutorManager)
46 
47   std::map<std::string, std::shared_ptr<Executor>> executors_;
48 };
49 }  // namespace mindspore::session
50 #endif  // MINDSPORE_CCSRC_BACKEND_SESSION_EXECUTOR_MANAGER_H_
51