diff --git a/src/core/src/op/space_to_batch.cpp b/src/core/src/op/space_to_batch.cpp index 57721c5e120472..b117a81ec2e056 100644 --- a/src/core/src/op/space_to_batch.cpp +++ b/src/core/src/op/space_to_batch.cpp @@ -102,7 +102,7 @@ bool ngraph::op::v1::SpaceToBatch::evaluate_space_to_batch(const HostTensorVecto auto data_shape = data->get_shape(); - if (!(data->get_shape().size() == 4 || data->get_shape().size() == 5)) { + if (!(data->get_shape().size() == 3 || data->get_shape().size() == 4 || data->get_shape().size() == 5)) { return false; } diff --git a/src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp b/src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp index 6e243cc4aee4b2..a664ea02ff263f 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp @@ -31,7 +31,7 @@ static void CreateBatchToSpaceOp(Program& p, const std::shared_ptr sizes = inConst->cast_vector(); int32_t default_size = i == 1 ? 1 : 0; - for (size_t s = sizes.size(); s < rank; s++) { + for (size_t s = sizes.size(); s < format.dimension(); s++) { sizes.push_back(default_size); } tensor_inputs.emplace_back(format, sizes, default_size); diff --git a/src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp b/src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp index 0be31669c28575..bbf9e0797a9442 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp @@ -31,7 +31,7 @@ static void CreateSpaceToBatchOp(Program& p, const std::shared_ptr sizes = inConst->cast_vector(); int32_t default_size = i == 1 ? 1 : 0; - for (size_t s = sizes.size(); s < rank; s++) { + for (size_t s = sizes.size(); s < format.dimension(); s++) { sizes.push_back(default_size); } tensor_inputs.emplace_back(format, sizes, default_size); @@ -41,14 +41,14 @@ static void CreateSpaceToBatchOp(Program& p, const std::shared_ptr{batchToSpaceParamsTuple({1, 1, 2, 2}, + return std::vector{batchToSpaceParamsTuple({1, 2, 2}, + {0, 0, 0}, + {0, 0, 0}, + {4, 1, 1}, + InferenceEngine::Precision::FP32, + InferenceEngine::Precision::UNSPECIFIED, + InferenceEngine::Precision::UNSPECIFIED, + InferenceEngine::Layout::ANY, + InferenceEngine::Layout::ANY, + CommonTestUtils::DEVICE_GPU), + batchToSpaceParamsTuple({1, 1, 2, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, {4, 1, 1, 1}, diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/space_to_batch.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/space_to_batch.cpp index 1ad03e2015187d..0a78ecff4622cb 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/space_to_batch.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/space_to_batch.cpp @@ -13,6 +13,16 @@ namespace { auto stb_only_test_cases = []() { return std::vector{ + spaceToBatchParamsTuple({1, 2, 2}, + {0, 0, 0}, + {0, 0, 0}, + {1, 2, 2}, + InferenceEngine::Precision::FP32, + InferenceEngine::Precision::UNSPECIFIED, + InferenceEngine::Precision::UNSPECIFIED, + InferenceEngine::Layout::ANY, + InferenceEngine::Layout::ANY, + CommonTestUtils::DEVICE_GPU), spaceToBatchParamsTuple({1, 1, 2, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, diff --git a/src/plugins/template/tests/functional/op_reference/batch_to_space.cpp b/src/plugins/template/tests/functional/op_reference/batch_to_space.cpp index e9f5ce61384d63..7c8da263b078fd 100644 --- a/src/plugins/template/tests/functional/op_reference/batch_to_space.cpp +++ b/src/plugins/template/tests/functional/op_reference/batch_to_space.cpp @@ -90,6 +90,15 @@ std::vector generateBatchToSpaceParams() { reference_tests::Tensor({2, 6}, IN_ET, std::vector{1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12}), "input_with_shape_4x3"), + // input_with_shape_4x1x3 + BatchToSpaceParams( + reference_tests::Tensor({4, 1, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}), + reference_tests::Tensor({3}, element::i64, std::vector{1, 1, 2}), + reference_tests::Tensor({3}, element::i64, std::vector{0, 0, 0}), + reference_tests::Tensor({3}, element::i64, std::vector{0, 0, 0}), + reference_tests::Tensor({2, 1, 6}, IN_ET, std::vector{1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12}), + "input_with_shape_4x1x3"), + // input_with_shape_4x1x1x3 BatchToSpaceParams( reference_tests::Tensor({4, 1, 1, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}), diff --git a/src/plugins/template/tests/functional/op_reference/space_to_batch.cpp b/src/plugins/template/tests/functional/op_reference/space_to_batch.cpp index 38210a96d95114..cbfe36d6963f30 100644 --- a/src/plugins/template/tests/functional/op_reference/space_to_batch.cpp +++ b/src/plugins/template/tests/functional/op_reference/space_to_batch.cpp @@ -82,6 +82,15 @@ template std::vector generateParams() { using T = typename element_type_traits::value_type; std::vector batchToSpaceParams { + // space_to_batch_3D + SpaceToBatchParams( + reference_tests::Tensor({1, 2, 2}, IN_ET, std::vector{1, 1, 1, 1}), + reference_tests::Tensor({3}, element::i64, std::vector{1, 1, 1}), + reference_tests::Tensor({3}, element::i64, std::vector{0, 0, 0}), + reference_tests::Tensor({3}, element::i64, std::vector{0, 0, 0}), + reference_tests::Tensor({1, 2, 2}, IN_ET, std::vector{1, 1, 1, 1}), + "space_to_batch_4D"), + // space_to_batch_4D SpaceToBatchParams( reference_tests::Tensor({1, 1, 2, 2}, IN_ET, std::vector{1, 1, 1, 1}),