Commit e2b5a392 authored by charlie's avatar charlie
Browse files

Fix add/subtract opt dimensions

parent d176196b
...@@ -531,7 +531,7 @@ bool operator!=(const std::size_t& x, const shape::dynamic_dimension& y) { retur ...@@ -531,7 +531,7 @@ bool operator!=(const std::size_t& x, const shape::dynamic_dimension& y) { retur
shape::dynamic_dimension operator+(const shape::dynamic_dimension& x, const std::size_t& y) shape::dynamic_dimension operator+(const shape::dynamic_dimension& x, const std::size_t& y)
{ {
return {x.min + y, x.max + y, x.opt + y}; return {x.min + y, x.max + y, x.opt == 0 ? 0 : x.opt + y};
} }
shape::dynamic_dimension operator+(const std::size_t& x, const shape::dynamic_dimension& y) shape::dynamic_dimension operator+(const std::size_t& x, const shape::dynamic_dimension& y)
{ {
...@@ -539,11 +539,11 @@ shape::dynamic_dimension operator+(const std::size_t& x, const shape::dynamic_di ...@@ -539,11 +539,11 @@ shape::dynamic_dimension operator+(const std::size_t& x, const shape::dynamic_di
} }
shape::dynamic_dimension operator-(const shape::dynamic_dimension& x, const std::size_t& y) shape::dynamic_dimension operator-(const shape::dynamic_dimension& x, const std::size_t& y)
{ {
return {x.min - y, x.max - y, x.opt - y}; return {x.min - y, x.max - y, x.opt == 0 ? 0 : x.opt - y};
} }
shape::dynamic_dimension operator-(const std::size_t& x, const shape::dynamic_dimension& y) shape::dynamic_dimension operator-(const std::size_t& x, const shape::dynamic_dimension& y)
{ {
return {x - y.min, x - y.max, x - y.opt}; return {x - y.min, x - y.max, y.opt == 0 ? 0 : x - y.opt};
} }
bool operator==(const shape& x, const shape& y) bool operator==(const shape& x, const shape& y)
......
...@@ -1680,9 +1680,9 @@ TEST_CASE(pad_shape1) ...@@ -1680,9 +1680,9 @@ TEST_CASE(pad_shape1)
TEST_CASE(pad_dyn_shape0) TEST_CASE(pad_dyn_shape0)
{ {
migraphx::shape input{migraphx::shape::float_type, migraphx::shape input{migraphx::shape::float_type,
{{1, 4, 2}, {3, 3, 0}, {3, 3, 0}, {3, 3, 0}}}; {{1, 4, 2}, {3, 3, 0}, {3, 5, 0}, {3, 5, 0}}};
migraphx::shape output{migraphx::shape::float_type, migraphx::shape output{migraphx::shape::float_type,
{{1, 4, 2}, {3, 3, 0}, {5, 5, 0}, {5, 5, 0}}}; {{1, 4, 2}, {3, 3, 0}, {5, 7, 0}, {5, 7, 0}}};
expect_shape(output, migraphx::make_op("pad", {{"pads", {0, 0, 1, 1, 0, 0, 1, 1}}}), input); expect_shape(output, migraphx::make_op("pad", {{"pads", {0, 0, 1, 1, 0, 0, 1, 1}}}), input);
} }
......
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