1 /** 2 * Copyright 2019-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 17 #ifndef MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_GE_RUNTIME_TASK_TASK_H_ 18 #define MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_GE_RUNTIME_TASK_TASK_H_ 19 20 #include <memory> 21 #include <utility> 22 #include <vector> 23 #include <string> 24 #include "runtime/device/ascend/ge_runtime/model_context.h" 25 #include "runtime/device/ascend/ge_runtime/task_info.h" 26 27 namespace mindspore::ge::model_runner { 28 class Task { 29 public: Task()30 Task() {} 31 ~Task()32 virtual ~Task() {} 33 34 virtual void Distribute() = 0; 35 Args()36 virtual void *Args() { return nullptr; } 37 task_name()38 virtual std::string task_name() const { return ""; } 39 set_model_handle(rtModel_t model_handle)40 void set_model_handle(rtModel_t model_handle) { model_handle_ = model_handle; } 41 42 protected: 43 rtModel_t model_handle_{nullptr}; 44 }; 45 46 template <class T> 47 class TaskRepeater : public Task { 48 static_assert(std::is_base_of<TaskInfo, T>(), "Wrong TaskInfo Type!"); 49 50 public: TaskRepeater(const ModelContext & model_context,const std::shared_ptr<T> & task_info)51 TaskRepeater(const ModelContext &model_context, const std::shared_ptr<T> &task_info) {} 52 ~TaskRepeater()53 virtual ~TaskRepeater() {} 54 55 virtual void Distribute() = 0; 56 }; 57 } // namespace mindspore::ge::model_runner 58 #endif // MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_GE_RUNTIME_TASK_TASK_H_ 59