/** * Copyright 2019 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 TRANSFORM_OP_ADAPTER_UTIL_H_ #define TRANSFORM_OP_ADAPTER_UTIL_H_ #include #include #include "transform/op_adapter_base.h" namespace mindspore { namespace transform { template static Q ConvertAnyUtil(const ValuePtr &value, const AnyTraits

&, const AnyTraits &) { return static_cast(GetValue

(value)); } GeTensor ConvertAnyUtil(const ValuePtr &value, const AnyTraits &traits); std::vector ConvertAnyUtil(const ValuePtr &value, const std::string &name, const AnyTraits>); std::string ConvertAnyUtil(const ValuePtr &value, const AnyTraits>, const AnyTraits); std::vector ConvertAnyUtil(const ValuePtr &value, const AnyTraits>, const AnyTraits); std::vector ConvertAnyUtil(const ValuePtr &value, const std::string &format, const AnyTraits>, const AnyTraits); GeDataType ConvertAnyUtil(const ValuePtr &value, const AnyTraits); template std::vector ConvertAnyUtil(const ValuePtr &value, AnyTraits

, const AnyTraits>) { if (!value->isa() && !value->isa()) { MS_LOG(EXCEPTION) << "error convert Value to vector for value: " << value->ToString() << ", type: " << value->type_name() << ", value should be a tuple or list"; } auto vec = value->isa() ? value->cast()->value() : value->cast()->value(); std::vector data; for (auto &it : vec) { data.push_back(ConvertAnyUtil(it, AnyTraits

(), AnyTraits())); } return data; } GeTensor ConvertAnyUtil(const ValuePtr &value, const AnyTraits); bool IsCustomPrim(const PrimitivePtr &prim); bool IsCustomCNode(const AnfNodePtr &node); } // namespace transform } // namespace mindspore #endif // TRANSFORM_OP_ADAPTER_UTIL_H_