Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
guojin-yan authored Oct 9, 2023
2 parents b5b7ba1 + d2944fd commit 89aecec
Show file tree
Hide file tree
Showing 22 changed files with 326 additions and 173 deletions.
2 changes: 1 addition & 1 deletion modules/nvidia_plugin/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ target_link_libraries(${OBJ_NAME}
fmt-header-only
openvino::runtime
openvino::runtime::dev
ov_core_dev
openvino::core::dev
PRIVATE
CUDA::cudart
CUDA::cublas
Expand Down
5 changes: 5 additions & 0 deletions modules/nvidia_plugin/src/ops/detection_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ DetectionOutputOp::DetectionOutputOp(const CreationContext& context,
IndexCollection&& inputIds,
IndexCollection&& outputIds)
: OperationBase{context, node, move(inputIds), move(outputIds)}, element_type_{node.get_input_element_type(0)} {
OPENVINO_ASSERT(node.get_element_type() == element_type_, "Node name: ", GetName());
for (const auto& input : node.inputs()) {
OPENVINO_ASSERT(input.get_element_type() == element_type_, "Node name: ", GetName());
}

const auto& ngraph_attrs = node.get_attrs();
kernel::DetectionOutput::Attrs kernel_attrs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "bidirectional_lstm_sequence_composition.hpp"
#include "concat_transformation.hpp"
#include "detection_output_fix_input_types_transformation.hpp"
#include "fuse_matmul_add.hpp"
#include "matmul_transformations.hpp"
#include "reduce_transformation.hpp"
Expand All @@ -52,6 +53,7 @@ void GraphTransformer::transform(const CUDA::Device& device,
if (inference_precision == ov::element::f16 && !isHalfSupported(device)) {
inference_precision = ov::element::f32;
}

auto upscale_precision = [&]() -> bool {
return !isHalfSupported(device) || inference_precision == ov::element::f32;
};
Expand Down Expand Up @@ -151,6 +153,8 @@ void GraphTransformer::transform(const CUDA::Device& device,
pass_manager.register_pass<ov::nvidia_gpu::pass::FullyConnectedTransformation>();
pass_manager.register_pass<ov::nvidia_gpu::pass::ConcatTransformation>();
pass_manager.register_pass<ov::nvidia_gpu::pass::ReduceTransformation>();
pass_manager.register_pass<ov::nvidia_gpu::pass::DetectionOutputFixInputTypesTransformation>();

// Do we actually need to eliminate broadcast one more time at the end?
pass_manager.register_pass<ov::pass::NopElimination>();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "detection_output_fix_input_types_transformation.hpp"

#include "openvino/cc/pass/itt.hpp"
#include "openvino/core/rt_info.hpp"
#include "openvino/op/convert.hpp"
#include "openvino/op/detection_output.hpp"
#include "openvino/pass/pattern/op/pattern.hpp"
#include "openvino/pass/pattern/op/wrap_type.hpp"

using namespace ov::pass::pattern;

namespace ov::nvidia_gpu::pass {

bool detection_output_fix_input_types(Matcher& m) {
const auto d_out = std::dynamic_pointer_cast<ov::op::v0::DetectionOutput>(m.get_match_root());
if (!d_out) {
return false;
}
const auto& type = d_out->get_element_type();
ov::OutputVector inputs;
bool needs_transform = false;
for (std::size_t i = 0; i < d_out->inputs().size(); ++i) {
const auto& input_type = d_out->input(i).get_element_type();
if (input_type != type) {
needs_transform = true;
const auto convert = std::make_shared<ov::op::v0::Convert>(d_out->input_value(i), type);
ov::copy_runtime_info(d_out, convert);
inputs.emplace_back(convert);
} else {
inputs.emplace_back(d_out->input_value(i));
}
}
if (!needs_transform) {
return false;
}
auto new_d_out = d_out->clone_with_new_inputs(inputs);
new_d_out->set_friendly_name(d_out->get_friendly_name());
ov::copy_runtime_info(d_out, new_d_out);
ov::replace_node(d_out, new_d_out);
return true;
}

DetectionOutputFixInputTypesTransformation::DetectionOutputFixInputTypesTransformation() {
MATCHER_SCOPE(DetectionOutputFixInputTypesTransformation);

const auto d_out = wrap_type<ov::op::v0::DetectionOutput>();
matcher_pass_callback callback = [](Matcher& m) { return detection_output_fix_input_types(m); };

const auto m = std::make_shared<Matcher>(d_out, matcher_name);
register_matcher(m, callback);
}

} // namespace ov::nvidia_gpu::pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include "openvino/pass/graph_rewrite.hpp"

namespace ov::nvidia_gpu::pass {

class DetectionOutputFixInputTypesTransformation : public ov::pass::MatcherPass {
public:
OPENVINO_RTTI("DetectionOutputFixInputTypesTransformation", "0");
DetectionOutputFixInputTypesTransformation();
};

} // namespace ov::nvidia_gpu::pass
1 change: 0 additions & 1 deletion modules/nvidia_plugin/tests/functional/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ov_add_test_target(
openvino_nvidia_gpu_plugin_obj
LINK_LIBRARIES
openvino::funcSharedTests
gmock
INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/../include
ADD_CLANG_FORMAT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <vector>

#include "behavior/plugin/hetero_synthetic.hpp"
#include "ngraph_functions/builders.hpp"
#include "ngraph_functions/subgraph_builders.hpp"
#include "ov_models/builders.hpp"
#include "ov_models/subgraph_builders.hpp"

namespace {
using namespace HeteroTests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "cuda_test_constants.hpp"
#include "finite_comparer.hpp"
#include "ngraph_functions/builders.hpp"
#include "ov_models/builders.hpp"

using namespace LayerTestsDefinitions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "cuda_test_constants.hpp"
#include "finite_comparer.hpp"
#include "ngraph_functions/builders.hpp"
#include "ov_models/builders.hpp"
#include "shared_test_classes/single_layer/convolution_backprop_data.hpp"

using namespace LayerTestsDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <functional_test_utils/skip_tests_config.hpp>
#include <ie_precision.hpp>
#include <limits>
#include <ngraph_functions/utils/ngraph_helpers.hpp>
#include <ov_models/utils/ov_helpers.hpp>
#include <openvino/op/util/attr_types.hpp>
#include <tuple>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <ngraph/opsets/opset1.hpp>
#include <ngraph/shape.hpp>
#include <ngraph/type/element_type.hpp>
#include <ngraph_functions/builders.hpp>
#include <ngraph_functions/utils/ngraph_helpers.hpp>
#include <ov_models/builders.hpp>
#include <ov_models/utils/ov_helpers.hpp>
#include <openvino/op/util/attr_types.hpp>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include <shared_test_classes/single_layer/activation.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <ngraph/op/parameter.hpp>
#include <ngraph/type/bfloat16.hpp>
#include <ngraph/type/float16.hpp>
#include <ngraph_functions/builders.hpp>
#include <ngraph_functions/utils/ngraph_helpers.hpp>
#include <ov_models/builders.hpp>
#include <ov_models/utils/ov_helpers.hpp>
#include <sstream>
#include <vector>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <cuda_test_constants.hpp>
#include <ie_precision.hpp>
#include <map>
#include <ngraph_functions/utils/ngraph_helpers.hpp>
#include <ov_models/utils/ov_helpers.hpp>
#include <string>
#include <vector>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "cuda_test_constants.hpp"
#include "finite_comparer.hpp"
#include "ngraph_functions/builders.hpp"
#include "ov_models/builders.hpp"

using namespace LayerTestsDefinitions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <cuda_test_constants.hpp>
#include <functional_test_utils/skip_tests_config.hpp>
#include <ie_precision.hpp>
#include <ngraph_functions/utils/ngraph_helpers.hpp>
#include <ov_models/utils/ov_helpers.hpp>
#include <openvino/op/util/attr_types.hpp>
#include <tuple>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <cstddef>
#include <cuda_test_constants.hpp>
#include <ngraph_functions/utils/ngraph_helpers.hpp>
#include <ov_models/utils/ov_helpers.hpp>
#include <openvino/op/util/attr_types.hpp>
#include <vector>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <ops/parameter.hpp>

#include "kernels/details/cuda_type_traits.hpp"
#include "ngraph_functions/builders.hpp"
#include "ov_models/builders.hpp"

namespace {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "single_layer_tests/transpose.hpp"

#include <cuda_test_constants.hpp>
#include <vector>

#include "common_test_utils/test_constants.hpp"
#include "cuda_test_constants.hpp"
#include "single_op_tests/transpose.hpp"

using namespace LayerTestsDefinitions;

namespace {

const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP16,
InferenceEngine::Precision::FP32,
using namespace ov::test;
using namespace ov::test::utils;
using ov::test::TransposeLayerTest;

const std::vector<ov::element::Type> model_types = {
ov::element::f16,
ov::element::f32,
};

const std::vector<std::vector<size_t>> inputShapes = {
std::vector<size_t>{256, 3, 100, 100},
std::vector<size_t>{1, 2048, 1, 1},
const std::vector<std::vector<ov::Shape>> input_shapes = {
{{256, 3, 100, 100}},
{{1, 2048, 1, 1}},
};

const std::vector<std::vector<size_t>> inputOrder = {
const std::vector<std::vector<size_t>> input_order = {
std::vector<size_t>{0, 3, 2, 1},
// Empty inputs are currently unsupported in nvidia_gpu.
// std::vector<size_t>{},
};

const auto params = testing::Combine(testing::ValuesIn(inputOrder),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::ValuesIn(inputShapes),
testing::Values(ov::test::utils::DEVICE_NVIDIA));
const auto params = testing::Combine(testing::ValuesIn(input_order),
testing::ValuesIn(model_types),
testing::ValuesIn(static_shapes_to_test_representation(input_shapes)),
testing::Values(DEVICE_NVIDIA));

INSTANTIATE_TEST_CASE_P(smoke_Transpose, TransposeLayerTest, params, TransposeLayerTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_Transpose,
TransposeLayerTest,
params,
TransposeLayerTest::getTestCaseName);

} // namespace
Loading

0 comments on commit 89aecec

Please sign in to comment.