/** * Copyright 2019-2020 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 INC_REGISTER_OP_REGISTRY_H_ #define INC_REGISTER_OP_REGISTRY_H_ #include #include #include #include #include #include "register/register.h" namespace domi { enum RemoveInputType { OMG_MOVE_TYPE_DTYPE = 0, OMG_MOVE_TYPE_VALUE, OMG_MOVE_TYPE_SHAPE, OMG_MOVE_TYPE_FORMAT, OMG_MOVE_TYPE_AXIS, OMG_MOVE_TYPE_SCALAR_VALUE, OMG_REMOVE_TYPE_WITH_COND = 1000, OMG_REMOVE_INPUT_WITH_ORIGINAL_TYPE, }; struct RemoveInputConfigure { int inputIdx = INT_MAX; std::string attrName; RemoveInputType moveType; bool attrValue = false; std::string originalType; }; class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistry { public: static OpRegistry *Instance(); std::vector registrationDatas; bool Register(const OpRegistrationData ®_data); domi::ImplyType GetImplyType(const std::string &op_type); void GetOpTypeByImplyType(std::vector &vec_op_type, const domi::ImplyType &imply_type); domi::ParseParamFunc GetParseParamFunc(const std::string &op_type); domi::ParseParamByOpFunc GetParseParamByOperatorFunc(const std::string &op_type); domi::FusionParseParamFunc GetFusionParseParamFunc(const std::string &op_type); domi::ParseSubgraphFunc GetParseSubgraphPostFunc(const std::string &op_type); domi::ImplyType GetImplyTypeByOriOpType(const std::string &ori_optype); const std::vector &GetRemoveInputConfigure(const std::string &ori_optype) const; bool GetOmTypeByOriOpType(const std::string &ori_optype, std::string &om_type); private: std::unordered_map> op_ori_optype_map_; std::unordered_map op_run_mode_map_; std::unordered_map opParseParamsFnMap_; std::unordered_map parse_params_by_op_func_map_; std::unordered_map fusionOpParseParamsFnMap_; std::unordered_map op_types_to_parse_subgraph_post_func_; std::unordered_map> remove_input_configure_map_; std::unordered_map originOpType2OmOpType_; }; } // namespace domi #endif // INC_REGISTER_OP_REGISTRY_H_