Commit e5f54b6d authored by Ivan Tikhonov's avatar Ivan Tikhonov Committed by Scott Cyphers

DynSlice op: fix for JIRA: NGRAPH-3437 bug (#3713)

* add check for dynamic dimensions

* to_shape() -> rank()

* Delete unnecessary check

* Added in DeduceDynSlice suite to check dynamic dimension

* minor codestyle fix

* c-cast -> static_cast
parent e576a6c6
......@@ -680,7 +680,7 @@ PartialShape ngraph::infer_slice_shape(const Node* node,
int64_t num_input_axis_after_ellipses =
(begin.size() - axis - num_new_axis_after_ellipses -
1); // -1 because it's a position of ellipses
int64_t num_of_hidden_dims = input_shape.to_shape().size() -
int64_t num_of_hidden_dims = static_cast<size_t>(input_shape.rank()) -
num_input_axis_after_ellipses -
num_input_axis_before_ellipses;
for (int64_t i = 0; i < num_of_hidden_dims; ++i)
......@@ -704,6 +704,14 @@ PartialShape ngraph::infer_slice_shape(const Node* node,
// calculating dimension (begin, end, begin_mask, end_mask, stride)
else
{
// check dynamic dimension
if (input_shape[input_shape_idx].is_dynamic())
{
input_shape_idx++;
dim.emplace_back(Dimension::dynamic());
continue;
}
int64_t lb = begin[axis];
int64_t ub = end[axis];
......@@ -779,7 +787,7 @@ PartialShape ngraph::infer_slice_shape(const Node* node,
}
}
// get remaining values
for (; input_shape_idx < input_shape.to_shape().size(); ++input_shape_idx)
for (; input_shape_idx < static_cast<size_t>(input_shape.rank()); ++input_shape_idx)
{
dim.emplace_back(input_shape[input_shape_idx]);
}
......
......@@ -403,3 +403,16 @@ TEST(type_prop, dynslice_params_et_wrong)
DynSlice_Test_Type_Except(arg, lower_bounds, upper_bounds, strides);
}
}
TEST(DeduceDynSliceTest, dynslice_arg_dimension_dynamic_output_dimension_dynamic)
{
auto arg = make_shared<op::Parameter>(element::f32, PartialShape{3, Dimension::dynamic()});
auto lower_bounds = op::Constant::create(element::i64, {2}, {1, 2});
auto upper_bounds = op::Constant::create(element::i64, {2}, {2, 3});
auto strides = op::Constant::create(element::i64, {2}, {1, 1});
auto r = make_shared<op::DynSlice>(arg, lower_bounds, upper_bounds, strides);
auto output_val = PartialShape{1, Dimension::dynamic()};
EXPECT_TRUE(output_val.compatible(r->get_output_partial_shape(0)));
}
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