Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Support 1D dilations for Conv1d layers #3172

@ghost

Description

It seems that 1D dilations for torch's nn.Conv1d() layers is not currently supported:

location: ../../lib/Importer/ONNXModelLoader.cpp:557 message: Conv: dilations must be specified for 2 axes.

And from ONNXModelLoader.cpp, around the line 557:

  if (dict.count("dilations")) {
    std::vector<unsigned_t> dilations(2, 1);
    dilations = getShape<unsigned_t>(dict.at("dilations"));
    RETURN_ERR_IF_NOT(dilations.size() == 2,
                      "Conv: dilations must be specified for 2 axes.");
    RETURN_ERR_IF_NOT(dilations[1] == dilations[0],
                      "Conv: different dilation values along different axes "
                      "are not supported currently. values must be same.");
    dilation = dilations[0];
  }

Also, from that code, it looks like 3D convolutions are not supported either. So it looks like only 2D convolutions are supported. Is there a particular reason for this?

On the other hand, this (or similar) is what torch.onnx.export() produces for the torch.nn.Conv1d layer:

 %29 : Float(1, 256, 246) = onnx::Conv[dilations=[1], group=1, kernel_shape=[15], pads=[0, 0], strides=[4]](%28, %conv.weight, %conv.bias)

(see in particular dilations=[1]). Is there a quick workaround, maybe some dirty hack?

Metadata

Metadata

Assignees

No one assigned

    Labels

    onnxONNX support related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions