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

Padding in the MaxPool operator is not working #17

@owulveryck

Description

@owulveryck

I am trying to make the test of the Maxpool with padding to turn green (Line 169 of the file maxpool_autogenerated_test.go).

The test consists of an input tensor with shape (1, 3, 28, 28) of float32;
The kernel shape is (3,3) and the strides are set to their default values (1).
The padding given to the model is []int{2,2,2,2}, which has to be converted into a two dimensional []int for the Maxpool operator of Gorgonia. (the doc from onnx is here)

The expected shape of the output tensor is (1,3,30,30).

The problem is that no padding allows me to get this shape (I have tried manually to set the shape in the maxpool_wip.go file like this:

Here is the test I run from the batchnorm branch of this repo

$ cd operator
$ go test -run=TestMaxpool_2d_pads
--- FAIL: TestMaxpool_2d_pads (0.00s)
    maxpool_autogenerated_test.go:222: Info: operator &operators.Maxpool{name:"Maxpool", Pads:[]int{4, 4}, AutoPad:"", StorageOrder:0, KernelShape:(3, 3), Strides:[]int{1, 1}}
    maxpool_autogenerated_test.go:269:
                Error Trace:    maxpool_autogenerated_test.go:269
                Error:          Not equal:
                                expected: (1, 3, 30, 30)
                                actual  : (1, 3, 22, 22)

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -3,4 +3,4 @@
                                  (int) 3,
                                - (int) 30,
                                - (int) 30
                                + (int) 22,
                                + (int) 22
                                 }
                Test:           TestMaxpool_2d_pads
                Messages:       Tensors should be the same
    maxpool_autogenerated_test.go:270:
                Error Trace:    maxpool_autogenerated_test.go:270
                Error:          Max difference between -3.4028235e+38 and 1.7640524 allowed is 1e-05, but difference was -3.4028234663852886e+38
                Test:           TestMaxpool_2d_pads
                Messages:       Tensors should be the same
FAIL
exit status 1
FAIL    github.com/owulveryck/gorgonnx/operators        0.017s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions