// Copyright 2018 Xiaomi, Inc. All rights reserved. // // 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 MACE_CORE_ARG_HELPER_H_ #define MACE_CORE_ARG_HELPER_H_ #include #include #include #include "mace/proto/mace.pb.h" namespace mace { // Refer to caffe2 class ProtoArgHelper { public: template static T GetOptionalArg(const Def &def, const std::string &arg_name, const T &default_value) { return ProtoArgHelper(def).GetOptionalArg(arg_name, default_value); } template static std::vector GetRepeatedArgs( const Def &def, const std::string &arg_name, const std::vector &default_value = std::vector()) { return ProtoArgHelper(def).GetRepeatedArgs(arg_name, default_value); } explicit ProtoArgHelper(const OperatorDef &def); explicit ProtoArgHelper(const NetDef &netdef); template T GetOptionalArg(const std::string &arg_name, const T &default_value) const; template std::vector GetRepeatedArgs( const std::string &arg_name, const std::vector &default_value = std::vector()) const; private: std::map arg_map_; }; } // namespace mace #endif // MACE_CORE_ARG_HELPER_H_