Skip to content

Support negative inputs for 'Pad' op #584

Description

@fthielke

Describe the bug

If I have a Pad op with negative paddings (in this case -16 in all the spatial dimensions of a 3D volume) in my model, onnx_tf.backend.prepare raises the following error:

ValueError: Paddings must be non-negative for 'Pad' (op: 'Pad') with input shapes: [1,32,40,40,40], [5,2] and with computed input tensors: input[1] = <[0 0][0 0][-16 -16][-16 -16][-16 -16]>.

However, this is not in line with the ONNX spec which supports negative paddings (ie. croppings) since version 2: https://github.com/onnx/onnx/blob/master/docs/Changelog.md#Pad-2

Python, ONNX, ONNX-TF, Tensorflow version

  • Python version: 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
  • ONNX version: 1.5.0
  • ONNX-TF version: 1.5.0
  • Tensorflow version: 2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions