From 57900a4a18585c33996f5b3b1a10e001b075922b Mon Sep 17 00:00:00 2001 From: Tingqian Li Date: Sat, 13 Nov 2021 19:05:09 +0800 Subject: [PATCH] Add constructor to allow implict convertion at compile-time but not at run-time (#8525) Signed-off-by: Li, Tingqian --- .../utils/shape_inference/static_dimension.hpp | 13 +++++++++++++ .../utils/shape_inference/static_shape.hpp | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/inference-engine/src/mkldnn_plugin/utils/shape_inference/static_dimension.hpp b/inference-engine/src/mkldnn_plugin/utils/shape_inference/static_dimension.hpp index 03aee9d63f9..20efc49cdc7 100644 --- a/inference-engine/src/mkldnn_plugin/utils/shape_inference/static_dimension.hpp +++ b/inference-engine/src/mkldnn_plugin/utils/shape_inference/static_dimension.hpp @@ -9,6 +9,9 @@ #include #include +#include "openvino/core/dimension.hpp" +#include "openvino/core/except.hpp" + namespace ov { /// \brief Class representing a dimension, which must be static, /// in a shape or shape-like object. @@ -25,6 +28,10 @@ public: /// \brief Construct a zero dimension StaticDimension() = default; + StaticDimension(const Dimension &) { + OPENVINO_UNREACHABLE("[shape infer] Shoudn't convert from Dimension to StaticDimension."); + } + bool operator==(const StaticDimension& dimension) const; bool operator!=(const StaticDimension& dimension) const; @@ -35,6 +42,12 @@ public: value_type get_min_length() const; value_type get_max_length() const; + Interval& get_interval() const { + static Interval dummy{}; + OPENVINO_UNREACHABLE("[shape infer] Shoudn't call get_interval() in StaticDimension."); + return dummy; + } + bool same_scheme(const StaticDimension& dim) const; bool compatible(const StaticDimension& d) const; static bool merge(StaticDimension& dst, const StaticDimension& d1, const StaticDimension& d2); diff --git a/inference-engine/src/mkldnn_plugin/utils/shape_inference/static_shape.hpp b/inference-engine/src/mkldnn_plugin/utils/shape_inference/static_shape.hpp index f0dd557f7f3..1afa6f2b02d 100644 --- a/inference-engine/src/mkldnn_plugin/utils/shape_inference/static_shape.hpp +++ b/inference-engine/src/mkldnn_plugin/utils/shape_inference/static_shape.hpp @@ -12,6 +12,7 @@ #include "openvino/core/rank.hpp" #include "openvino/core/shape.hpp" #include "openvino/core/partial_shape.hpp" +#include "openvino/core/except.hpp" namespace ov { namespace op { @@ -26,6 +27,10 @@ public: StaticShape(const std::vector& dimensions); StaticShape(std::vector dimensions); + StaticShape(const PartialShape &) { + OPENVINO_UNREACHABLE("[shape infer] Shouldn't convert from PartialShape to StaticShape at runtime."); + } + static bool is_static() { return true; } static bool is_dynamic() { return false; }