• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-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_TOOLS_OPTIMIZER_GRAPH_LITE_TENSOR_EXTRACTOR_H_
18 #define MINDSPORE_LITE_TOOLS_OPTIMIZER_GRAPH_LITE_TENSOR_EXTRACTOR_H_
19 
20 #include <vector>
21 #include "include/registry/converter_context.h"
22 #include "ir/anf.h"
23 #include "src/tensor.h"
24 #include "tools/lite_exporter/fetch_content.h"
25 
26 namespace mindspore {
27 namespace opt {
28 class LiteTensorExtractor {
29  public:
30   LiteTensorExtractor() = default;
31   ~LiteTensorExtractor() = default;
32   static int GetCNodeInputAbstractLists(const CNodePtr &cnode, AbstractBasePtrList *abs_list);
33   static int GetCNodeInputTensors(const CNodePtr &cnode, std::vector<TensorPtr> *inputs, converter::FmkType fmk_type,
34                                   bool train_flag, bool copy_data);
35   static int GetCNodeOutputTensors(const CNodePtr &cnode, std::vector<TensorPtr> *outputs, bool train_flag);
36   static int GetCNodeConstInputs(const CNodePtr &cnode, const converter::FmkType &fmk_type, const bool &train_flag,
37                                  const bool &copy_data, std::vector<TensorPtr> *const_ms_inputs);
38   static int GetCNodeConstInput(const CNodePtr &cnode, const size_t &index, const converter::FmkType &fmk_type,
39                                 const bool &train_flag, const bool &copy_data, std::vector<TensorPtr> *const_ms_inputs);
40   static int GetCNodeVarInput(const CNodePtr &cnode, const size_t &index, std::vector<TensorPtr> *var_ms_inputs);
41   static int GetCNodeConstInputToAbstract(const CNodePtr &cnode, const AbstractBasePtrList &abs_list,
42                                           converter::FmkType fmk_type, bool train_flag);
43 };
44 }  // namespace opt
45 }  // namespace mindspore
46 #endif  // MINDSPORE_LITE_TOOLS_OPTIMIZER_GRAPH_LITE_TENSOR_EXTRACTOR_H_
47