1 /** 2 * Copyright 2021 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_LITE_SRC_RUNTIME_DELEGATE_NPU_NPU_DELEGATE_H_ 18 #define MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_NPU_NPU_DELEGATE_H_ 19 20 #include <vector> 21 #include <map> 22 #include "include/api/delegate.h" 23 #include "include/context.h" 24 #include "src/delegate/npu/npu_manager.h" 25 #include "src/delegate/npu/pass/npu_pass_manager.h" 26 #include "src/delegate/npu/op/npu_op.h" 27 28 namespace mindspore { 29 class NPUDelegate : public Delegate { 30 public: NPUDelegate(lite::NpuDeviceInfo device_info)31 explicit NPUDelegate(lite::NpuDeviceInfo device_info) : Delegate() { frequency_ = device_info.frequency_; } 32 33 ~NPUDelegate() override; 34 35 Status Init() override; 36 37 Status Build(DelegateModel<schema::Primitive> *model) override; 38 39 protected: 40 NPUOp *GetOP(kernel::Kernel *kernel, const schema::Primitive *primitive); 41 42 kernel::Kernel *CreateNPUGraph(const std::vector<NPUOp *> &ops, DelegateModel<schema::Primitive> *model, 43 KernelIter from, KernelIter end); 44 45 NPUManager *npu_manager_ = nullptr; 46 NPUPassManager *pass_manager_ = nullptr; 47 std::map<schema::PrimitiveType, NPUGetOp> op_func_lists_; 48 int frequency_ = 0; 49 }; 50 } // namespace mindspore 51 52 #endif // MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_NPU_DELEGATE_H_ 53