[GPU] Support negative indice for static (#20909)

This commit is contained in:
Kelvin Choi 2023-12-01 20:04:50 +09:00 committed by GitHub
parent d1f72e2d01
commit ed0ce165ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -106,7 +106,12 @@ void CreateGatherOpBase(ProgramBuilder& p, const std::shared_ptr<T>& op, const i
// Set tensors for crop shape and offset
ov::Shape start_offset(input_shape.size());
start_offset[0] = static_cast<size_t>(result);
int32_t new_offset0 = static_cast<int32_t>(result);
if (support_neg_ind && new_offset0 < 0) {
new_offset0 += static_cast<int32_t>(start_offset.size());
}
start_offset[0] = static_cast<size_t>(new_offset0);
auto offsetTensor = tensor_from_dims(start_offset, 0);
auto outTensor = tensor_from_dims(out_shape, 1);

View File

@ -534,4 +534,29 @@ INSTANTIATE_TEST_CASE_P(smoke,
Gather8withIndicesDataLayerTest::getTestCaseName
);
std::vector<std::vector<int64_t>> nagativeSingleindicesData = {
{-1},
{-2},
{-3}
};
gather7ParamsTuple dummyParams2 = {
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({{4, 8, 2, 2}})),
ov::Shape({}),
std::tuple<int, int>{0, 0},
ov::element::f32,
ov::test::utils::DEVICE_GPU,
};
const auto gatherWithNagativeIndicesParams = testing::Combine(
testing::Values(dummyParams2),
testing::ValuesIn(nagativeSingleindicesData)
);
INSTANTIATE_TEST_CASE_P(smoke_Gather8NagativeIndice,
Gather8withIndicesDataLayerTest,
gatherWithNagativeIndicesParams,
Gather8withIndicesDataLayerTest::getTestCaseName
);
} // namespace