Skip to content

Commit d3cdfe8

Browse files
oToToTmlukasze
andauthored
[core] Remove custom ov::optional (#28949)
### Description: As CPP17 is the default standard of OpenVINO, there is no need to use the self-implemented optional struct. Note: discussed in #28942. ### Related PRs: - #28942 Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com>
1 parent 77707fb commit d3cdfe8

23 files changed

+137
-260
lines changed

src/common/transformations/src/transformations/symbolic_transformations/symbol_optimization.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "transformations/symbolic_transformations/symbol_optimization.hpp"
66

7+
#include <optional>
8+
79
#include "itt.hpp"
810
#include "openvino/core/bound_evaluation_util.hpp"
911
#include "openvino/core/rt_info.hpp"
@@ -379,7 +381,7 @@ struct OutputValue {
379381
});
380382
}
381383

382-
static ov::optional<OutputValue> make(const ov::Output<ov::Node>& output) {
384+
static std::optional<OutputValue> make(const ov::Output<ov::Node>& output) {
383385
auto symbols = output.get_tensor().get_value_symbol();
384386
if (symbols.empty() || symbols.size() == 1)
385387
return {};

src/core/dev_api/openvino/core/tensor_util.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
#pragma once
66

7+
#include <optional>
8+
79
#include "openvino/op/constant.hpp"
8-
#include "ov_optional.hpp"
910

1011
namespace ov {
1112
namespace util {
@@ -15,7 +16,7 @@ template <typename T>
1516
OPENVINO_API Tensor greater_equal(const ov::Tensor& lhs, const T& element);
1617
OPENVINO_API bool reduce_and(const ov::Tensor& t);
1718
template <typename T>
18-
OPENVINO_API ov::optional<std::vector<T>> to_vector(const ov::Tensor& t);
19+
OPENVINO_API std::optional<std::vector<T>> to_vector(const ov::Tensor& t);
1920

2021
template <typename T>
2122
Tensor make_tensor_of_value(const element::Type_t& et, const T& value, Shape shape = {}) {
@@ -34,8 +35,8 @@ Tensor greater_equal(const ov::Tensor& lhs, const T& element) {
3435
}
3536

3637
template <typename T>
37-
ov::optional<std::vector<T>> to_vector(const ov::Tensor& t) {
38-
ov::optional<std::vector<T>> result;
38+
std::optional<std::vector<T>> to_vector(const ov::Tensor& t) {
39+
std::optional<std::vector<T>> result;
3940
if (t)
4041
result = ov::op::v0::Constant(t).cast_vector<T>();
4142
return result;

src/core/shape_inference/include/convolution_backprop_shape_inference.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//
44
#pragma once
55

6+
#include <optional>
7+
68
#include "convolution_backprop_shape_inference_util.hpp"
79
#include "convolution_shape_inference_util.hpp"
810
#include "openvino/op/convolution.hpp"
@@ -22,7 +24,7 @@ std::vector<TRShape> shape_infer(const ConvolutionBackpropData* op,
2224
NODE_VALIDATION_CHECK(op, inputs_count >= 2);
2325
using namespace ov::util;
2426

25-
ov::optional<TRShape> out_spatial_shape;
27+
std::optional<TRShape> out_spatial_shape;
2628
if (has_spatial_shape) {
2729
const auto& spatial_shape = input_shapes[2];
2830
NODE_VALIDATION_CHECK(op,

src/core/shape_inference/include/fft_common_validation.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include <optional>
8+
79
#include "openvino/core/axis_vector.hpp"
810
#include "openvino/core/validation_util.hpp"
911
#include "openvino/op/util/fft_base.hpp"
@@ -99,7 +101,7 @@ void validate_signal_size(const ov::op::util::FFTBase* op,
99101
template <class T>
100102
void shape_validation(const ov::op::util::FFTBase* op,
101103
const std::vector<T>& input_shapes,
102-
ov::optional<std::vector<int64_t>>& axes,
104+
std::optional<std::vector<int64_t>>& axes,
103105
FFTKind fft_kind) {
104106
const auto& input_shape = input_shapes[0];
105107
const auto& axes_shape = input_shapes[1];

src/core/shape_inference/include/group_convolution_backprop_shape_inference.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//
44
#pragma once
55

6+
#include <optional>
7+
68
#include "convolution_backprop_shape_inference.hpp"
79
#include "openvino/op/group_conv.hpp"
810
#include "utils.hpp"
@@ -33,7 +35,7 @@ std::vector<TRShape> shape_infer(const GroupConvolutionBackpropData* op,
3335
NODE_VALIDATION_CHECK(op, inputs_count >= 2);
3436
using namespace ov::util;
3537

36-
ov::optional<TRShape> out_spatial_shape;
38+
std::optional<TRShape> out_spatial_shape;
3739
if (has_spatial_shape) {
3840
const auto& spatial_shape = input_shapes[2];
3941
NODE_VALIDATION_CHECK(op,

src/core/shape_inference/include/interpolate_shape_inference.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#pragma once
66

77
#include <algorithm>
8-
#include <openvino/op/interpolate.hpp>
8+
#include <optional>
99

1010
#include "dimension_util.hpp"
11-
#include "pooling_shape_inference_util.hpp"
11+
#include "openvino/op/interpolate.hpp"
1212
#include "utils.hpp"
1313

1414
namespace ov {
@@ -153,8 +153,8 @@ TRShape make_padded_shape(const TShape& input, TInputIter pads_begin, TInputIter
153153
* @return Not null pointer with axes values or null pointer if can't get axes from input.
154154
*/
155155
template <class TShape, class TRes = std::vector<int64_t>>
156-
ov::optional<TRes> get_axes(const Node* const op, size_t port, bool has_axes, size_t rank, const ITensorAccessor& ta) {
157-
ov::optional<TRes> axes;
156+
std::optional<TRes> get_axes(const Node* const op, size_t port, bool has_axes, size_t rank, const ITensorAccessor& ta) {
157+
std::optional<TRes> axes;
158158
if (has_axes) {
159159
using TAxis = typename TRes::value_type;
160160
axes = std::move(get_input_const_data_as<TShape, TAxis, TRes>(op, port, ta));

src/core/shape_inference/include/ov_optional.hpp

-139
This file was deleted.

src/core/shape_inference/include/range_shape_inference.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ std::vector<TRShape> range_shape_infer(const Node* op,
102102

103103
output_shapes[0] = TRShape{static_cast<uint32_t>(strided)};
104104
} else {
105-
symbol_propagation(op, output_shapes, start, step, start_val, step_val);
105+
symbol_propagation(op, output_shapes, start, step, start_val.has_value(), step_val.has_value());
106106
}
107107
return output_shapes;
108108
}

src/core/shape_inference/include/segment_max_shape_inference.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include <cmath>
8+
#include <optional>
89

910
#include "openvino/op/segment_max.hpp"
1011
#include "utils.hpp"
@@ -50,7 +51,7 @@ std::vector<TRShape> shape_infer(const SegmentMax* op,
5051

5152
// validate num_segments input
5253
const auto num_segments_available = op->inputs().size() == 3;
53-
ov::optional<TRShape> num_segments;
54+
std::optional<TRShape> num_segments;
5455
if (num_segments_available) {
5556
num_segments = get_input_const_data_as_shape<TRShape>(op, 2, tensor_accessor);
5657
}

src/core/shape_inference/include/strided_slice_shape_inference.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
#pragma once
66

77
#include <array>
8-
#include <openvino/op/strided_slice.hpp>
8+
#include <optional>
99

10+
#include "openvino/op/strided_slice.hpp"
1011
#include "slice_shape_inference_utils.hpp"
1112
#include "utils.hpp"
1213

@@ -61,7 +62,7 @@ std::vector<TRShape> shape_infer(const StridedSlice* op,
6162
const auto begin = get_input_bounds<TRShape, int64_t>(op, 1, ta);
6263
const auto end = get_input_bounds<TRShape, int64_t>(op, 2, ta);
6364

64-
ov::optional<std::vector<int64_t>> strides;
65+
std::optional<std::vector<int64_t>> strides;
6566
if (input_shapes.size() > 3) {
6667
strides = get_input_const_data_as<TRShape, int64_t>(op, 3, ta);
6768
} else if (begin) {

0 commit comments

Comments
 (0)