Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tmva/sofie/inc/TMVA/ROperator_Pool.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,20 @@ public:
// find lower bounds of filtered area
int hmin = - fAttrPads[0]; // minimum lower bound value of filter area
// use stride instead of 1 when ceil_mode=1, so the loop covers the extra partial window
int hmax = fShapeX[2] + fAttrPads[1] - fAttrKernelShape[0] + (fAttrCeilMode ? (int)fAttrStrides[0] : 1);
int hmax = fShapeX[2] + fAttrPads[fDim] - fAttrKernelShape[0] + (fAttrCeilMode ? (int)fAttrStrides[0] : 1);
int wmin,wmax,dmin,dmax;

if(fDim >= 2){
wmin = - fAttrPads[2]; // minimum lower bound value of filter area
wmax = fShapeX[3] + fAttrPads[3] - fAttrKernelShape[1] + (fAttrCeilMode ? (int)fAttrStrides[1] : 1);
wmin = -fAttrPads[1]; // minimum lower bound value of filter area
wmax = fShapeX[3] + fAttrPads[fDim + 1] - fAttrKernelShape[1] + (fAttrCeilMode ? (int)fAttrStrides[1] : 1);
}
else{
wmin=1;
wmax=1;
}
if(fDim == 3){
dmin = - fAttrPads[4]; // minimum lower bound value of filter area
dmax = fShapeX[4] + fAttrPads[5] - fAttrKernelShape[2] + (fAttrCeilMode ? (int)fAttrStrides[2] : 1);
dmin = -fAttrPads[2]; // minimum lower bound value of filter area
dmax = fShapeX[4] + fAttrPads[fDim + 2] - fAttrKernelShape[2] + (fAttrCeilMode ? (int)fAttrStrides[2] : 1);
}
else{
dmin=1;
Expand Down
20 changes: 20 additions & 0 deletions tmva/sofie/test/TestCustomModelsFromONNX.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ constexpr auto modelDataSuffix = "_FromONNX.dat";
#include "input_models/references/MaxPool2d.ref.hxx"
#include "input_models/references/MaxPool2d_CeilMode.ref.hxx"
#include "input_models/references/MaxPool3d.ref.hxx"
#include "input_models/references/MaxPool2d_AsymPad.ref.hxx"
#include "input_models/references/Max.ref.hxx"
#include "input_models/references/MaxMultidirectionalBroadcast.ref.hxx"
#include "input_models/references/MinMultidirectionalBroadcast.ref.hxx"
Expand Down Expand Up @@ -848,6 +849,25 @@ TEST(ONNX, MaxPool2d){

}

TEST(ONNX, MaxPool2d_AsymPad)
{
constexpr float TOLERANCE = DEFAULT_TOLERANCE;

// 1x1x4x4 input with values 0..15
std::vector<float> input({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});

ASSERT_INCLUDE_AND_RUN(std::vector<float>, "MaxPool2d_AsymPad", input);

// pads=[0,1,0,1] (width padded, height not) gives a 1x1x3x5 output;
// the pre-fix code mis-read the pads and produced a 4x4 grid instead
EXPECT_EQ(output.size(), std::size(MaxPool2d_AsymPad_ExpectedOutput::output));

float *correct = MaxPool2d_AsymPad_ExpectedOutput::output;
for (size_t i = 0; i < output.size(); ++i) {
EXPECT_LE(std::abs(output[i] - correct[i]), TOLERANCE);
}
}

TEST(ONNX, MaxPool2d_CeilMode)
{
constexpr float TOLERANCE = DEFAULT_TOLERANCE;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace MaxPool2d_AsymPad_ExpectedOutput {
float output[] = {4, 5, 6, 7, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 15};
} // namespace MaxPool2d_AsymPad_ExpectedOutput
Loading