-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GPU] static strided_sliced crop to use tensor (#28507)
### Details: - *static strided_sliced crop to use tensor* ### Tickets: - *160254*
- Loading branch information
1 parent
b3a32cb
commit 398842a
Showing
6 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/stridedslice_eltwise.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <vector> | ||
|
||
#include "subgraph_tests/stridedslice_eltwise.hpp" | ||
|
||
namespace { | ||
using ov::test::StridedSliceEltwiseTest; | ||
|
||
std::vector<ov::test::StridedSliceEltwiseSpecificParams> ss_spec = { | ||
ov::test::StridedSliceEltwiseSpecificParams{ ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({ | ||
{ 1, 2, 2, 3}, { 1, 1, 3}})), | ||
{ 0 }, { 2 }, { 1 }, | ||
{ 0 }, { 0 }, { 0 }, { 1 }, { 0 } }, | ||
ov::test::StridedSliceEltwiseSpecificParams{ ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({ | ||
{ 2, 3, 4, 5}, { 3, 1, 1}})), | ||
{ 0 }, { 2 }, { 1 }, | ||
{ 0 }, { 0 }, { 0 }, { 1 }, { 0 } }, | ||
}; | ||
|
||
INSTANTIATE_TEST_SUITE_P(smoke_StridedSliceEltwise, StridedSliceEltwiseTest, | ||
testing::Combine( | ||
testing::ValuesIn(ss_spec), | ||
testing::Values(ov::element::f32), | ||
testing::Values(ov::test::utils::DEVICE_GPU)), | ||
StridedSliceEltwiseTest::getTestCaseName); | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/tests/functional/plugin/shared/include/subgraph_tests/stridedslice_eltwise.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "shared_test_classes/subgraph/stridedslice_eltwise.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
TEST_P(StridedSliceEltwiseTest, Inference) { | ||
run(); | ||
}; | ||
} // namespace test | ||
} // namespace ov |
42 changes: 42 additions & 0 deletions
42
...ctional/shared_test_classes/include/shared_test_classes/subgraph/stridedslice_eltwise.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <tuple> | ||
#include <string> | ||
#include <vector> | ||
#include <memory> | ||
|
||
#include "shared_test_classes/base/ov_subgraph.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
|
||
struct StridedSliceEltwiseSpecificParams { | ||
std::vector<InputShape> input_shape; | ||
std::vector<int64_t> begin; | ||
std::vector<int64_t> end; | ||
std::vector<int64_t> strides; | ||
std::vector<int64_t> begin_mask; | ||
std::vector<int64_t> end_mask; | ||
std::vector<int64_t> new_axis_mask; | ||
std::vector<int64_t> shrink_axis_mask; | ||
std::vector<int64_t> ellipsis_axis_mask; | ||
}; | ||
|
||
using StridedSliceEltwiseParamsTuple = typename std::tuple< | ||
StridedSliceEltwiseSpecificParams, // strided_slice params | ||
ov::element::Type, // Network precision | ||
std::string>; // Device name | ||
|
||
class StridedSliceEltwiseTest: public testing::WithParamInterface<StridedSliceEltwiseParamsTuple>, | ||
virtual public ov::test::SubgraphBaseStaticTest{ | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<StridedSliceEltwiseParamsTuple> &obj); | ||
protected: | ||
void SetUp() override; | ||
}; | ||
} // namespace test | ||
} // namespace ov |
83 changes: 83 additions & 0 deletions
83
src/tests/functional/shared_test_classes/src/subgraph/stridedslice_eltwise.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "shared_test_classes/subgraph/stridedslice_eltwise.hpp" | ||
|
||
#include "common_test_utils/node_builders/constant.hpp" | ||
#include "common_test_utils/node_builders/eltwise.hpp" | ||
#include "common_test_utils/test_enums.hpp" | ||
#include "common_test_utils/ov_tensor_utils.hpp" | ||
|
||
#include "openvino/op/parameter.hpp" | ||
#include "openvino/op/constant.hpp" | ||
#include "openvino/op/result.hpp" | ||
#include "openvino/op/reduce_sum.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
std::string StridedSliceEltwiseTest::getTestCaseName(const testing::TestParamInfo<StridedSliceEltwiseParamsTuple> &obj) { | ||
StridedSliceEltwiseSpecificParams params; | ||
ov::element::Type model_type; | ||
std::string target_device; | ||
std::tie(params, model_type, target_device) = obj.param; | ||
std::ostringstream result; | ||
result << "IS=("; | ||
for (size_t i = 0lu; i < params.input_shape.size(); i++) { | ||
result << ov::test::utils::partialShape2str({params.input_shape[i].first}) | ||
<< (i < params.input_shape.size() - 1lu ? "_" : ""); | ||
} | ||
result << ")_TS="; | ||
for (size_t i = 0lu; i < params.input_shape.front().second.size(); i++) { | ||
result << "{"; | ||
for (size_t j = 0lu; j < params.input_shape.size(); j++) { | ||
result << ov::test::utils::vec2str(params.input_shape[j].second[i]) << (j < params.input_shape.size() - 1lu ? "_" : ""); | ||
} | ||
result << "}_"; | ||
} | ||
result << "modelType=" << model_type.to_string() << "_"; | ||
result << "begin=" << ov::test::utils::vec2str(params.begin) << "_"; | ||
result << "end=" << ov::test::utils::vec2str(params.end) << "_"; | ||
result << "stride=" << ov::test::utils::vec2str(params.strides) << "_"; | ||
result << "begin_m=" << ov::test::utils::vec2str(params.begin_mask) << "_"; | ||
result << "end_m=" << ov::test::utils::vec2str(params.end_mask) << "_"; | ||
result << "new_axis_m=" << (params.new_axis_mask.empty() ? "def" : ov::test::utils::vec2str(params.new_axis_mask)) << "_"; | ||
result << "shrink_m=" << (params.shrink_axis_mask.empty() ? "def" : ov::test::utils::vec2str(params.shrink_axis_mask)) << "_"; | ||
result << "ellipsis_m=" << (params.ellipsis_axis_mask.empty() ? "def" : ov::test::utils::vec2str(params.ellipsis_axis_mask)) << "_"; | ||
result << "trgDev=" << target_device; | ||
return result.str(); | ||
} | ||
|
||
void StridedSliceEltwiseTest::SetUp() { | ||
StridedSliceEltwiseSpecificParams ssParams; | ||
ov::element::Type type; | ||
std::tie(ssParams, type, targetDevice) = this->GetParam(); | ||
|
||
init_input_shapes(ssParams.input_shape); | ||
|
||
ASSERT_EQ(ssParams.begin.size(), ssParams.end.size()); | ||
ASSERT_EQ(ssParams.begin.size(), ssParams.strides.size()); | ||
|
||
auto param = std::make_shared<ov::op::v0::Parameter>(type, inputDynamicShapes.front()); | ||
ov::Shape const_shape = {ssParams.begin.size()}; | ||
auto begin_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, ssParams.begin.data()); | ||
auto end_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, ssParams.end.data()); | ||
auto stride_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, ssParams.strides.data()); | ||
auto stridedSlice = std::make_shared<ov::op::v1::StridedSlice>(param, | ||
begin_node, | ||
end_node, | ||
stride_node, | ||
ssParams.begin_mask, | ||
ssParams.end_mask, | ||
ssParams.new_axis_mask, | ||
ssParams.shrink_axis_mask, | ||
ssParams.ellipsis_axis_mask); | ||
|
||
auto constant_input1_tensor = ov::test::utils::create_and_fill_tensor(type, targetStaticShapes.front()[1]); | ||
auto constant_input1 = std::make_shared<ov::op::v0::Constant>(constant_input1_tensor); | ||
auto eltw = ov::test::utils::make_eltwise(stridedSlice, constant_input1, ov::test::utils::EltwiseTypes::ADD); | ||
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(eltw)}; | ||
function = std::make_shared<ov::Model>(results, ov::ParameterVector{param}, "StridedSliceEltwise"); | ||
} | ||
} // namespace test | ||
} // namespace ov |