void PadNodeConverter::convert(const onnx::NodeProto &onnx_node, ConverterContext *context) const
{
+ const auto opset_version = context->getOpsetVersion(onnx_node.domain());
+ if (opset_version >= 2)
+ convertPadAttrName("paddings", onnx_node, context);
+ else if (opset_version >= 1)
+ convertPadAttrName("pads", onnx_node, context);
+ else
+ throw std::runtime_error("Not supported opset version on Pad operation!");
+}
+
+void PadNodeConverter::convertPadAttrName(const std::string pad_attr_name,
+ const onnx::NodeProto &onnx_node,
+ ConverterContext *context) const
+{
std::vector<mir::Operation::Output *> inputs = context->getNodeInputs(onnx_node);
mir::Graph *graph = context->getGraph();
// 0.0f is the default value to be filled into padded cells.
- float value = getFloatAttribute(onnx_node, "value", 0.0f);
- auto pads_attr = findAttribute(onnx_node, "pads");
+ const float value = getFloatAttribute(onnx_node, "value", 0.0f);
+ const auto *pads_attr = findAttribute(onnx_node, pad_attr_name);
assert(pads_attr);
// "constant" is the default mode.
auto mode = getStringAttribute(onnx_node, "mode", "constant");
{
public:
void convert(const onnx::NodeProto &onnx_node, ConverterContext *context) const override;
+
+private:
+ void convertPadAttrName(const std::string pad_attr_name, const onnx::NodeProto &onnx_node,
+ ConverterContext *context) const;
};
} // namespace mir_onnx