|
| 1 | +// Copyright (C) 2024 Intel Corporation |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +// |
| 4 | +#include "shared_test_classes/base/ov_subgraph.hpp" |
| 5 | +#include "shared_test_classes/single_op/convolution.hpp" |
| 6 | + |
| 7 | +#include "common_test_utils/ov_tensor_utils.hpp" |
| 8 | +#include "common_test_utils/node_builders/convolution.hpp" |
| 9 | +#include "common_test_utils/data_utils.hpp" |
| 10 | +#include "common_test_utils/node_builders/constant.hpp" |
| 11 | +#include "common_test_utils/node_builders/fake_quantize.hpp" |
| 12 | + |
| 13 | +#include "openvino/op/parameter.hpp" |
| 14 | +#include "openvino/op/constant.hpp" |
| 15 | +#include "openvino/op/result.hpp" |
| 16 | +#include "openvino/op/convolution.hpp" |
| 17 | +#include "openvino/op/fake_quantize.hpp" |
| 18 | + |
| 19 | + |
| 20 | +namespace { |
| 21 | +using ov::test::InputShape; |
| 22 | + |
| 23 | +typedef std::tuple< |
| 24 | + std::vector<InputShape>, // input shape |
| 25 | + ov::element::Type, // Network precision |
| 26 | + std::string // Device name |
| 27 | +> convStaticConcatDynamicGPUTestDynamicParamsSet; |
| 28 | +class ConvStaticConcatDynamicGPUTestDynamic : public testing::WithParamInterface<convStaticConcatDynamicGPUTestDynamicParamsSet>, |
| 29 | + virtual public ov::test::SubgraphBaseTest { |
| 30 | +public: |
| 31 | + static std::string getTestCaseName(const testing::TestParamInfo<convStaticConcatDynamicGPUTestDynamicParamsSet>& obj) { |
| 32 | + std::vector<InputShape> inputShape; |
| 33 | + ov::element::Type model_type; |
| 34 | + std::string targetDevice; |
| 35 | + |
| 36 | + convStaticConcatDynamicGPUTestDynamicParamsSet basicParamsSet = obj.param; |
| 37 | + std::tie(inputShape, model_type, targetDevice) = basicParamsSet; |
| 38 | + |
| 39 | + std::ostringstream result; |
| 40 | + result << "IS_Dynamic="; |
| 41 | + result << ov::test::utils::partialShape2str({inputShape[0].first}) << "_"; |
| 42 | + for (const auto& actual_shape : {inputShape[0].second}) { |
| 43 | + result << ov::test::utils::partialShape2str({actual_shape[0]}) << "_"; |
| 44 | + } |
| 45 | + result << "IS_Static="; |
| 46 | + result << ov::test::utils::partialShape2str({inputShape[1].first}) << "_"; |
| 47 | + for (const auto& actual_shape : {inputShape[1].second}) { |
| 48 | + result << ov::test::utils::partialShape2str({actual_shape[0]}) << "_"; |
| 49 | + } |
| 50 | + result << "model_type=" << model_type << "_"; |
| 51 | + result << "targetDevice=" << targetDevice; |
| 52 | + return result.str(); |
| 53 | + } |
| 54 | + |
| 55 | +protected: |
| 56 | + void SetUp() override { |
| 57 | + std::vector<InputShape> inputShape; |
| 58 | + ov::element::Type model_type; |
| 59 | + convStaticConcatDynamicGPUTestDynamicParamsSet basicParamsSet = this->GetParam(); |
| 60 | + std::tie(inputShape, model_type, targetDevice) = basicParamsSet; |
| 61 | + |
| 62 | + init_input_shapes(inputShape); |
| 63 | + |
| 64 | + ov::ParameterVector inputParams; |
| 65 | + for (auto&& shape : inputDynamicShapes) |
| 66 | + inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(model_type, shape)); |
| 67 | + |
| 68 | + // Constant weight |
| 69 | + auto sh0 = inputShape[0].first[1].get_length(); |
| 70 | + auto sh1 = inputShape[1].first[1].get_length(); |
| 71 | + ov::PartialShape inShape1 = {sh0, sh1, 1}; |
| 72 | + auto tensor1 = ov::test::utils::create_and_fill_tensor(model_type, inShape1.to_shape()); |
| 73 | + std::shared_ptr<ov::Node> constantWeightOp = std::make_shared<ov::op::v0::Constant>(tensor1); |
| 74 | + constantWeightOp->set_friendly_name("constantWeight"); |
| 75 | + |
| 76 | + // Static convolution |
| 77 | + auto convolutionOp = ov::test::utils::make_convolution(inputParams[1], constantWeightOp, model_type, {3}, {1}, {0}, {0}, {1}, ov::op::PadType::EXPLICIT, 1); |
| 78 | + convolutionOp->set_friendly_name("convolution"); |
| 79 | + |
| 80 | + // Dynamic Concat |
| 81 | + const auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector({inputParams[0], convolutionOp}), 2); |
| 82 | + |
| 83 | + // Function |
| 84 | + auto makeFunction = [](const ov::element::Type &ngPrc, ov::ParameterVector ¶ms, const std::shared_ptr<ov::Node> &lastNode) { |
| 85 | + ov::ResultVector results; |
| 86 | + |
| 87 | + for (size_t i = 0; i < lastNode->get_output_size(); i++) |
| 88 | + results.push_back(std::make_shared<ov::op::v0::Result>(lastNode->output(i))); |
| 89 | + |
| 90 | + return std::make_shared<ov::Model>(results, params, "Concat"); |
| 91 | + }; |
| 92 | + function = makeFunction(model_type, inputParams, concat); |
| 93 | + } |
| 94 | +}; |
| 95 | + |
| 96 | +TEST_P(ConvStaticConcatDynamicGPUTestDynamic, Inference) { |
| 97 | + run(); |
| 98 | +} |
| 99 | + |
| 100 | +const std::vector<std::vector<ov::test::InputShape>> dynInputShapes1D = { |
| 101 | + { |
| 102 | + {{1, 192, ov::Dimension::dynamic()}, {{1, 192, 1}}}, |
| 103 | + {{1, 256, 1}, {{1, 256, 1}}}, |
| 104 | + }, |
| 105 | + { |
| 106 | + {{1, 32, ov::Dimension::dynamic()}, {{1, 32, 1}}}, |
| 107 | + {{1, 48, 1}, {{1, 48, 1}}}, |
| 108 | + }, |
| 109 | +}; |
| 110 | + |
| 111 | +INSTANTIATE_TEST_SUITE_P(smoke_static_conv_n_dynamic_concat, ConvStaticConcatDynamicGPUTestDynamic, |
| 112 | + ::testing::Combine(::testing::ValuesIn(dynInputShapes1D), |
| 113 | + ::testing::Values(ov::element::f16), |
| 114 | + ::testing::Values(ov::test::utils::DEVICE_GPU)), |
| 115 | + ConvStaticConcatDynamicGPUTestDynamic::getTestCaseName); |
| 116 | + |
| 117 | +} // namespace |
0 commit comments