Commit 4e56214f authored by tsocha's avatar tsocha Committed by Robert Kimball

[ONNX] Fix convpool padding by max(x, 0) on pad calculation (#2637)

* [ONNX] Fix convpool padding by max(x, 0) on pad calculation

* Update convpool.cpp

* Add Casting

* Add coment
parent 67328703
...@@ -82,8 +82,15 @@ namespace ngraph ...@@ -82,8 +82,15 @@ namespace ngraph
Shape pad_shape; Shape pad_shape;
for (std::size_t idx = 0; idx < input.size(); ++idx) for (std::size_t idx = 0; idx < input.size(); ++idx)
{ {
pad_shape.emplace_back((output.at(idx) - 1) * strides.at(idx) + // for `SAME` pading formula is: max((output - 1) * strides[1] + kernel - input, 0)
kernel.at(idx) - input.at(idx)); // Element type of shape is unsigned long.
// During pad computation we can get a value as result value
// During max computation unsigned long(-1) is greater than 0
// so std::max won't work corectly without casting
pad_shape.emplace_back(
std::max(static_cast<long>((output.at(idx) - 1) * strides.at(idx) +
kernel.at(idx) - input.at(idx)),
0L));
} }
return pad_shape; return pad_shape;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment