!26653 [MSLITE][DEVELOP] add onnx hard sigmoid parser

Merge pull request !26653 from yangruoqi713/master
This commit is contained in:
i-robot 2021-11-23 06:30:33 +00:00 committed by Gitee
commit 2e7c2ef782
2 changed files with 18 additions and 1 deletions

View File

@ -136,11 +136,20 @@ ops::PrimitiveC *OnnxSigmoidParser::Parse(const onnx::GraphProto &onnx_graph, co
return prim.release();
}
ops::PrimitiveC *OnnxHardSigmoidParser::Parse(const onnx::GraphProto &onnx_graph, const onnx::NodeProto &onnx_node) {
auto prim = std::make_unique<ops::Activation>();
MS_CHECK_TRUE_RET(prim != nullptr, nullptr);
prim->set_activation_type(mindspore::ActivationType::HSIGMOID);
return prim.release();
}
OnnxNodeRegistrar g_onnxReluParser("Relu", new OnnxReluParser());
OnnxNodeRegistrar g_onnxLeakyReluParser("LeakyRelu", new OnnxLeakyReluParser());
OnnxNodeRegistrar g_onnxPReluParser("PRelu", new OnnxPReluParser());
OnnxNodeRegistrar g_onnxEluParser("Elu", new OnnxEluParser());
OnnxNodeRegistrar g_onnxTanhParser("Tanh", new OnnxTanhParser());
OnnxNodeRegistrar g_onnxSigmoodParser("Sigmoid", new OnnxSigmoidParser());
OnnxNodeRegistrar g_onnxSigmoidParser("Sigmoid", new OnnxSigmoidParser());
OnnxNodeRegistrar g_onnxHardSigmoidParser("HardSigmoid", new OnnxHardSigmoidParser());
} // namespace lite
} // namespace mindspore

View File

@ -70,6 +70,14 @@ class OnnxSigmoidParser : public OnnxNodeParser {
ops::PrimitiveC *Parse(const onnx::GraphProto &onnx_graph, const onnx::NodeProto &onnx_node) override;
};
class OnnxHardSigmoidParser : public OnnxNodeParser {
public:
OnnxHardSigmoidParser() : OnnxNodeParser("HardSigmoid") {}
~OnnxHardSigmoidParser() override = default;
ops::PrimitiveC *Parse(const onnx::GraphProto &onnx_graph, const onnx::NodeProto &onnx_node) override;
};
} // namespace lite
} // namespace mindspore
#endif // MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_ONNX_RELU_PARSER_H