Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit b3602cf

Browse files
Rob Earhartdiyessi
authored andcommitted
Handle negative padding (#3195)
1 parent 0053547 commit b3602cf

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

src/ngraph/runtime/plaidml/plaidml_ops_general.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ void ngraph::runtime::plaidml::ImplPad::Apply()
212212
NGRAPH_DEBUG << "Pad input dims: " << op().get_input_shape(0);
213213
NGRAPH_DEBUG << "Pad output dims: " << op().get_shape();
214214

215-
// FIXME: Compatibility hack inserted by amprocte, now that nGraph's Pad op no longer supports
216-
// interior padding.
217-
Shape padding_interior(op().get_padding_below().size(), 0);
218-
219215
auto dim_limit = op().get_shape().size();
220216

221217
bool any_zero_dims = false;
@@ -230,16 +226,17 @@ void ngraph::runtime::plaidml::ImplPad::Apply()
230226

231227
auto out_dsize = [&](std::size_t idx) {
232228
std::ostringstream s;
233-
std::size_t total_pad = op().get_padding_below().at(idx) + op().get_padding_above().at(idx);
234-
std::size_t in_dsize = op().get_input_shape(0).at(idx);
235-
if (in_dsize)
236-
{
237-
total_pad += padding_interior.at(idx) * (in_dsize - 1);
238-
}
229+
std::ptrdiff_t total_pad =
230+
op().get_padding_below().at(idx) + op().get_padding_above().at(idx);
231+
std::ptrdiff_t in_dsize = op().get_input_shape(0).at(idx);
239232
if (!any_zero_dims)
240233
{
241234
s << "DI" << idx + 1;
242-
if (total_pad)
235+
if (total_pad < 0)
236+
{
237+
s << " - " << (0 - total_pad);
238+
}
239+
else if (0 < total_pad)
243240
{
244241
s << " + " << total_pad;
245242
}
@@ -258,15 +255,7 @@ void ngraph::runtime::plaidml::ImplPad::Apply()
258255
{
259256
s << below << " + ";
260257
}
261-
auto interior = padding_interior.at(idx) + 1;
262-
if (interior != 1)
263-
{
264-
s << "(d" << idx + 1 << " * " << interior << ")";
265-
}
266-
else
267-
{
268-
s << "d" << idx + 1;
269-
}
258+
s << "d" << idx + 1;
270259
return s.str();
271260
};
272261

0 commit comments

Comments
 (0)