Commit dc4a2143 authored by Adam Procter's avatar Adam Procter

A few more tests for the negative-stride slicing issue that's worrying me.

parent dbdc25c8
......@@ -1129,19 +1129,784 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{2};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{1}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{5};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{1};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{5,2};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{5,2};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{5,2};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{6};
std::vector<int64_t> ub_values{3};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{1}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{6};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{6};
std::vector<int64_t> ub_values{2};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{6,3};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{6};
std::vector<int64_t> ub_values{1};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{6,3};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{6};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{6,3,0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{7};
std::vector<int64_t> ub_values{1};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{7,4};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{7};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{7,4,1};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{7};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::i32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::i32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<int32_t>(output);
std::vector<int32_t> expected_values{7,4,1};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{2});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0,3};
std::vector<int64_t> ub_values{0,0};
std::vector<int64_t> strides_values{1,-1};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{0};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{2});
auto input_ub = backend->create_tensor(element::i64, Shape{2});
auto input_strides = backend->create_tensor(element::i64, Shape{2});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{1,3}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{3.0,2.0,1.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{1};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{0};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{8}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{1};
std::vector<int64_t> ub_values{3};
std::vector<int64_t> strides_values{1};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{1.0,2.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{2};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{1};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{0};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{2.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{3};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{3.0,1.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{3};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{3.0,1.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0,3};
std::vector<int64_t> ub_values{0,0};
std::vector<int64_t> strides_values{1,-1};
std::vector<int64_t> lb_values{4};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{0};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
......@@ -1152,10 +1917,10 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_lb = backend->create_tensor(element::i64, Shape{2});
auto input_ub = backend->create_tensor(element::i64, Shape{2});
auto input_strides = backend->create_tensor(element::i64, Shape{2});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
......@@ -1166,29 +1931,74 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{1,3}));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{3.0,2.0,1.0};
std::vector<float> expected_values{4.0,2.0,0.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{1};
std::vector<int64_t> strides_values{-2};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{5.0,3.0,1.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{-9000};
std::vector<int64_t> ub_values{-8000};
std::vector<int64_t> strides_values{2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{0};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
......@@ -1197,7 +2007,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -1211,24 +2021,69 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{5}));
EXPECT_EQ(output->get_shape(), (Shape{0}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,1.0,2.0,3.0,4.0};
std::vector<float> expected_values{};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{1};
std::vector<int64_t> ub_values{3};
std::vector<int64_t> strides_values{1};
std::vector<int64_t> lb_values{-9000};
std::vector<int64_t> ub_values{8000};
std::vector<int64_t> strides_values{2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{4}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,2.0,4.0,6.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{-5};
std::vector<int64_t> ub_values{5};
std::vector<int64_t> strides_values{2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -1242,10 +2097,145 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{1}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{3.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{1};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{0};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{1,8}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{2});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0,0};
std::vector<int64_t> ub_values{0,0};
std::vector<int64_t> strides_values{1,1};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{0,1};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{2});
auto input_ub = backend->create_tensor(element::i64, Shape{2});
auto input_strides = backend->create_tensor(element::i64, Shape{2});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
copy_data(input_strides, strides_values);
auto output = backend->create_dynamic_tensor(element::f32, PartialShape::dynamic());
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{1,1,8}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{4});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{4});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{4});
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0,0,0,0};
std::vector<int64_t> ub_values{0,0,0,0};
std::vector<int64_t> strides_values{1,1,1,1};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{0,1,3};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{2};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
auto f = std::make_shared<Function>(NodeVector{slice}, ParameterVector{arg, lb, ub, strides});
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{4});
auto input_ub = backend->create_tensor(element::i64, Shape{4});
auto input_strides = backend->create_tensor(element::i64, Shape{4});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
......@@ -1256,11 +2246,11 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
EXPECT_EQ(output->get_shape(), (Shape{1,1,8,1}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{1.0,2.0};
std::vector<float> expected_values{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1271,13 +2261,13 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{2};
std::vector<int64_t> lb_values{3};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{1};
std::vector<int64_t> strides_values{-2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{0};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
......@@ -1301,11 +2291,11 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{}));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{2.0};
std::vector<float> expected_values{3.0,1.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1316,9 +2306,9 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{3};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{3};
std::vector<int64_t> strides_values{2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -1350,7 +2340,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{3.0,1.0};
std::vector<float> expected_values{0.0,2.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1361,11 +2351,11 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{3};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{4};
std::vector<int64_t> strides_values{2};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
......@@ -1395,7 +2385,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{3.0,1.0};
std::vector<float> expected_values{0.0,2.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1406,11 +2396,11 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{4};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{5};
std::vector<int64_t> strides_values{2};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
......@@ -1440,7 +2430,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{4.0,2.0,0.0};
std::vector<float> expected_values{0.0,2.0,4.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1451,11 +2441,11 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{6};
std::vector<int64_t> strides_values{2};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet ub_mask{};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
......@@ -1485,7 +2475,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{4.0,2.0,0.0};
std::vector<float> expected_values{0.0,2.0,4.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1496,8 +2486,8 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{-9000};
std::vector<int64_t> ub_values{-8000};
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{100};
std::vector<int64_t> strides_values{2};
AxisSet lb_mask{};
AxisSet ub_mask{};
......@@ -1526,11 +2516,11 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{0}));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{};
std::vector<float> expected_values{0.0,2.0,4.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1541,9 +2531,9 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{-9000};
std::vector<int64_t> ub_values{8000};
std::vector<int64_t> strides_values{2};
std::vector<int64_t> lb_values{4};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -1571,11 +2561,11 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,2.0,4.0};
std::vector<float> expected_values{4.0,2.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1586,9 +2576,9 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{-5};
std::vector<int64_t> ub_values{5};
std::vector<int64_t> strides_values{2};
std::vector<int64_t> lb_values{4};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -1616,11 +2606,11 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,2.0,4.0};
std::vector<float> expected_values{4.0,1.0};
EXPECT_EQ(output_values, expected_values);
}
{
......@@ -1631,12 +2621,12 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> lb_values{3};
std::vector<int64_t> ub_values{2};
std::vector<int64_t> strides_values{1};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
......@@ -1661,27 +2651,27 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{1,5}));
EXPECT_EQ(output->get_shape(), (Shape{0}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,1.0,2.0,3.0,4.0};
std::vector<float> expected_values{};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0,0};
std::vector<int64_t> ub_values{0,0};
std::vector<int64_t> strides_values{1,1};
std::vector<int64_t> lb_values{4};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{0,1};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
......@@ -1693,9 +2683,9 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_lb = backend->create_tensor(element::i64, Shape{2});
auto input_ub = backend->create_tensor(element::i64, Shape{2});
auto input_strides = backend->create_tensor(element::i64, Shape{2});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
......@@ -1706,29 +2696,29 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{1,1,5}));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,1.0,2.0,3.0,4.0};
std::vector<float> expected_values{4.0,2.0,0.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{4});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{4});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{4});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0,0,0,0};
std::vector<int64_t> ub_values{0,0,0,0};
std::vector<int64_t> strides_values{1,1,1,1};
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{2};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{0,1,3};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{2};
AxisSet ellipsis_mask{};
auto slice = std::make_shared<op::DynSlice>(arg, lb, ub, strides, lb_mask, ub_mask, new_mask, shrink_mask, ellipsis_mask);
......@@ -1737,10 +2727,10 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_lb = backend->create_tensor(element::i64, Shape{4});
auto input_ub = backend->create_tensor(element::i64, Shape{4});
auto input_strides = backend->create_tensor(element::i64, Shape{4});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
copy_data(input_arg, input_values);
copy_data(input_lb, lb_values);
copy_data(input_ub, ub_values);
......@@ -1751,24 +2741,24 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{1,1,5,1}));
EXPECT_EQ(output->get_shape(), (Shape{1}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,1.0,2.0,3.0,4.0};
std::vector<float> expected_values{5.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{3};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{1};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -1782,7 +2772,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -1800,20 +2790,20 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{3.0,1.0};
std::vector<float> expected_values{5.0,2.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{3};
std::vector<int64_t> strides_values{2};
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -1827,7 +2817,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -1845,22 +2835,22 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,2.0};
std::vector<float> expected_values{5.0,2.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{4};
std::vector<int64_t> strides_values{2};
std::vector<int64_t> lb_values{5};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
......@@ -1872,7 +2862,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -1890,20 +2880,20 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,2.0};
std::vector<float> expected_values{5.0,2.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{5};
std::vector<int64_t> strides_values{2};
std::vector<int64_t> lb_values{6};
std::vector<int64_t> ub_values{3};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -1917,7 +2907,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -1931,24 +2921,24 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
EXPECT_EQ(output->get_shape(), (Shape{1}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,2.0,4.0};
std::vector<float> expected_values{6.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{6};
std::vector<int64_t> strides_values{2};
std::vector<int64_t> lb_values{6};
std::vector<int64_t> ub_values{2};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -1962,7 +2952,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -1976,24 +2966,24 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,2.0,4.0};
std::vector<float> expected_values{6.0,3.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{100};
std::vector<int64_t> strides_values{2};
std::vector<int64_t> lb_values{6};
std::vector<int64_t> ub_values{1};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -2007,7 +2997,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2021,26 +3011,26 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{3}));
EXPECT_EQ(output->get_shape(), (Shape{2}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{0.0,2.0,4.0};
std::vector<float> expected_values{6.0,3.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{4};
std::vector<int64_t> lb_values{6};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet ub_mask{0};
AxisSet new_mask{};
AxisSet shrink_mask{};
AxisSet ellipsis_mask{};
......@@ -2052,7 +3042,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2066,23 +3056,23 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{2}));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{4.0,2.0};
std::vector<float> expected_values{6.0,3.0,0.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{4};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> lb_values{7};
std::vector<int64_t> ub_values{1};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
......@@ -2097,7 +3087,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2115,20 +3105,20 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{4.0,1.0};
std::vector<float> expected_values{7.0,4.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{3};
std::vector<int64_t> ub_values{2};
std::vector<int64_t> strides_values{1};
std::vector<int64_t> lb_values{7};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{};
AxisSet new_mask{};
......@@ -2142,7 +3132,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2156,24 +3146,24 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
ex->call({output}, {input_arg, input_lb, input_ub, input_strides});
EXPECT_EQ(output->get_element_type(), (element::f32));
EXPECT_EQ(output->get_shape(), (Shape{0}));
EXPECT_EQ(output->get_shape(), (Shape{3}));
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{};
std::vector<float> expected_values{7.0,4.0,1.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::f32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<float> input_values(5);
std::vector<float> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<float>(0));
std::vector<int64_t> lb_values{4};
std::vector<int64_t> lb_values{7};
std::vector<int64_t> ub_values{0};
std::vector<int64_t> strides_values{-2};
std::vector<int64_t> strides_values{-3};
AxisSet lb_mask{};
AxisSet ub_mask{0};
AxisSet new_mask{};
......@@ -2187,7 +3177,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::f32, Shape{5});
auto input_arg = backend->create_tensor(element::f32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2205,16 +3195,16 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto output_values = read_vector<float>(output);
std::vector<float> expected_values{4.0,2.0,0.0};
std::vector<float> expected_values{7.0,4.0,1.0};
EXPECT_EQ(output_values, expected_values);
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(5);
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{80000};
std::vector<int64_t> ub_values{0};
......@@ -2234,7 +3224,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{5});
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2249,12 +3239,12 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
});
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(5);
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{-80000};
std::vector<int64_t> ub_values{0};
......@@ -2274,7 +3264,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{5});
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2289,12 +3279,12 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
});
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{2});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{2});
std::vector<int32_t> input_values(5);
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{0,0};
std::vector<int64_t> ub_values{0,0};
......@@ -2314,7 +3304,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{5});
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{2});
auto input_ub = backend->create_tensor(element::i64, Shape{2});
auto input_strides = backend->create_tensor(element::i64, Shape{2});
......@@ -2329,12 +3319,12 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
});
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(5);
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{0};
......@@ -2354,7 +3344,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{5});
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2369,12 +3359,12 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
});
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(5);
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{1};
......@@ -2394,7 +3384,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{5});
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2409,12 +3399,12 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
});
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(5);
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{2};
......@@ -2434,7 +3424,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{5});
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......@@ -2449,12 +3439,12 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
});
}
{
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{5});
auto arg = std::make_shared<op::Parameter>(element::i32, Shape{8});
auto lb = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto ub = std::make_shared<op::Parameter>(element::i64, Shape{1});
auto strides = std::make_shared<op::Parameter>(element::i64, Shape{1});
std::vector<int32_t> input_values(5);
std::vector<int32_t> input_values(8);
std::iota(input_values.begin(), input_values.end(), static_cast<int32_t>(0));
std::vector<int64_t> lb_values{0};
std::vector<int64_t> ub_values{0};
......@@ -2474,7 +3464,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
auto backend = runtime::Backend::create("${BACKEND_NAME}",true);
auto ex = backend->compile(f);
auto input_arg = backend->create_tensor(element::i32, Shape{5});
auto input_arg = backend->create_tensor(element::i32, Shape{8});
auto input_lb = backend->create_tensor(element::i64, Shape{1});
auto input_ub = backend->create_tensor(element::i64, Shape{1});
auto input_strides = backend->create_tensor(element::i64, Shape{1});
......
......@@ -439,6 +439,49 @@ NGRAPH_TEST(${BACKEND_NAME}, dyn_slice)
t[3:2:1]
t[4::-2]
#
# A couple of tests for negative-stride slicing. The issue we want to
# be on the lookout for is this:
#
# 01234567
# ..1..0.. [5:0:-3] # suppose we start with this, want to convert
# _____ # to pos stride. suppose that our stride is
# # "uneven" wrt the slicing region, i.e. the
# # start-to-end distance is not an even
# # multiple of the strides (e.g. here: we get
# # elements 5 and 2.)
#
# 01234567
# .0..1... [1:6:3] # if we just reverse the sign of the stride
# _____ # and flip the start/end indices while
# # traversing, we will get out the wrong
# # elements. (e.g. here: we get elements 1 and
# # 4, which are not what we want.)
#
# 01234567
# ..0..1.. [2:6:3] # the correct thing to do is to adjust the
# ____ # start of our reversed slice to be the last
# # element that is *actually* touched by the
# # original negative striding, not the
# # boundary of the region. (e.g. here: we get
# # elements 2 and 5, which are what we want.)
#
# There's some logic to do this transformation in DynElimination, but
# it feels a bit delicate.
#
t.set_shape((8,))
t[5:2:-3]
t[5:1:-3]
t[5:0:-3]
t[5::-3]
t[6:3:-3]
t[6:2:-3]
t[6:1:-3]
t[6::-3]
t[7:1:-3]
t[7:0:-3]
t[7::-3]
t.set_dtype('int32')
t[80000] # error expected (shrink-axis OOB)
t[-80000] # error expected (shrink-axis OOB)
......
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