1 /** 2 * Copyright 2021-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_EXTENDRT_MINDIR_LOADER_MINDIR_MODEL_MINDIR_MODEL_UTIL_H_ 18 #define MINDSPORE_LITE_SRC_EXTENDRT_MINDIR_LOADER_MINDIR_MODEL_MINDIR_MODEL_UTIL_H_ 19 20 #include <memory> 21 #include "ir/anf.h" 22 #include "mindapi/base/type_id.h" 23 #include "proto/mind_ir.pb.h" 24 #include "include/api/context.h" 25 26 namespace mindspore::infer::mindir { 27 class MindirModelUtil { 28 public: 29 static mindspore::ValuePtr MakeValueFromAttribute(const mind_ir::AttributeProto &attr_proto); 30 31 static mindspore::ValuePtr MakeValueFromTensorOrTypeAttribute(const mind_ir::AttributeProto &attr_proto); 32 static mindspore::ValuePtr MakeValueFromTensorAttribute(const mind_ir::TensorProto &attr_tensor, 33 bool need_load_data = false); 34 static mindspore::ValuePtr MakeValueFromListAttribute(const mind_ir::AttributeProto &attr_proto); 35 static mindspore::ValuePtr MakeValueFromScalarAttribute(const mind_ir::AttributeProto &attr_proto); 36 37 static mindspore::TypeId ProtoTypeToTypeId(int32_t proto_type); 38 }; 39 } // namespace mindspore::infer::mindir 40 41 #endif // MINDSPORE_LITE_SRC_EXTENDRT_MINDIR_LOADER_MINDIR_MODEL_MINDIR_MODEL_UTIL_H_ 42