Skip to content

Commit

Permalink
[GPU][BUGFIX]: Fixed bug in SliceOp::calc_output_layout. (openvinotoo…
Browse files Browse the repository at this point in the history
…lkit#22663)

### Details:
- Fixed bug in SliceOp::calc_output_layout, which was calculating wrong
output shape due to use of deprecated tensor struct.
- Fixed and refactored all SliceOp unittests - which were expecting
wrong output data

### Tickets:
 - CVS-131491
  • Loading branch information
pkowalc1 authored Feb 13, 2024
1 parent 7d376ac commit e6070df
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 208 deletions.
12 changes: 6 additions & 6 deletions src/plugins/intel_gpu/src/graph/slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ slice_inst::typed_primitive_inst(network& network, slice_node const& node)
: parent(network, node) {}

layout slice_inst::calc_output_layout(slice_node const& node, kernel_impl_params const& impl_param) {
auto l = calc_output_layouts<ov::PartialShape>(node, impl_param)[0];
return layout{l.data_type, l.format, tensor{l.get_ordered_dims()}};
return calc_output_layouts<ov::PartialShape>(node, impl_param)[0];
}

template<typename ShapeType>
inline std::vector<layout> slice_inst::calc_output_layouts(const slice_node&, const kernel_impl_params& impl_param) {
std::vector<ShapeType> input_shapes{impl_param.input_layouts[0].get<ShapeType>()};
std::unordered_map<size_t, ov::Tensor> const_data;
for (std::size_t i = 1; i < impl_param.input_layouts.size(); i++) {
auto shape_len = shape_size(impl_param.input_layouts[i].get<ShapeType>().to_shape());
input_shapes.push_back({static_cast<ov::Dimension::value_type>(shape_len)});
const auto shape_len = shape_size(impl_param.input_layouts[i].get<ShapeType>().to_shape());
const ov::PartialShape input_shape{static_cast<ov::Dimension::value_type>(shape_len)};
input_shapes.push_back(input_shape);
auto gpu_mem = impl_param.memory_deps.at(i);
cldnn::mem_lock<uint8_t, mem_lock_type::read> gpu_mem_lock(gpu_mem, impl_param.get_stream());
const_data.emplace(i, make_tensor(layout { gpu_mem->get_layout().data_type, gpu_mem->get_layout().format,
tensor { std::vector<tensor::value_type>{ static_cast<tensor::value_type>(shape_len) } } }, gpu_mem_lock.data()));
const_data.emplace(i, make_tensor(layout {input_shape, gpu_mem->get_layout().data_type, gpu_mem->get_layout().format },
gpu_mem_lock.data()));
}
ov::op::v8::Slice op;
auto output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "single_op_tests/slice.hpp"
#include "common_test_utils/test_constants.hpp"

namespace {
using ov::test::Slice8LayerTest;
using ov::test::Slice8SpecificParams;
using ov::test::Slice8Params;

static const std::vector<Slice8SpecificParams> static_params = {
Slice8SpecificParams{ {{{}, {{ 16 }}}}, { 4 }, { 12 }, { 1 }, { 0 } },
Slice8SpecificParams{ {{{}, {{ 16 }}}}, { 0 }, { 8 }, { 2 }, { 0 } },
Slice8SpecificParams{ {{{}, {{ 20, 10, 5 }}}}, { 0, 0}, { 10, 20}, { 1, 1 }, { 1, 0 } },
Slice8SpecificParams{ {{{}, {{ 1, 2, 12, 100 }}}}, { 0, 1, 0, 1 }, { 1, 2, 5, 100 }, { 1, 1, 1, 10 }, {} },
Slice8SpecificParams{ {{{}, {{ 1, 12, 100 }}}}, { 0, 9, 0 }, { 1, 11, 1 }, { 1, 1, 1 }, { 0, 1, -1 } },
Slice8SpecificParams{ {{{}, {{ 1, 12, 100 }}}}, { 0, 1, 0 }, { 10, -1, 10 }, { 1, 1, 1 }, { -3, -2, -1} },
Slice8SpecificParams{ {{{}, {{ 2, 12, 100 }}}}, { 1, 12, 100 }, { 0, 7, 0 }, { -1, -1, -1 }, {} },
Slice8SpecificParams{ {{{}, {{ 2, 12, 100 }}}}, { 1, 4, 99 }, { 0, 9, 0 }, { -1, 2, -1 }, {} },
Slice8SpecificParams{ {{{}, {{ 2, 12, 100 }}}}, { -1, -1, -1 }, { 0, 4, 0 }, { -1, -2, -1 }, {} },
Slice8SpecificParams{ {{{}, {{ 2, 12, 100 }}}}, { -1, -1, -1 }, { 0, 0, 4 }, { -1, -1, -1 }, {2, 0, 1} },
Slice8SpecificParams{ {{{}, {{ 2, 12, 100 }}}}, { 0, 0, 4 }, { -5, -1, -1 }, { 1, 2, 1 }, {2, 0, 1} },
Slice8SpecificParams{ {{{}, {{ 2, 4, 5, 5, 68 }}}}, { 0, 1, 0, 0, 0 }, {
std::numeric_limits<std::int64_t>::max(),
std::numeric_limits<std::int64_t>::max(),
std::numeric_limits<std::int64_t>::max(),
std::numeric_limits<std::int64_t>::max(),
std::numeric_limits<std::int64_t>::max() }, { 1, 1, 1, 1, 16 }, {} },
Slice8SpecificParams{ {{{}, {{ 10, 12 }}}}, { -1, 1 }, { -9999, 10 }, { -1, 1 }, {} },
};

static const std::vector<ov::element::Type> types = {
ov::element::i64,
ov::element::i32,
ov::element::f32,
ov::element::f16
};

INSTANTIATE_TEST_SUITE_P(
smoke_GPU, Slice8LayerTest,
::testing::Combine(
::testing::ValuesIn(static_params),
::testing::ValuesIn(types),
::testing::Values(ov::test::utils::DEVICE_GPU)),
Slice8LayerTest::getTestCaseName);


} // namespace
202 changes: 0 additions & 202 deletions src/plugins/intel_gpu/tests/unit/test_cases/slice.cpp

This file was deleted.

Loading

0 comments on commit e6070df

Please sign in to comment.