Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Op][Interpolate-11] Add evaluate to Interpolate-11 for constant folding (#29738)

Katarzyna Mitrusf4d0fd77c717
diff --git a/src/core/include/openvino/op/interpolate.hpp b/src/core/include/openvino/op/interpolate.hpp
index d60e95cdb7f..427f86ba97e 100644
--- a/src/core/include/openvino/op/interpolate.hpp
+++ b/src/core/include/openvino/op/interpolate.hpp
@@ -108,9 +108,6 @@ public:
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override;
bool has_evaluate() const override;
-
-private:
- bool evaluate_interpolate(TensorVector& outputs, const TensorVector& inputs) const;
};
} // namespace v4
@@ -143,9 +140,8 @@ public:
void validate_and_infer_types() override;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
- bool has_evaluate() const override {
- return false;
- }
+ bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override;
+ bool has_evaluate() const override;
};
} // namespace v11
} // namespace op
diff --git a/src/core/reference/include/openvino/reference/interpolate.hpp b/src/core/reference/include/openvino/reference/interpolate.hpp
index 5696fc16e17..e188a39f020 100644
--- a/src/core/reference/include/openvino/reference/interpolate.hpp
+++ b/src/core/reference/include/openvino/reference/interpolate.hpp
@@ -24,6 +24,12 @@ using Nearest_mode = op::v4::Interpolate::NearestMode;
using Transform_mode = op::v4::Interpolate::CoordinateTransformMode;
using InterpolateMode = op::v4::Interpolate::InterpolateMode;
+/// \brief Gets the function to calculate the nearest pixel.
+///
+/// \param mode the calculation mode
+///
+/// \return The function to calculate the nearest pixel.
+std::function<int64_t(float, bool)> get_func(Nearest_mode mode);
/// \brief Calculation of nearest pixel.
class GetNearestPixel final {
public:
@@ -51,45 +57,15 @@ private:
using Func = std::function<int64_t(float, bool)>;
Func m_func;
-
- /// \brief Gets the function to calculate the nearest pixel.
- ///
- /// \param mode the calculation mode
- ///
- /// \return The function to calculate the nearest pixel.
- Func get_func(Nearest_mode mode) {
- switch (mode) {
- case Nearest_mode::ROUND_PREFER_CEIL:
- return [](float x_original, bool) {
- return static_cast<int64_t>(std::round(x_original));
- };
- case Nearest_mode::FLOOR:
- return [](float x_original, bool) {
- return static_cast<int64_t>(std::floor(x_original));
- };
- case Nearest_mode::CEIL:
- return [](float x_original, bool) {
- return static_cast<int64_t>(std::ceil(x_original));
- };
- case Nearest_mode::SIMPLE:
- return [](float x_original, bool is_downsample) {
- if (is_downsample) {
- return static_cast<int64_t>(std::ceil(x_original));
- } else {
- return static_cast<int64_t>(x_original);
- }
- };
- default:;
- }
- return [](float x_original, bool) {
- if (x_original == static_cast<int64_t>(x_original) + 0.5f) {
- return static_cast<int64_t>(std::floor(x_original));
- }
- return static_cast<int64_t>(std::round(x_original));
- };
- }
};
+/// \brief Gets the function to calculate the source coordinate.
+///
+/// \param mode the calculation mode
+///
+/// \return The function to calculate the source coordinate.
+std::function<float(float, float, float, float)> get_func(Transform_mode mode);
+
/// \brief Calculation of the source coordinate using the resized coordinate
class GetOriginalCoordinate final {
public:
@@ -122,40 +98,6 @@ private:
using Func = std::function<float(float, float, float, float)>;
Func m_func;
-
- /// \brief Gets the function to calculate the source coordinate.
- ///
- /// \param mode the calculation mode
- ///
- /// \return The function to calculate the source coordinate.
- Func get_func(Transform_mode mode) {
- switch (mode) {
- case Transform_mode::PYTORCH_HALF_PIXEL:
- return [](float x_resized, float x_scale, float length_resized, float) {
- return length_resized > 1 ? (x_resized + 0.5f) / x_scale - 0.5f : 0.0f;
- };
- break;
- case Transform_mode::ASYMMETRIC:
- return [](float x_resized, float x_scale, float, float) {
- return x_resized / x_scale;
- };
- break;
- case Transform_mode::TF_HALF_PIXEL_FOR_NN:
- return [](float x_resized, float x_scale, float, float) {
- return (x_resized + 0.5f) / x_scale;
- };
- break;
- case Transform_mode::ALIGN_CORNERS:
- return [](float x_resized, float, float length_resized, float length_original) {
- return length_resized == 1 ? 0 : x_resized * (length_original - 1) / (length_resized - 1);
- };
- break;
- default:;
- }
- return [](float x_resized, float x_scale, float, float) {
- return ((x_resized + 0.5f) / x_scale) - 0.5f;
- };
- }
};
/// \brief Helper class to implent non-template parts of the interpolation calculation.
@@ -684,111 +626,20 @@ void InterpolateEval<T>::nearest_func(const T* input_data, T* out) {
}
}
-inline void pad_input_data(const uint8_t* data_ptr,
- uint8_t* padded_data_ptr,
- size_t type_size,
- const ov::Shape& input_shape,
- const ov::Shape& padded_input_shape,
- const std::vector<size_t>& pads_begin) {
- const CoordinateTransformBasic input_transform{input_shape};
-
- for (const Coordinate& input_coord : input_transform) {
- auto padded_coord = input_coord;
- size_t i = 0;
- for (size_t pad : pads_begin) {
- padded_coord[i] += pad;
- ++i;
- }
- uint8_t* dst_ptr = padded_data_ptr + type_size * coordinate_index(padded_coord, padded_input_shape);
- const uint8_t* src_ptr = data_ptr + type_size * coordinate_index(input_coord, input_shape);
- memcpy(dst_ptr, src_ptr, type_size);
- }
-}
-
-inline PartialShape get_padded_input_shape(const PartialShape& input_shape,
- const op::v0::Interpolate::Attributes& attrs) {
- const auto input_rank = input_shape.rank().get_length();
-
- PartialShape padded_input_shape = input_shape;
-
- auto pads_begin = attrs.pads_begin;
- auto pads_end = attrs.pads_end;
- pads_begin.resize(input_rank);
- pads_end.resize(input_rank);
- for (int64_t i = 0; i < input_rank; ++i) {
- if (input_shape[i].is_static()) {
- auto new_length = pads_begin[i] + pads_end[i] + input_shape[i].get_length();
- padded_input_shape[i] = Dimension(new_length);
- }
- }
-
- return padded_input_shape;
-}
+void pad_input_data(const uint8_t* data_ptr,
+ uint8_t* padded_data_ptr,
+ size_t type_size,
+ const ov::Shape& input_shape,
+ const ov::Shape& padded_input_shape,
+ const std::vector<size_t>& pads_begin);
-inline std::vector<float> get_scales(const PartialShape& input_data_partial_shape,
- const Shape& out_shape,
- const op::v0::Interpolate::Attributes& attrs) {
- std::vector<float> scales(attrs.axes.size(), 1.0f);
- auto input_shape = input_data_partial_shape.to_shape();
- size_t i = 0;
- for (size_t axis : attrs.axes) {
- scales[i] = static_cast<float>(out_shape.at(axis)) / input_shape.at(axis);
- i++;
- }
+PartialShape get_padded_input_shape(const PartialShape& input_shape, const op::v0::Interpolate::Attributes& attrs);
- return scales;
-}
-
-inline op::v4::Interpolate::InterpolateAttrs transform_v0_to_v4(const PartialShape& input_partial_shape,
- const op::v0::Interpolate::Attributes& attrs_v0) {
- auto input_shape_rank = input_partial_shape.rank().get_length();
-
- op::v4::Interpolate::InterpolateAttrs attrs_v4;
- if (attrs_v0.mode == "nearest") {
- attrs_v4.mode = InterpolateMode::NEAREST;
- } else if (attrs_v0.mode == "linear") {
- if (input_shape_rank < 5) {
- attrs_v4.mode = InterpolateMode::LINEAR_ONNX;
- } else if (input_shape_rank == 5) {
- attrs_v4.mode = InterpolateMode::LINEAR;
- } else {
- OPENVINO_ASSERT(false, "Failed to process ", attrs_v0.mode);
- }
- } else if (attrs_v0.mode == "cubic") {
- attrs_v4.mode = InterpolateMode::CUBIC;
- } else if (attrs_v0.mode == "linear_onnx") {
- attrs_v4.mode = InterpolateMode::LINEAR_ONNX;
- } else {
- OPENVINO_ASSERT(false, "Failed to process ", attrs_v0.mode);
- }
-
- attrs_v4.shape_calculation_mode = op::v4::Interpolate::ShapeCalcMode::SIZES;
- attrs_v4.nearest_mode = Nearest_mode::SIMPLE;
- attrs_v4.pads_begin = attrs_v0.pads_begin;
- attrs_v4.pads_end = attrs_v0.pads_end;
- attrs_v4.antialias = attrs_v0.antialias;
- attrs_v4.coordinate_transformation_mode = Transform_mode::ASYMMETRIC;
- attrs_v4.cube_coeff = -0.75f;
-
- if (attrs_v0.align_corners) {
- attrs_v4.coordinate_transformation_mode = Transform_mode::ALIGN_CORNERS;
- } else if ((attrs_v4.mode == InterpolateMode::LINEAR_ONNX || attrs_v4.mode == InterpolateMode::LINEAR) &&
- std::all_of(attrs_v4.pads_begin.begin(),
- attrs_v4.pads_begin.end(),
- [](size_t i) {
- return i == 0;
- }) &&
- std::all_of(attrs_v4.pads_end.begin(),
- attrs_v4.pads_end.end(),
- [](size_t i) {
- return i == 0;
- }) &&
- !(input_shape_rank - 2 == 2 && attrs_v0.axes == AxisSet{2, 3})) {
- attrs_v4.coordinate_transformation_mode = Transform_mode::HALF_PIXEL;
- }
-
- return attrs_v4;
-}
+std::vector<float> get_scales(const PartialShape& input_data_partial_shape,
+ const Shape& out_shape,
+ const op::v0::Interpolate::Attributes& attrs);
+op::v4::Interpolate::InterpolateAttrs transform_v0_to_v4(const PartialShape& input_partial_shape,
+ const op::v0::Interpolate::Attributes& attrs_v0);
template <typename T>
void interpolate(const T* input_data,
diff --git a/src/core/reference/src/op/interpolate.cpp b/src/core/reference/src/op/interpolate.cpp
index 40a8d17815e..11d6d1b7387 100644
--- a/src/core/reference/src/op/interpolate.cpp
+++ b/src/core/reference/src/op/interpolate.cpp
@@ -9,6 +9,67 @@
namespace ov {
namespace reference {
+std::function<int64_t(float, bool)> get_func(Nearest_mode mode) {
+ switch (mode) {
+ case Nearest_mode::ROUND_PREFER_CEIL:
+ return [](float x_original, bool) {
+ return static_cast<int64_t>(std::round(x_original));
+ };
+ case Nearest_mode::FLOOR:
+ return [](float x_original, bool) {
+ return static_cast<int64_t>(std::floor(x_original));
+ };
+ case Nearest_mode::CEIL:
+ return [](float x_original, bool) {
+ return static_cast<int64_t>(std::ceil(x_original));
+ };
+ case Nearest_mode::SIMPLE:
+ return [](float x_original, bool is_downsample) {
+ if (is_downsample) {
+ return static_cast<int64_t>(std::ceil(x_original));
+ } else {
+ return static_cast<int64_t>(x_original);
+ }
+ };
+ default:
+ return [](float x_original, bool) {
+ if (x_original == static_cast<int64_t>(x_original) + 0.5f) {
+ return static_cast<int64_t>(std::floor(x_original));
+ }
+ return static_cast<int64_t>(std::round(x_original));
+ };
+ }
+}
+
+std::function<float(float, float, float, float)> get_func(Transform_mode mode) {
+ switch (mode) {
+ case Transform_mode::PYTORCH_HALF_PIXEL:
+ return [](float x_resized, float x_scale, float length_resized, float) {
+ return length_resized > 1 ? (x_resized + 0.5f) / x_scale - 0.5f : 0.0f;
+ };
+ break;
+ case Transform_mode::ASYMMETRIC:
+ return [](float x_resized, float x_scale, float, float) {
+ return x_resized / x_scale;
+ };
+ break;
+ case Transform_mode::TF_HALF_PIXEL_FOR_NN:
+ return [](float x_resized, float x_scale, float, float) {
+ return (x_resized + 0.5f) / x_scale;
+ };
+ break;
+ case Transform_mode::ALIGN_CORNERS:
+ return [](float x_resized, float, float length_resized, float length_original) {
+ return length_resized == 1 ? 0 : x_resized * (length_original - 1) / (length_resized - 1);
+ };
+ break;
+ default:
+ return [](float x_resized, float x_scale, float, float) {
+ return ((x_resized + 0.5f) / x_scale) - 0.5f;
+ };
+ }
+}
+
float InterpolateEvalHelper::triangle_coeff(float dz) {
return std::max(0.0f, 1.0f - std::fabs(dz));
}
@@ -222,5 +283,110 @@ InterpolateEvalHelper::LinearModeInnerIterationResult InterpolateEvalHelper::inn
return result;
}
+
+void pad_input_data(const uint8_t* data_ptr,
+ uint8_t* padded_data_ptr,
+ size_t type_size,
+ const ov::Shape& input_shape,
+ const ov::Shape& padded_input_shape,
+ const std::vector<size_t>& pads_begin) {
+ const CoordinateTransformBasic input_transform{input_shape};
+
+ for (const Coordinate& input_coord : input_transform) {
+ auto padded_coord = input_coord;
+ size_t i = 0;
+ for (size_t pad : pads_begin) {
+ padded_coord[i] += pad;
+ ++i;
+ }
+ uint8_t* dst_ptr = padded_data_ptr + type_size * coordinate_index(padded_coord, padded_input_shape);
+ const uint8_t* src_ptr = data_ptr + type_size * coordinate_index(input_coord, input_shape);
+ memcpy(dst_ptr, src_ptr, type_size);
+ }
+}
+
+PartialShape get_padded_input_shape(const PartialShape& input_shape, const op::v0::Interpolate::Attributes& attrs) {
+ const auto input_rank = input_shape.rank().get_length();
+
+ PartialShape padded_input_shape = input_shape;
+
+ auto pads_begin = attrs.pads_begin;
+ auto pads_end = attrs.pads_end;
+ pads_begin.resize(input_rank);
+ pads_end.resize(input_rank);
+ for (int64_t i = 0; i < input_rank; ++i) {
+ if (input_shape[i].is_static()) {
+ auto new_length = pads_begin[i] + pads_end[i] + input_shape[i].get_length();
+ padded_input_shape[i] = Dimension(new_length);
+ }
+ }
+
+ return padded_input_shape;
+}
+
+std::vector<float> get_scales(const PartialShape& input_data_partial_shape,
+ const Shape& out_shape,
+ const op::v0::Interpolate::Attributes& attrs) {
+ std::vector<float> scales(attrs.axes.size(), 1.0f);
+ auto input_shape = input_data_partial_shape.to_shape();
+ size_t i = 0;
+ for (size_t axis : attrs.axes) {
+ scales[i] = static_cast<float>(out_shape.at(axis)) / input_shape.at(axis);
+ i++;
+ }
+
+ return scales;
+}
+
+op::v4::Interpolate::InterpolateAttrs transform_v0_to_v4(const PartialShape& input_partial_shape,
+ const op::v0::Interpolate::Attributes& attrs_v0) {
+ auto input_shape_rank = input_partial_shape.rank().get_length();
+
+ op::v4::Interpolate::InterpolateAttrs attrs_v4;
+ if (attrs_v0.mode == "nearest") {
+ attrs_v4.mode = InterpolateMode::NEAREST;
+ } else if (attrs_v0.mode == "linear") {
+ if (input_shape_rank < 5) {
+ attrs_v4.mode = InterpolateMode::LINEAR_ONNX;
+ } else if (input_shape_rank == 5) {
+ attrs_v4.mode = InterpolateMode::LINEAR;
+ } else {
+ OPENVINO_ASSERT(false, "Failed to process ", attrs_v0.mode);
+ }
+ } else if (attrs_v0.mode == "cubic") {
+ attrs_v4.mode = InterpolateMode::CUBIC;
+ } else if (attrs_v0.mode == "linear_onnx") {
+ attrs_v4.mode = InterpolateMode::LINEAR_ONNX;
+ } else {
+ OPENVINO_ASSERT(false, "Failed to process ", attrs_v0.mode);
+ }
+
+ attrs_v4.shape_calculation_mode = op::v4::Interpolate::ShapeCalcMode::SIZES;
+ attrs_v4.nearest_mode = Nearest_mode::SIMPLE;
+ attrs_v4.pads_begin = attrs_v0.pads_begin;
+ attrs_v4.pads_end = attrs_v0.pads_end;
+ attrs_v4.antialias = attrs_v0.antialias;
+ attrs_v4.coordinate_transformation_mode = Transform_mode::ASYMMETRIC;
+ attrs_v4.cube_coeff = -0.75f;
+
+ if (attrs_v0.align_corners) {
+ attrs_v4.coordinate_transformation_mode = Transform_mode::ALIGN_CORNERS;
+ } else if ((attrs_v4.mode == InterpolateMode::LINEAR_ONNX || attrs_v4.mode == InterpolateMode::LINEAR) &&
+ std::all_of(attrs_v4.pads_begin.begin(),
+ attrs_v4.pads_begin.end(),
+ [](size_t i) {
+ return i == 0;
+ }) &&
+ std::all_of(attrs_v4.pads_end.begin(),
+ attrs_v4.pads_end.end(),
+ [](size_t i) {
+ return i == 0;
+ }) &&
+ !(input_shape_rank - 2 == 2 && attrs_v0.axes == AxisSet{2, 3})) {
+ attrs_v4.coordinate_transformation_mode = Transform_mode::HALF_PIXEL;
+ }
+
+ return attrs_v4;
+}
} // namespace reference
} // namespace ov
diff --git a/src/core/src/op/interpolate.cpp b/src/core/src/op/interpolate.cpp
index 472889fc866..0abea4d138c 100644
--- a/src/core/src/op/interpolate.cpp
+++ b/src/core/src/op/interpolate.cpp
@@ -144,19 +144,40 @@ std::shared_ptr<ov::Node> ov::op::v4::Interpolate::clone_with_new_inputs(const O
namespace {
static constexpr size_t data_port = 0;
static constexpr size_t target_shape_port = 1;
-static constexpr size_t scales_port = 2;
-static constexpr size_t axes_port = 3;
-static constexpr size_t max_num_of_ports = 4;
+size_t get_scales_port(const ov::op::util::InterpolateBase* node) {
+ constexpr size_t scales_port = 2;
+ if (ov::is_type<ov::op::v11::Interpolate>(node)) {
+ return scales_port - 1;
+ }
+ return scales_port;
+}
+
+size_t get_axes_port(const ov::op::util::InterpolateBase* node) {
+ constexpr size_t axes_port = 3;
+ if (ov::is_type<ov::op::v11::Interpolate>(node)) {
+ return axes_port - 1;
+ }
+ return axes_port;
+}
+
+size_t get_max_num_of_ports(const ov::op::util::InterpolateBase* node) {
+ constexpr size_t max_num_of_ports = 4;
+ if (ov::is_type<ov::op::v11::Interpolate>(node)) {
+ return max_num_of_ports - 1;
+ }
+ return max_num_of_ports;
+}
-std::vector<float> get_scales_vector(const ov::TensorVector& args,
+std::vector<float> get_scales_vector(const ov::op::util::InterpolateBase* node,
+ const ov::TensorVector& args,
const ov::Shape& input_shape,
- const ov::op::v4::Interpolate::InterpolateAttrs& attrs,
- std::vector<int64_t> axes) {
+ const ov::op::util::InterpolateBase::InterpolateAttrs& attrs,
+ const std::vector<int64_t>& axes) {
using scales_t = float;
constexpr auto f32_cast = ov::util::Cast<scales_t>();
if (attrs.shape_calculation_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) {
- return ov::get_tensor_data_as<scales_t>(args[scales_port], f32_cast);
+ return ov::get_tensor_data_as<scales_t>(args[get_scales_port(node)], f32_cast);
} else {
auto scales = ov::get_tensor_data_as<scales_t>(args[target_shape_port], f32_cast);
auto scales_iter = scales.begin();
@@ -167,48 +188,44 @@ std::vector<float> get_scales_vector(const ov::TensorVector& args,
return scales;
}
}
-} // namespace
-
-bool ov::op::v4::Interpolate::evaluate_interpolate(TensorVector& outputs, const TensorVector& inputs) const {
- auto input_shapes = std::vector<PartialShape>();
- const auto inputs_num = inputs.size();
-
- input_shapes.reserve(inputs_num);
- for (const auto& in : inputs) {
- input_shapes.push_back(in.get_shape());
- }
- auto pads_begin = m_attrs.pads_begin;
- auto pads_end = m_attrs.pads_end;
-
- const auto ta = make_tensor_accessor(inputs);
- const auto out_shape = shape_infer(this, input_shapes, pads_begin, pads_end, ta).front().to_shape();
+bool evaluate_interpolate(const ov::op::util::InterpolateBase* node,
+ const std::vector<ov::PartialShape>& input_shapes,
+ const ov::Shape& out_shape,
+ std::vector<size_t>& pads_begin,
+ std::vector<size_t>& pads_end,
+ const ov::ITensorAccessor& ta,
+ ov::TensorVector& outputs,
+ const ov::TensorVector& inputs) {
outputs[0].set_shape(out_shape);
-
auto padded_input_shape =
- interpolate::make_padded_shape(input_shapes.front(), pads_begin.begin(), pads_end.begin()).to_shape();
-
- const auto has_axes_input = (inputs_num == max_num_of_ports);
- const auto axes = interpolate::get_axes<PartialShape>(this, axes_port, has_axes_input, out_shape.size(), ta);
- const auto scales = get_scales_vector(inputs, padded_input_shape, m_attrs, *axes);
+ ov::op::interpolate::make_padded_shape(input_shapes.front(), pads_begin.begin(), pads_end.begin()).to_shape();
+ const auto has_axes_input = (input_shapes.size() == get_max_num_of_ports(node));
+ const auto axes = ov::op::interpolate::get_axes<ov::PartialShape>(node,
+ get_axes_port(node),
+ has_axes_input,
+ out_shape.size(),
+ ta);
+ const auto& m_attrs = node->get_attrs();
+ const auto scales = get_scales_vector(node, inputs, padded_input_shape, m_attrs, *axes);
const auto input_et = inputs[0].get_element_type();
const auto type_size = input_et.size();
- const auto bytes_in_padded_input = shape_size(padded_input_shape) * type_size;
+ const auto bytes_in_padded_input = ov::shape_size(padded_input_shape) * type_size;
auto padded_input_data = std::vector<uint8_t>(bytes_in_padded_input, 0);
auto* data_ptr = static_cast<const uint8_t*>(inputs[data_port].data());
auto* padded_data_ptr = padded_input_data.data();
- reference::pad_input_data(data_ptr,
- padded_data_ptr,
- type_size,
- inputs[data_port].get_shape(),
- padded_input_shape,
- pads_begin);
-
+ ov::reference::pad_input_data(data_ptr,
+ padded_data_ptr,
+ type_size,
+ inputs[data_port].get_shape(),
+ padded_input_shape,
+ pads_begin);
+ using ov::element::Type_t;
switch (input_et) {
- case element::Type_t::f32:
+ case Type_t::f32:
ov::reference::interpolate<float>(reinterpret_cast<float*>(padded_data_ptr),
padded_input_shape,
scales,
@@ -217,10 +234,10 @@ bool ov::op::v4::Interpolate::evaluate_interpolate(TensorVector& outputs, const
out_shape,
m_attrs);
break;
- case element::Type_t::f16:
- case element::Type_t::bf16:
- return ov::util::evaluate_node_with_unsupported_precision(this, outputs, inputs);
- case element::Type_t::i8:
+ case Type_t::f16:
+ case Type_t::bf16:
+ return ov::util::evaluate_node_with_unsupported_precision(node, outputs, inputs);
+ case Type_t::i8:
ov::reference::interpolate<int8_t>(reinterpret_cast<int8_t*>(padded_data_ptr),
padded_input_shape,
scales,
@@ -229,7 +246,7 @@ bool ov::op::v4::Interpolate::evaluate_interpolate(TensorVector& outputs, const
out_shape,
m_attrs);
break;
- case element::Type_t::u8:
+ case Type_t::u8:
ov::reference::interpolate<uint8_t>(reinterpret_cast<uint8_t*>(padded_data_ptr),
padded_input_shape,
scales,
@@ -238,15 +255,22 @@ bool ov::op::v4::Interpolate::evaluate_interpolate(TensorVector& outputs, const
out_shape,
m_attrs);
break;
- default:;
+ default:
+ return false;
}
return true;
}
+} // namespace
bool ov::op::v4::Interpolate::evaluate(TensorVector& outputs, const TensorVector& inputs) const {
OV_OP_SCOPE(v4_Interpolate_evaluate);
- return evaluate_interpolate(outputs, inputs);
+ auto pads_begin = m_attrs.pads_begin;
+ auto pads_end = m_attrs.pads_end;
+ const auto input_shapes = ov::util::get_tensors_partial_shapes(inputs);
+ const auto ta = make_tensor_accessor(inputs);
+ const auto out_shape = shape_infer(this, input_shapes, pads_begin, pads_end, ta).front().to_shape();
+ return evaluate_interpolate(this, input_shapes, out_shape, pads_begin, pads_end, ta, outputs, inputs);
}
bool ov::op::v4::Interpolate::has_evaluate() const {
@@ -259,9 +283,8 @@ bool ov::op::v4::Interpolate::has_evaluate() const {
case ov::element::f32:
return true;
default:
- break;
+ return false;
}
- return false;
}
namespace ov {
@@ -313,4 +336,30 @@ void op::v11::Interpolate::validate_and_infer_types() {
}
AttributeAdapter<op::v0::Interpolate::InterpolateMode>::~AttributeAdapter() = default;
+
+bool ov::op::v11::Interpolate::evaluate(TensorVector& outputs, const TensorVector& inputs) const {
+ OV_OP_SCOPE(v11_Interpolate_evaluate);
+
+ auto pads_begin = m_attrs.pads_begin;
+ auto pads_end = m_attrs.pads_end;
+ const auto ta = make_tensor_accessor(inputs);
+ const auto input_shapes = ov::util::get_tensors_partial_shapes(inputs);
+ const auto out_shape = shape_infer(this, input_shapes, pads_begin, pads_end, ta).front().to_shape();
+ return evaluate_interpolate(this, input_shapes, out_shape, pads_begin, pads_end, ta, outputs, inputs);
+}
+
+bool ov::op::v11::Interpolate::has_evaluate() const {
+ OV_OP_SCOPE(v11_Interpolate_has_evaluate);
+ switch (get_input_element_type(0)) {
+ case ov::element::i8:
+ case ov::element::u8:
+ case ov::element::bf16:
+ case ov::element::f16:
+ case ov::element::f32:
+ return true;
+ default:
+ return false;
+ }
+}
+
} // namespace ov
diff --git a/src/plugins/template/tests/functional/op_reference/interpolate.cpp b/src/plugins/template/tests/functional/op_reference/interpolate.cpp
index 46a3836da8a..f7fb333c154 100644
--- a/src/plugins/template/tests/functional/op_reference/interpolate.cpp
+++ b/src/plugins/template/tests/functional/op_reference/interpolate.cpp
@@ -1235,8 +1235,9 @@ std::vector<InterpolateV11TestParams> generateParamsForInterpolate_bicubic_pil_i
}};
}
-template <typename Data_t = float>
+template <element::Type_t ET>
std::vector<InterpolateV11TestParams> generateParamsForInterpolate_bilinear_pil_float() {
+ using Data_t = typename element_type_traits<ET>::value_type;
return {
{
"bilinear.downsample_2D_sizes",
@@ -1308,61 +1309,8 @@ std::vector<InterpolateV11TestParams> generateParamsForInterpolate_bilinear_pil_
}
template <element::Type_t ET>
-std::vector<InterpolateV11TestParams> generateParamsForInterpolate_bilinear_pil_f16() {
- using Data_t = typename element_type_traits<ET>::value_type;
- return {
- {
- "bilinear.downsample_2D_sizes",
- Shape{5, 6},
- {2, 4},
- Shape{2, 4},
- {},
- {0, 1},
- {InterpolateMode::BILINEAR_PILLOW, ShapeCalcMode::SIZES, {0, 0}, {0, 0}},
- std::vector<Data_t>{121, 131, 193, 243, 8.875, 37, 210, 242, 63.75, 80, 222, 108, 70, 212, 66,
- 105, 164, 140, 22, 7.0625, 222, 192, 214, 138, 209, 84, 116, 202, 31.75, 77.5},
- std::vector<Data_t>{159, 141, 138, 111, 96, 128, 158, 128},
- },
- {
- "bilinear.downsample_2D_scales",
- Shape{5, 6},
- {},
- Shape{2, 4},
- {0.4f, 0.7f},
- {0, 1},
- {InterpolateMode::BILINEAR_PILLOW, ShapeCalcMode::SCALES, {0, 0}, {0, 0}},
- std::vector<Data_t>{121, 131, 193, 243, 8.875, 37, 210, 242, 63.75, 80, 222, 108, 70, 212, 66,
- 105, 164, 140, 22, 7.0625, 222, 192, 214, 138, 209, 84, 116, 202, 31.75, 77.5},
- std::vector<Data_t>{159, 141, 138, 111, 96, 128, 158, 128},
- },
- {
- "bilinear.upsample_2D_sizes",
- Shape{2, 4},
- {5, 6},
- Shape{5, 6},
- {},
- {0, 1},
- {InterpolateMode::BILINEAR_PILLOW, ShapeCalcMode::SIZES, {0, 0}, {0, 0}},
- std::vector<Data_t>{214, 67, 28, 76, 106, 208, 115.5, 23.5},
- std::vector<Data_t>{214, 140, 60.5, 34.5, 52, 76, 202, 142, 74, 44, 53.5, 70, 160, 148, 126,
- 82, 60.75, 49.75, 116, 155, 178, 120, 67.5, 28.75, 106, 157, 192, 130, 69.5, 23.5},
- },
- {
- "bilinear.upsample_2D_scales",
- Shape{2, 4},
- {},
- Shape{5, 6},
- {2.5f, 1.5f},
- {0, 1},
- {InterpolateMode::BILINEAR_PILLOW, ShapeCalcMode::SCALES, {0, 0}, {0, 0}},
- std::vector<Data_t>{214, 67, 28, 76, 106, 208, 115.5, 23.5},
- std::vector<Data_t>{214, 140, 60.5, 34.5, 52, 76, 202, 142, 74, 44, 53.5, 70, 160, 148, 126,
- 82, 60.75, 49.75, 116, 155, 178, 120, 67.5, 28.75, 106, 157, 192, 130, 69.5, 23.5},
- }};
-}
-
-template <typename Data_t = float>
std::vector<InterpolateV11TestParams> generateParamsForInterpolate_bicubic_pil_float() {
+ using Data_t = typename element_type_traits<ET>::value_type;
return {
{
"bicubic.downsample_2D_sizes",
@@ -1589,12 +1537,12 @@ std::vector<InterpolateV11TestParams> generateParamsForInterpolate_bicubic_pil_f
std::vector<InterpolateV11TestParams> generateCombinedParamsForInterpolate_v11() {
const std::vector<std::vector<InterpolateV11TestParams>> allTypeParamsV11{
- generateParamsForInterpolate_bilinear_pil_float<float>(),
- generateParamsForInterpolate_bicubic_pil_float<float>(),
- generateParamsForInterpolate_bilinear_pil_f16<element::Type_t::bf16>(),
- generateParamsForInterpolate_bilinear_pil_f16<element::Type_t::f16>(),
- generateParamsForInterpolate_bicubic_pil_f16<element::Type_t::bf16>(),
- generateParamsForInterpolate_bicubic_pil_f16<element::Type_t::f16>(),
+ generateParamsForInterpolate_bilinear_pil_float<element::Type_t::f32>(),
+ generateParamsForInterpolate_bicubic_pil_float<element::Type_t::f32>(),
+ generateParamsForInterpolate_bilinear_pil_float<element::Type_t::bf16>(),
+ generateParamsForInterpolate_bicubic_pil_float<element::Type_t::bf16>(),
+ generateParamsForInterpolate_bilinear_pil_float<element::Type_t::f16>(),
+ generateParamsForInterpolate_bicubic_pil_float<element::Type_t::f16>(),
generateParamsForInterpolate_bilinear_pil_int_common<uint8_t>(),
generateParamsForInterpolate_bilinear_pil_int_common<int32_t>(),
generateParamsForInterpolate_bilinear_pil_int8<int8_t>(),
diff --git a/src/plugins/template/tests/functional/skip_tests_config.cpp b/src/plugins/template/tests/functional/skip_tests_config.cpp
index 95cb3ac0611..c00fbce1297 100644
--- a/src/plugins/template/tests/functional/skip_tests_config.cpp
+++ b/src/plugins/template/tests/functional/skip_tests_config.cpp
@@ -90,8 +90,6 @@ std::vector<std::string> disabledTestPatterns() {
// Why query state should throw an exception
R"(.*InferRequestQueryStateExceptionTest.*inferreq_smoke_QueryState_ExceptionTest.*)",
R"(.*OVInferRequestCheckTensorPrecision.*get(Input|Output|Inputs|Outputs)From.*FunctionWith(Single|Several).*type=(u4|u1|i4|boolean).*)",
- // CVS-110345
- R"(.*ReferenceInterpolate_v11.*data_type=f16.*)",
R"(.*LSTMSequence_With_Hardcoded_Refs.*ReferenceLSTMSequenceTest.*iType=f16.*)",
// CVS-111443
R"(.*eltwiseOpType=Mod_secondaryInputType=PARAMETER_opType=VECTOR_NetType=(f16|f32).*)",