OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] Support for empty second input in Bucketize (#26292)
David Nam41b502a30796
diff --git a/src/plugins/intel_gpu/src/plugin/ops/constant.cpp b/src/plugins/intel_gpu/src/plugin/ops/constant.cppindex f87c2b39848..a947bdf5851 100644--- a/src/plugins/intel_gpu/src/plugin/ops/constant.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/constant.cpp@@ -22,6 +22,7 @@#include "openvino/op/util/op_types.hpp"#include "openvino/op/loop.hpp"#include "openvino/op/tensor_iterator.hpp"+#include "openvino/op/bucketize.hpp"#include "openvino/op/util/binary_elementwise_bitwise.hpp"#include "intel_gpu/primitives/data.hpp"@@ -80,11 +81,6 @@ static void create_data(ProgramBuilder& p, const ov::Shape& const_shape, const sconstTensor.feature[0] = 1;}- // If const_shape has a dimension = 0, then create tensor with single value- // TODO: check if dim=0 is a valid case- if (std::accumulate(const_shape.begin(), const_shape.end(), size_t(1), std::multiplies<size_t>()) == 0)- constTensor = cldnn::tensor{1};-cldnn::data_types out_dtype = cldnn::element_type_to_data_type(op->get_output_element_type(0));cldnn::layout constLayout = p.use_new_shape_infer() ? cldnn::layout(const_shape, out_dtype, constFormat) :cldnn::layout(out_dtype, constFormat, constTensor);@@ -134,7 +130,6 @@ static bool is_btiwise(Node* node) {static void CreateConstantOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0::Constant>& op) {ov::Shape constDims = op->get_shape();auto constUsers = op->get_output_target_inputs(0);-std::unordered_map<std::shared_ptr<ov::op::v0::Constant>, ConstProperties> consts = {{op, {false}}};diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/bucketize.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/bucketize.cppindex 89da3853927..15f39f9f635 100644--- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/bucketize.cpp+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/bucketize.cpp@@ -106,4 +106,44 @@ INSTANTIATE_TEST_SUITE_P(smoke_Bucketize_input_u8,testing::Values(ov::test::utils::DEVICE_GPU)),BucketizeLayerTest::getTestCaseName);+INSTANTIATE_TEST_SUITE_P(smoke_Bucketize_empty_boundary_f16,+ BucketizeLayerTest,+ testing::Combine(testing::Values(ov::test::static_shapes_to_test_representation({{6, 7, 3, 2, 8, 5}, {0}})),+ testing::ValuesIn(with_right_bound),+ testing::Values(ov::element::f16),+ testing::Values(ov::element::f16),+ testing::ValuesIn(out_precision),+ testing::Values(ov::test::utils::DEVICE_GPU)),+ BucketizeLayerTest::getTestCaseName);++INSTANTIATE_TEST_SUITE_P(smoke_Bucketize_empty_boundary_f32,+ BucketizeLayerTest,+ testing::Combine(testing::Values(ov::test::static_shapes_to_test_representation({{6, 7, 3, 2, 8, 5}, {0}})),+ testing::ValuesIn(with_right_bound),+ testing::Values(ov::element::f32),+ testing::Values(ov::element::f32),+ testing::ValuesIn(out_precision),+ testing::Values(ov::test::utils::DEVICE_GPU)),+ BucketizeLayerTest::getTestCaseName);++INSTANTIATE_TEST_SUITE_P(smoke_Bucketize_empty_boundary_i8,+ BucketizeLayerTest,+ testing::Combine(testing::Values(ov::test::static_shapes_to_test_representation({{6, 7, 3, 2, 8, 5}, {0}})),+ testing::ValuesIn(with_right_bound),+ testing::Values(ov::element::i8),+ testing::Values(ov::element::i8),+ testing::ValuesIn(out_precision),+ testing::Values(ov::test::utils::DEVICE_GPU)),+ BucketizeLayerTest::getTestCaseName);++INSTANTIATE_TEST_SUITE_P(smoke_Bucketize_empty_boundary_u8,+ BucketizeLayerTest,+ testing::Combine(testing::Values(ov::test::static_shapes_to_test_representation({{6, 7, 3, 2, 8, 5}, {0}})),+ testing::ValuesIn(with_right_bound),+ testing::Values(ov::element::u8),+ testing::Values(ov::element::u8),+ testing::ValuesIn(out_precision),+ testing::Values(ov::test::utils::DEVICE_GPU)),+ BucketizeLayerTest::getTestCaseName);+} // namespacediff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/bucketize.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/bucketize.cppnew file mode 100644index 00000000000..d65f4ea51c9--- /dev/null+++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/bucketize.cpp@@ -0,0 +1,154 @@+// Copyright (C) 2018-2022 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#include <random>++#include "common_test_utils/ov_tensor_utils.hpp"+#include "shared_test_classes/base/ov_subgraph.hpp"++#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"+#include "openvino/op/bucketize.hpp"++namespace {+using ov::test::InputShape;++typedef std::tuple<InputShape, // input shape+ InputShape, // boundary shape+ bool, // with_right_bound+ ov::element::Type, // input type+ ov::element::Type, // boundary type+ ov::element::Type, // output type+ std::string+> BucketizeLayerParamsSet;++class BucketizeLayerDynamicTest : public testing::WithParamInterface<BucketizeLayerParamsSet>,+ virtual public ov::test::SubgraphBaseTest {+public:+ static std::string getTestCaseName(testing::TestParamInfo<BucketizeLayerParamsSet> obj) {+ InputShape shapes;+ InputShape boundary;+ bool with_right_boundary;+ ov::element::Type input_type;+ ov::element::Type boundary_type;+ ov::element::Type output_type;+ std::string deviceName;+ std::tie(shapes, boundary, with_right_boundary, input_type, boundary_type, output_type, deviceName) = obj.param;++ std::ostringstream results;+ results << "IS=" << ov::test::utils::partialShape2str({shapes.first}) << "_";+ results << "TS=";+ for (const auto& item : shapes.second) {+ results << ov::test::utils::vec2str(item) << "_";+ }+ for (const auto& item : boundary.second) {+ results << ov::test::utils::vec2str(item) << "_";+ }+ results << "withRightBoundary=" << with_right_boundary << "_";+ results << "netPRC=" << input_type << "_";+ results << "boundPRC=" << boundary_type << "_";+ results << "outPRC=" << output_type << "_";++ return results.str();+ }++ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {+ inputs.clear();+ const auto& func_inputs = function->inputs();+ ov::Tensor tensor;+ for (size_t i = 0; i < func_inputs.size(); ++i) {+ const auto& func_input = func_inputs[i];+ tensor = ov::test::utils::create_and_fill_tensor(func_input.get_element_type(), targetInputStaticShapes[i]);+ inputs.insert({func_input.get_node_shared_ptr(), tensor});+ }+ inferRequestNum++;+ }++protected:+ size_t inferRequestNum = 0;++ void SetUp() override {+ InputShape shapes;+ InputShape boundary;+ bool with_right_boundary;+ ov::element::Type input_type;+ ov::element::Type boundary_type;+ ov::element::Type output_type;+ std::string deviceName;+ std::tie(shapes, boundary, with_right_boundary, input_type, boundary_type, output_type, deviceName) = this->GetParam();++ targetDevice = ov::test::utils::DEVICE_GPU;++ std::vector<InputShape> input_shapes;+ input_shapes.push_back(shapes);+ input_shapes.push_back(boundary);++ init_input_shapes(input_shapes);++ ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(input_type, inputDynamicShapes.front()),+ std::make_shared<ov::op::v0::Parameter>(boundary_type, inputDynamicShapes.back())};++ auto bucketize = std::make_shared<ov::op::v3::Bucketize>(params[0], params[1], output_type, with_right_boundary);++ ov::ResultVector results;+ for (size_t i = 0; i < bucketize->get_output_size(); i++) {+ results.push_back(std::make_shared<ov::op::v0::Result>(bucketize->output(i)));+ }++ function = std::make_shared<ov::Model>(results, params, "BucketizeFuncTest");+ }+};++TEST_P(BucketizeLayerDynamicTest, inference) {+ run();+}++const std::vector<InputShape> input_shapes = {+ {{-1, -1}, {{2, 3}, {3, 4}}}+};++const std::vector<InputShape> boundary_shapes = {+ {{-1}, {{1}, {0}}}+};++const std::vector<bool> with_right_boundary = {+ true,+ false+};++const std::vector<ov::element::Type> input_precisions = {+ ov::element::f16,+ ov::element::f32,+ ov::element::i64,+ ov::element::i32,+ ov::element::i8,+ ov::element::u8+};++const std::vector<ov::element::Type> boundary_precisions = {+ ov::element::f16,+ ov::element::f32,+ ov::element::i64,+ ov::element::i32,+ ov::element::i8,+ ov::element::u8+};++const std::vector<ov::element::Type> output_precisions = {+ ov::element::i64,+ ov::element::i32+};++INSTANTIATE_TEST_SUITE_P(smoke_bucketize_dynamic,+ BucketizeLayerDynamicTest,+ ::testing::Combine(+ ::testing::ValuesIn(input_shapes),+ ::testing::ValuesIn(boundary_shapes),+ ::testing::ValuesIn(with_right_boundary),+ ::testing::ValuesIn(input_precisions),+ ::testing::ValuesIn(boundary_precisions),+ ::testing::ValuesIn(output_precisions),+ ::testing::Values(ov::test::utils::DEVICE_GPU)),+ BucketizeLayerDynamicTest::getTestCaseName);++} // namespace\ No newline at end of filediff --git a/tests/layer_tests/tensorflow_tests/test_tf_Bucketize.py b/tests/layer_tests/tensorflow_tests/test_tf_Bucketize.pyindex 102663503d8..a3bb2e371d1 100644--- a/tests/layer_tests/tensorflow_tests/test_tf_Bucketize.py+++ b/tests/layer_tests/tensorflow_tests/test_tf_Bucketize.py@@ -61,8 +61,6 @@ class TestBucketize(CommonTFLayerTest):def test_bucketize(self, input_shape, input_type, boundaries_size,ie_device, precision, ir_version, temp_dir,use_legacy_frontend):- if ie_device == 'GPU' and boundaries_size == 0:- pytest.skip("149852: accuracy error for boundaries_size == 0 on GPU")if platform.machine() in ["aarch64", "arm64", "ARM64"] and boundaries_size == 0:pytest.skip("149853: segmentation fault or signal 11 for boundaries_size == 0 on CPU")self._test(*self.create_bucketize_net(input_shape, input_type, boundaries_size),