Add constructor to allow implict convertion at compile-time but not at run-time (#8525)

Signed-off-by: Li, Tingqian <tingqian.li@intel.com>
This commit is contained in:
Tingqian Li 2021-11-13 19:05:09 +08:00 committed by GitHub
parent 8abf1eca7a
commit 57900a4a18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -9,6 +9,9 @@
#include <stdexcept>
#include <ostream>
#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);

View File

@ -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<StaticDimension::value_type>& dimensions);
StaticShape(std::vector<StaticDimension> 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; }