Skip to content

Commit

Permalink
[core] Api 2.0/migrate operators without evaluate (openvinotoolkit#19988
Browse files Browse the repository at this point in the history
)

* Migrate ops evaluate

* Remove using ngraph and std from ops

* Use OPENVINO_ASSERT instead of NGRAPH_CHECK

* Move `shape_util.hpp` to `dev_api/openvino/core/`

* Remove visit_attributes, same as base impl

* Fix build issues

* Fix build issues
  • Loading branch information
praasz authored Sep 25, 2023
1 parent a4e1f9d commit 7d1b7b6
Show file tree
Hide file tree
Showing 125 changed files with 877 additions and 994 deletions.
File renamed without changes.
12 changes: 2 additions & 10 deletions src/core/include/ngraph/op/util/recurrent_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,12 @@

#include "ngraph/deprecated.hpp"
#include "ngraph/node.hpp"
#include "openvino/op/util/recurrent_sequence.hpp"

namespace ngraph {
namespace op {
namespace util {
///
/// \brief Validates static rank and dimension for provided input parameters.
/// Additionally input_size dimension is checked for X and W inputs.
/// Applies to LSTM, GRU and RNN Sequences.
///
///
/// \param[in] input Vector with RNNSequence-like op inputs in following order:
/// X, initial_hidden_state, sequence_lengths, W, R and B.
///
NGRAPH_API_DEPRECATED void validate_seq_input_rank_dimension(const std::vector<ngraph::PartialShape>& input);
using ov::op::util::validate_seq_input_rank_dimension;
} // namespace util
} // namespace op
} // namespace ngraph
1 change: 0 additions & 1 deletion src/core/include/openvino/op/convert_like.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class OPENVINO_API ConvertLike : public Op {
ConvertLike(const Output<Node>& data, const Output<Node>& like);

void validate_and_infer_types() override;
bool visit_attributes(AttributeVisitor& visitor) override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;

Expand Down
2 changes: 0 additions & 2 deletions src/core/include/openvino/op/dft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class OPENVINO_API DFT : public util::FFTBase {
/// \param signal_size Signal sizes for 'axes'
DFT(const Output<Node>& data, const Output<Node>& axes, const Output<Node>& signal_size);

bool visit_attributes(AttributeVisitor& visitor) override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
};
} // namespace v7
Expand Down
1 change: 0 additions & 1 deletion src/core/include/openvino/op/gather.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class OPENVINO_API Gather : public op::util::GatherBase {
/// \param axis The tensor is a dimension index to gather data from
Gather(const Output<Node>& params, const Output<Node>& indices, const Output<Node>& axis);

bool visit_attributes(AttributeVisitor& visitor) override;
int64_t get_axis() const override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
Expand Down
1 change: 0 additions & 1 deletion src/core/include/openvino/op/gather_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class OPENVINO_API GatherTree : public Op {
const Output<Node>& max_seq_len,
const Output<Node>& end_token);

bool visit_attributes(AttributeVisitor& visitor) override;
void validate_and_infer_types() override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
Expand Down
1 change: 0 additions & 1 deletion src/core/include/openvino/op/hard_sigmoid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class OPENVINO_API HardSigmoid : public Op {
///
HardSigmoid(const Output<Node>& data, const Output<Node>& alpha, const Output<Node>& beta);

bool visit_attributes(AttributeVisitor& visitor) override;
void validate_and_infer_types() override;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
};
Expand Down
2 changes: 0 additions & 2 deletions src/core/include/openvino/op/idft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class OPENVINO_API IDFT : public util::FFTBase {
/// \param signal_size Signal sizes for 'axes'
IDFT(const Output<Node>& data, const Output<Node>& axes, const Output<Node>& signal_size);

bool visit_attributes(AttributeVisitor& visitor) override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
};
} // namespace v7
Expand Down
1 change: 0 additions & 1 deletion src/core/include/openvino/op/irdft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class OPENVINO_API IRDFT : public util::FFTBase {
IRDFT(const Output<Node>& data, const Output<Node>& axes, const Output<Node>& signal_size);

void validate_and_infer_types() override;
bool visit_attributes(AttributeVisitor& visitor) override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
};
Expand Down
1 change: 0 additions & 1 deletion src/core/include/openvino/op/rdft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class OPENVINO_API RDFT : public util::FFTBase {
RDFT(const Output<Node>& data, const Output<Node>& axes, const Output<Node>& signal_size);

void validate_and_infer_types() override;
bool visit_attributes(AttributeVisitor& visitor) override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
};
Expand Down
2 changes: 0 additions & 2 deletions src/core/include/openvino/op/selu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class OPENVINO_API Selu : public Op {

void validate_and_infer_types() override;

bool visit_attributes(AttributeVisitor& visitor) override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
};
} // namespace v0
Expand Down
26 changes: 26 additions & 0 deletions src/core/include/openvino/op/util/recurrent_sequence.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <vector>

#include "openvino/core/partial_shape.hpp"

namespace ov {
namespace op {
namespace util {
///
/// \brief Validates static rank and dimension for provided input parameters.
/// Additionally input_size dimension is checked for X and W inputs.
/// Applies to LSTM, GRU and RNN Sequences.
///
///
/// \param[in] input Vector with RNNSequence-like op inputs in following order:
/// X, initial_hidden_state, sequence_lengths, W, R and B.
///
OPENVINO_API void validate_seq_input_rank_dimension(const std::vector<ov::PartialShape>& input);
} // namespace util
} // namespace op
} // namespace ov
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <cmath>
#include <numeric>

#include "openvino/core/shape_util.hpp"
#include "openvino/reference/abs.hpp"
#include "openvino/reference/sum.hpp"
#include "openvino/reference/utils/type_util.hpp"
#include "shape_util.hpp"

namespace ov {
namespace reference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <cmath>
#include <numeric>

#include "openvino/core/shape_util.hpp"
#include "openvino/reference/utils/coordinate_transform.hpp"
#include "shape_util.hpp"

namespace ov {
namespace reference {
Expand Down
2 changes: 1 addition & 1 deletion src/core/reference/src/op/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "ngraph/runtime/host_tensor.hpp"
#include "ngraph/runtime/tensor.hpp"
#include "openvino/core/deprecated.hpp"
#include "openvino/core/shape_util.hpp"
#include "openvino/reference/concat.hpp"
#include "shape_util.hpp"

namespace ov {
namespace reference {
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/bound_evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include "ngraph/validation_util.hpp"
#include "openvino/core/dimension_tracker.hpp"
#include "openvino/core/rt_info.hpp"
#include "openvino/core/shape_util.hpp"
#include "openvino/op/util/symbolic_info.hpp"
#include "openvino/opsets/opset10.hpp"
#include "shape_util.hpp"
#include "tensor_conversion_util.hpp"
#include "transformations/rt_info/decompression.hpp"
#include "transformations/rt_info/is_shape_subgraph.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include "ngraph/graph_util.hpp"
#include "openvino/core/descriptor/input.hpp"
#include "openvino/core/rt_info.hpp"
#include "openvino/core/shape_util.hpp"
#include "openvino/pass/constant_folding.hpp"
#include "openvino/pass/pattern/matcher.hpp"
#include "shape_util.hpp"
#include "shape_validation.hpp"
#include "shared_node_info.hpp"
#include "tensor_conversion_util.hpp"
Expand Down
6 changes: 2 additions & 4 deletions src/core/src/op/adaptive_avg_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "adaptive_avg_pool_shape_inference.hpp"
#include "itt.hpp"

using namespace std;

namespace ov {

op::v8::AdaptiveAvgPool::AdaptiveAvgPool(const Output<Node>& data, const Output<Node>& output_shape)
Expand All @@ -25,10 +23,10 @@ void op::v8::AdaptiveAvgPool::validate_and_infer_types() {
set_output_type(0, get_input_element_type(0), output_shape);
}

shared_ptr<Node> op::v8::AdaptiveAvgPool::clone_with_new_inputs(const OutputVector& new_args) const {
std::shared_ptr<Node> op::v8::AdaptiveAvgPool::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v8_AdaptiveAvgPool_clone_with_new_inputs);
check_new_args_count(this, new_args);
return make_shared<v8::AdaptiveAvgPool>(new_args.at(0), new_args.at(1));
return std::make_shared<v8::AdaptiveAvgPool>(new_args.at(0), new_args.at(1));
}

} // namespace ov
5 changes: 2 additions & 3 deletions src/core/src/op/adaptive_max_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "adaptive_max_pool_shape_inference.hpp"
#include "itt.hpp"

using namespace std;
namespace ov {

op::v8::AdaptiveMaxPool::AdaptiveMaxPool(const Output<Node>& data,
Expand Down Expand Up @@ -39,10 +38,10 @@ void op::v8::AdaptiveMaxPool::validate_and_infer_types() {
set_output_type(1, m_index_element_type, output_shapes[1]);
}

shared_ptr<Node> op::v8::AdaptiveMaxPool::clone_with_new_inputs(const OutputVector& new_args) const {
std::shared_ptr<Node> op::v8::AdaptiveMaxPool::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v8_AdaptiveMaxPool_clone_with_new_inputs);
check_new_args_count(this, new_args);
return make_shared<v8::AdaptiveMaxPool>(new_args.at(0), new_args.at(1), m_index_element_type);
return std::make_shared<v8::AdaptiveMaxPool>(new_args.at(0), new_args.at(1), m_index_element_type);
}

void op::v8::AdaptiveMaxPool::set_index_element_type(const element::Type& type) {
Expand Down
26 changes: 11 additions & 15 deletions src/core/src/op/avg_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "ngraph/op/avg_pool.hpp"
#include "openvino/op/avg_pool.hpp"

#include "avg_pool_shape_inference.hpp"
#include "itt.hpp"
#include "ngraph/attribute_visitor.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/validation_util.hpp"

using namespace std;
#include "openvino/core/attribute_visitor.hpp"

// *** AvgPool OP SET 1 ***
ov::op::v1::AvgPool::AvgPool(const Output<Node>& arg,
Expand Down Expand Up @@ -109,15 +105,15 @@ void ov::op::v1::AvgPool::set_rounding_type(op::RoundingType rounding_type) {
m_rounding_type = rounding_type;
}

shared_ptr<ov::Node> ov::op::v1::AvgPool::clone_with_new_inputs(const OutputVector& new_args) const {
std::shared_ptr<ov::Node> ov::op::v1::AvgPool::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v1_AvgPool_clone_with_new_inputs);
check_new_args_count(this, new_args);
return make_shared<v1::AvgPool>(new_args.at(0),
m_strides,
m_pads_begin,
m_pads_end,
m_kernel,
m_exclude_pad,
m_rounding_type,
m_auto_pad);
return std::make_shared<AvgPool>(new_args.at(0),
m_strides,
m_pads_begin,
m_pads_end,
m_kernel,
m_exclude_pad,
m_rounding_type,
m_auto_pad);
}
53 changes: 27 additions & 26 deletions src/core/src/op/batch_norm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "ngraph/op/batch_norm.hpp"
#include "openvino/op/batch_norm.hpp"

#include <sstream>

#include "itt.hpp"
#include "ngraph/attribute_visitor.hpp"
#include "ngraph/validation_util.hpp"
#include "openvino/core/attribute_visitor.hpp"
#include "openvino/core/validation_util.hpp"

using namespace std;
using namespace ngraph;
namespace ov {

op::v0::BatchNormInference::BatchNormInference(const Output<Node>& input,
const Output<Node>& gamma,
Expand Down Expand Up @@ -44,17 +44,17 @@ void op::v0::BatchNormInference::validate_and_infer_types() {
set_output_size(1);
OPENVINO_SUPPRESS_DEPRECATED_START
std::tie(result_et, result_batch_shape, result_channel_shape) =
infer_batch_norm_forward(this,
get_input_element_type(INPUT_DATA),
get_input_element_type(INPUT_GAMMA),
get_input_element_type(INPUT_BETA),
get_input_element_type(INPUT_MEAN),
get_input_element_type(INPUT_VARIANCE),
get_input_partial_shape(INPUT_DATA),
get_input_partial_shape(INPUT_GAMMA),
get_input_partial_shape(INPUT_BETA),
get_input_partial_shape(INPUT_MEAN),
get_input_partial_shape(INPUT_VARIANCE));
ngraph::infer_batch_norm_forward(this,
get_input_element_type(INPUT_DATA),
get_input_element_type(INPUT_GAMMA),
get_input_element_type(INPUT_BETA),
get_input_element_type(INPUT_MEAN),
get_input_element_type(INPUT_VARIANCE),
get_input_partial_shape(INPUT_DATA),
get_input_partial_shape(INPUT_GAMMA),
get_input_partial_shape(INPUT_BETA),
get_input_partial_shape(INPUT_MEAN),
get_input_partial_shape(INPUT_VARIANCE));
OPENVINO_SUPPRESS_DEPRECATED_END
set_output_type(0, result_et, result_batch_shape);
}
Expand Down Expand Up @@ -101,17 +101,17 @@ void op::v5::BatchNormInference::validate_and_infer_types() {
set_output_size(1);
OPENVINO_SUPPRESS_DEPRECATED_START
std::tie(result_et, result_batch_shape, result_channel_shape) =
infer_batch_norm_forward(this,
get_input_element_type(INPUT_DATA),
get_input_element_type(INPUT_GAMMA),
get_input_element_type(INPUT_BETA),
get_input_element_type(INPUT_MEAN),
get_input_element_type(INPUT_VARIANCE),
get_input_partial_shape(INPUT_DATA),
get_input_partial_shape(INPUT_GAMMA),
get_input_partial_shape(INPUT_BETA),
get_input_partial_shape(INPUT_MEAN),
get_input_partial_shape(INPUT_VARIANCE));
ngraph::infer_batch_norm_forward(this,
get_input_element_type(INPUT_DATA),
get_input_element_type(INPUT_GAMMA),
get_input_element_type(INPUT_BETA),
get_input_element_type(INPUT_MEAN),
get_input_element_type(INPUT_VARIANCE),
get_input_partial_shape(INPUT_DATA),
get_input_partial_shape(INPUT_GAMMA),
get_input_partial_shape(INPUT_BETA),
get_input_partial_shape(INPUT_MEAN),
get_input_partial_shape(INPUT_VARIANCE));
OPENVINO_SUPPRESS_DEPRECATED_END
set_output_type(0, result_et, result_batch_shape);
}
Expand All @@ -126,3 +126,4 @@ std::shared_ptr<Node> op::v5::BatchNormInference::clone_with_new_inputs(const Ou
new_args.at(4),
m_epsilon);
}
} // namespace ov
4 changes: 2 additions & 2 deletions src/core/src/op/batch_to_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ bool batch_to_space_evaluate(const HostTensorVector& outputs, const HostTensorVe
bool ngraph::op::v1::BatchToSpace::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const {
OV_OP_SCOPE(v1_BatchToSpace_evaluate);
OPENVINO_SUPPRESS_DEPRECATED_START
NGRAPH_CHECK(validate_host_tensor_vector(inputs, 4));
NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1));
OPENVINO_ASSERT(validate_host_tensor_vector(inputs, 4));
OPENVINO_ASSERT(validate_host_tensor_vector(outputs, 1));
OPENVINO_SUPPRESS_DEPRECATED_END

if (outputs[0]->get_partial_shape().is_dynamic()) {
Expand Down
22 changes: 10 additions & 12 deletions src/core/src/op/binary_convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "openvino/core/axis_vector.hpp"
#include "openvino/core/coordinate_diff.hpp"

using namespace std;

ov::op::v1::BinaryConvolution::BinaryConvolution(const Output<Node>& data,
const Output<Node>& kernel,
const Strides& strides,
Expand Down Expand Up @@ -67,18 +65,18 @@ void ov::op::v1::BinaryConvolution::validate_and_infer_types() {
set_output_type(0, data_batch_et, output_shapes[0]);
}

shared_ptr<ov::Node> ov::op::v1::BinaryConvolution::clone_with_new_inputs(const OutputVector& new_args) const {
std::shared_ptr<ov::Node> ov::op::v1::BinaryConvolution::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v1_BinaryConvolution_clone_with_new_inputs);
check_new_args_count(this, new_args);
return make_shared<v1::BinaryConvolution>(new_args.at(0),
new_args.at(1),
m_strides,
m_pads_begin,
m_pads_end,
m_dilations,
m_mode,
m_pad_value,
m_auto_pad);
return std::make_shared<v1::BinaryConvolution>(new_args.at(0),
new_args.at(1),
m_strides,
m_pads_begin,
m_pads_end,
m_dilations,
m_mode,
m_pad_value,
m_auto_pad);
}

bool ov::op::v1::BinaryConvolution::visit_attributes(AttributeVisitor& visitor) {
Expand Down
Loading

0 comments on commit 7d1b7b6

Please sign in to comment.