Skip to content

Commit

Permalink
[nvidia_plugin] Remove host tensor dependency (#824)
Browse files Browse the repository at this point in the history
* Use ov::element in custom operations module

* Fix includes in nvidia_plugin after remove HostTensor
  • Loading branch information
praasz authored Jan 16, 2024
1 parent fad8b1e commit a906e5b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions modules/nvidia_plugin/src/cuda/cuda_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include "openvino/core/type/element_type.hpp"
#include "openvino/core/type/element_type_traits.hpp"

#ifdef __CUDACC__
#include <cuda/float16.hpp>
Expand Down
6 changes: 3 additions & 3 deletions modules/nvidia_plugin/src/ops/convert_color_i420.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class I420ConvertColorBase : public OperationBase {
constexpr const size_t N_DIM = 0;
constexpr const size_t H_DIM = 1;
constexpr const size_t W_DIM = 2;
NGRAPH_CHECK(node.get_input_size() == 1 || node.get_input_size() == 3,
"I420 conversion shall have one or 3 inputs, but it is ",
node.get_input_size());
OPENVINO_ASSERT(node.get_input_size() == 1 || node.get_input_size() == 3,
"I420 conversion shall have one or 3 inputs, but it is ",
node.get_input_size());
auto single_plane = node.get_input_size() == 1;

const auto& in_tensor_shape = node.get_input_shape(0);
Expand Down
6 changes: 3 additions & 3 deletions modules/nvidia_plugin/src/ops/convert_color_nv12.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class NV12ConvertColorBase : public OperationBase {
constexpr const size_t N_DIM = 0;
constexpr const size_t H_DIM = 1;
constexpr const size_t W_DIM = 2;
NGRAPH_CHECK(node.get_input_size() == 1 || node.get_input_size() == 2,
"NV12 conversion shall have one or 2 inputs, but it is ",
node.get_input_size());
OPENVINO_ASSERT(node.get_input_size() == 1 || node.get_input_size() == 2,
"NV12 conversion shall have one or 2 inputs, but it is ",
node.get_input_size());
const bool single_plane = node.get_input_size() == 1;

const auto& in_tensor_shape = node.get_input_shape(0);
Expand Down
42 changes: 21 additions & 21 deletions modules/nvidia_plugin/src/transformer/nodes/fully_connected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ov::PartialShape validate_matmul_output_shape(const ov::PartialShape& arg0_shape
auto arg0_rank = arg0_shape.rank().get_length();
auto arg1_rank = arg1_shape.rank().get_length();

NGRAPH_CHECK((arg0_rank != 0 && arg1_rank != 0), "Scalars are not supported as MatMul inputs.");
OPENVINO_ASSERT((arg0_rank != 0 && arg1_rank != 0), "Scalars are not supported as MatMul inputs.");

// Temporary Dimension vectors to calculate output shape
std::vector<ov::Dimension> arg0_shape_tmp(arg0_shape);
Expand Down Expand Up @@ -117,17 +117,17 @@ ov::PartialShape validate_matmul_output_shape(const ov::PartialShape& arg0_shape
auto merged_dimension = ov::Dimension::dynamic();
auto arg0_col_dim = arg0_shape_tmp[arg0_rank - 1];
auto arg1_row_dim = arg1_shape_tmp[arg1_rank - 2];
NGRAPH_CHECK(ov::Dimension::merge(merged_dimension, arg0_col_dim, arg1_row_dim) || arg0_col_dim.is_dynamic() ||
arg1_row_dim.is_dynamic(),
"Incompatible MatMul matrix dimension. ",
"First input dimension=",
arg0_col_dim,
" at COL_INDEX_DIM=",
(arg0_rank - 1),
" doesn't match the second input dimension=",
arg1_row_dim,
" at ROW_INDEX_DIM=",
(arg1_rank - 2));
OPENVINO_ASSERT(ov::Dimension::merge(merged_dimension, arg0_col_dim, arg1_row_dim) || arg0_col_dim.is_dynamic() ||
arg1_row_dim.is_dynamic(),
"Incompatible MatMul matrix dimension. ",
"First input dimension=",
arg0_col_dim,
" at COL_INDEX_DIM=",
(arg0_rank - 1),
" doesn't match the second input dimension=",
arg1_row_dim,
" at ROW_INDEX_DIM=",
(arg1_rank - 2));

// 3. If ranks of input arguments are different after steps 1 and 2,
// the smaller tensor is unsqueezed from the left side of the shape
Expand All @@ -152,15 +152,15 @@ ov::PartialShape validate_matmul_output_shape(const ov::PartialShape& arg0_shape
// to ensure MatMul backward compatibility.
// Instead fully dynamic dimension is set as default for such a case.
auto merged_dimension = ov::Dimension::dynamic();
NGRAPH_CHECK(ov::Dimension::merge(merged_dimension, arg0_shape_tmp[i], arg1_shape_tmp[i]) ||
arg0_shape_tmp[i].is_dynamic() || arg1_shape_tmp[i].is_dynamic(),
"Incompatible MatMul batch dimension. ",
"Can't merge first input dimension=",
arg0_shape_tmp[i],
" with second input dimension=",
arg1_shape_tmp[i],
" at index=",
i);
OPENVINO_ASSERT(ov::Dimension::merge(merged_dimension, arg0_shape_tmp[i], arg1_shape_tmp[i]) ||
arg0_shape_tmp[i].is_dynamic() || arg1_shape_tmp[i].is_dynamic(),
"Incompatible MatMul batch dimension. ",
"Can't merge first input dimension=",
arg0_shape_tmp[i],
" with second input dimension=",
arg1_shape_tmp[i],
" at index=",
i);

output_shape[i] = merged_dimension;
} else {
Expand Down

0 comments on commit a906e5b

Please sign in to comment.