• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2022 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_COREML_COREML_DELEGATE_H_
18 #define MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_COREML_COREML_DELEGATE_H_
19 
20 #include <vector>
21 #include <map>
22 #include "include/api/delegate.h"
23 #include "src/litert/delegate/coreml/op/coreml_op.h"
24 #include "src/litert/delegate/coreml/pass/coreml_pass_manager.h"
25 
26 namespace mindspore {
27 namespace lite {
28 class CoreMLDelegateImpl : public mindspore::Delegate {
29  public:
30   CoreMLDelegateImpl() = default;
31 
32   ~CoreMLDelegateImpl() override;
33 
34   bool IsSupportCoreML() const;
35 
36   Status Init() override;
37 
38   Status Build(DelegateModel<schema::Primitive> *model) override;
39 
40  protected:
41   CoreMLOp *GetOP(kernel::Kernel *kernel, const schema::Primitive *primitive);
42 
43   kernel::Kernel *CreateCoreMLGraph(const std::vector<CoreMLOp *> &ops, DelegateModel<schema::Primitive> *model,
44                                     KernelIter from, KernelIter end);
45 
46   Status AddPasses();
47 
48  protected:
49   int graph_index_ = 0;
50   CoreMLPassManager *pass_manager_ = nullptr;
51   std::map<schema::PrimitiveType, CoreMLGetOp> op_func_lists_;
52 };
53 }  // namespace lite
54 }  // namespace mindspore
55 
56 #endif  // MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_COREML_COREML_DELEGATE_H_
57