[GPU] Fix strided slice clamped negative begin with negative stride (#16843)
Signed-off-by: Andrew Park <andrew.park@intel.com>
This commit is contained in:
parent
9e89b6c5f6
commit
63b16baa7e
@ -170,7 +170,7 @@ public:
|
||||
std::swap(begin, end);
|
||||
begin--;
|
||||
end--;
|
||||
} else {
|
||||
} else if (begin_org != -1) { // If begin is -1 with negative stride, clamping begin is already expected value
|
||||
if (is_clamp_begin)
|
||||
begin--;
|
||||
if (is_clamp_end)
|
||||
|
@ -1424,6 +1424,57 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void test_2x2x2x2_full_negative_stride_negative_begin_f_axis(bool is_caching_test) {
|
||||
// Input (BFYX): 1x2x2x2
|
||||
// Begin (BFYX): 0x-1
|
||||
// End (BFYX): 100x-100
|
||||
// Stride (BFYX): 1x-1
|
||||
// Output (BFYX): 1x2x2x2
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
auto input = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 2, 2, 2 } });
|
||||
|
||||
set_values(input, {
|
||||
0.0f, 1.0f, 2.0f, 3.0f,
|
||||
4.0f, 5.0f, 6.0f, 7.0f
|
||||
});
|
||||
std::vector<int64_t> begin = {
|
||||
0, -1
|
||||
};
|
||||
std::vector<int64_t> end= {
|
||||
100, -100
|
||||
};
|
||||
std::vector<int64_t> strides= {
|
||||
1, -1
|
||||
};
|
||||
|
||||
topology topology;
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(strided_slice("strided_slice", input_info("input"), begin, end, strides, {}, {}, {}, {}, {}, {1, 2, 2, 2}));
|
||||
|
||||
cldnn::network::ptr network = get_network(engine, topology, get_test_default_config(engine), get_test_stream_ptr(), is_caching_test);
|
||||
|
||||
network->set_input_data("input", input);
|
||||
|
||||
auto outputs = network->execute();
|
||||
|
||||
ASSERT_EQ(outputs.size(), size_t(1));
|
||||
ASSERT_EQ(outputs.begin()->first, "strided_slice");
|
||||
|
||||
auto output = outputs.at("strided_slice").get_memory();
|
||||
|
||||
std::vector<float> answers = {
|
||||
4.f, 5.f, 6.f, 7.f, 0.f, 1.f, 2.f, 3.f };
|
||||
|
||||
cldnn::mem_lock<float> output_ptr(output, get_test_stream());
|
||||
|
||||
ASSERT_EQ(output_ptr.size(), answers.size());
|
||||
for (size_t i = 0; i < answers.size(); ++i)
|
||||
{
|
||||
ASSERT_TRUE(are_equal(answers[i], output_ptr[i]));
|
||||
}
|
||||
}
|
||||
|
||||
void test_2x2x2x2_full_negative_stride_f_axis_clamp(bool is_caching_test) {
|
||||
// Input (BFYX): 1x2x2x2
|
||||
// Begin (BFYX): 0x100
|
||||
@ -1855,6 +1906,10 @@ TEST_F(strided_slice_gpu_constants, test_2x2x2x2_full_negative_stride_f_axis) {
|
||||
this->test_2x2x2x2_full_negative_stride_f_axis(false);
|
||||
}
|
||||
|
||||
TEST_F(strided_slice_gpu_constants, test_2x2x2x2_full_negative_stride_negative_begin_f_axis) {
|
||||
this->test_2x2x2x2_full_negative_stride_negative_begin_f_axis(false);
|
||||
}
|
||||
|
||||
TEST_F(strided_slice_gpu_constants, test_2x2x2x2_full_negative_stride_f_axis_clamp) {
|
||||
this->test_2x2x2x2_full_negative_stride_f_axis_clamp(false);
|
||||
}
|
||||
@ -1988,6 +2043,10 @@ TEST_F(strided_slice_gpu_constants, test_2x2x2x2_full_negative_stride_f_axis_cac
|
||||
this->test_2x2x2x2_full_negative_stride_f_axis(true);
|
||||
}
|
||||
|
||||
TEST_F(strided_slice_gpu_constants, test_2x2x2x2_full_negative_stride_negative_begin_f_axis_cached) {
|
||||
this->test_2x2x2x2_full_negative_stride_negative_begin_f_axis(true);
|
||||
}
|
||||
|
||||
TEST_F(strided_slice_gpu_constants, test_2x2x2x2_full_negative_stride_f_axis_clamp_cached) {
|
||||
this->test_2x2x2x2_full_negative_stride_f_axis_clamp(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user