Skip to content

Frontend conv/pool 'same' padding with striding is inconsistent #1693

@albertz

Description

@albertz

In the RF PyTorch backend for conv, the padding we add there seems to be off. Specifically, currently we do:

pad = s.dimension - 1 - (src_raw.shape[2 + i] - 1) % stride_
pad_left = pad // 2
pad_right = pad - pad_left

However, I noticed, I need to do this instead so that it matches when operating on a single seq:

pad = s.dimension - 1
pad_left = pad // 2
pad_right = pad - pad_left - (src_raw.shape[2 + i] - 1) % stride_

Now I'm not exactly sure how to introduce this change. That is maybe for another new behavior version? And/or also an explicit flag for it (which would mostly be just to test the direct difference of this).

Edit This is not only PyTorch. The TensorFlow backend behaves the same way. Now fixed via #1696.

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