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 #ifndef MINDSPORE_LITE_MICRO_OPCODERS_OP_CODER_BUILDER_H_ 17 #define MINDSPORE_LITE_MICRO_OPCODERS_OP_CODER_BUILDER_H_ 18 19 #include <vector> 20 #include <memory> 21 #include "coder/opcoders/op_coder.h" 22 #include "micro/coder/allocator/allocator.h" 23 24 namespace mindspore::lite::micro { 25 26 class OpCoderBuilder { 27 public: 28 std::unique_ptr<OperatorCoder> build(int schema_version); 29 30 OpCoderBuilder &inputs(const std::vector<Tensor *> &inputs); 31 32 OpCoderBuilder &outputs(const std::vector<Tensor *> &outputs); 33 34 OpCoderBuilder &node(const Model::Node *node); 35 36 OpCoderBuilder ¶meter(OpParameter *parameter); 37 38 OpCoderBuilder &data_type(TypeId data_type); 39 40 OpCoderBuilder &mode(CodeMode mode); 41 42 OpCoderBuilder &input_indices(const std::vector<uint32_t> &indices); 43 44 OpCoderBuilder &output_indices(const std::vector<uint32_t> &indices); 45 46 OpCoderBuilder &target(Target target); 47 48 OpCoderBuilder &support_parallel(bool parallel); 49 50 void Reset(); 51 52 private: 53 std::vector<Tensor *> inputs_; 54 55 std::vector<Tensor *> outputs_; 56 57 const mindspore::lite::Model::Node *node_ = nullptr; 58 59 OpParameter *parameter_{nullptr}; 60 61 size_t node_index_{0}; 62 63 Target target_{kTargetUnknown}; 64 65 TypeId data_type_{kTypeUnknown}; 66 67 CodeMode mode_{Code_Unknown}; 68 69 std::vector<uint32_t> input_indices_; 70 71 std::vector<uint32_t> output_indices_; 72 73 bool support_parallel_{false}; 74 }; 75 76 } // namespace mindspore::lite::micro 77 #endif // MINDSPORE_LITE_MICRO_OPCODERS_OP_CODER_BUILDER_H_ 78