/** * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MINDSPORE_LITE_MICRO_CODER_GRAPH_H_ #define MINDSPORE_LITE_MICRO_CODER_GRAPH_H_ #include #include #include #include #include #include "coder/config.h" #include "include/context.h" #include "include/model.h" #include "schema/inner/model_generated.h" #include "src/common/graph_util.h" #include "src/tensor.h" namespace mindspore::lite::micro { class CoderGraph { public: explicit CoderGraph(Model *model) : model_(model) {} ~CoderGraph(); int ConvertTensors(); int InitGraphInOutTensors(); void SetAllTensors(const std::vector &all_tensors); void InitInputs(); void InitOutputs(); void SetInputIndices(const std::vector &input_indices); void SetOutputIndices(const std::vector &output_indices); void AddInputMap(const std::string &node_id, Tensor *input_tensor); void AddOutputMap(const std::string &node_id, Tensor *output_tensor); std::vector input_indices() const; std::vector output_indices() const; std::vector input_tensors() const; std::vector output_tensors() const; std::vector all_tensors() const; const std::map> &GetOutputsMap() const; const Model *model() const { return this->model_; } private: // graph_inputs && weight && bias is value_node // others are parameter_node std::vector all_tensors_; std::vector input_tensors_; std::vector output_tensors_; std::vector input_indices_; std::vector output_indices_; std::map> inputs_map_; std::map> outputs_map_; Model *model_{nullptr}; }; } // namespace mindspore::lite::micro #endif // MINDSPORE_LITE_MICRO_CODER_GRAPH_H_