1 // 2 // EluOnnx.cpp 3 // MNNConverter 4 // 5 // Created by MNN on 2019/11/04. 6 // Copyright © 2018, Alibaba Group Holding Limited 7 // 8 9 #include "onnxOpConverter.hpp" 10 11 DECLARE_OP_CONVERTER(EluOnnx); 12 opType()13MNN::OpType EluOnnx::opType(){ 14 return MNN::OpType_ELU; 15 } 16 type()17MNN::OpParameter EluOnnx::type(){ 18 return MNN::OpParameter_ELU; 19 } 20 run(MNN::OpT * dstOp,const onnx::NodeProto * onnxNode,std::vector<const onnx::TensorProto * > initializers)21void EluOnnx::run(MNN::OpT *dstOp, const onnx::NodeProto *onnxNode, std::vector<const onnx::TensorProto *> initializers){ 22 23 auto eluParam = new MNN::ELUT; 24 25 float alpha = 1.0f; 26 for (int i = 0; i < onnxNode->attribute_size(); ++i) { 27 const auto &attributeProto = onnxNode->attribute(i); 28 const auto &attributeName = attributeProto.name(); 29 if (attributeName == "alpha") { 30 alpha = attributeProto.f(); 31 } 32 } 33 34 eluParam->alpha = alpha; 35 36 dstOp->main.value = eluParam; 37 } 38 39 REGISTER_CONVERTER(EluOnnx, Elu); 40