Fix for android type info comparison (#10142)
* Any value can fromm inner string * Fixed review coment * strict str to value conversion * fix format * [VPU] update config header (#9857) * [VPU] update config header * Review fixes * Performance hint config update * Removal deprecated vpu config stuff * Review changes * Rename myriad properties from camelCase to snake_case * Review changes * Review fixes * Removal intel_myriad::common namespace * OV throughput stream option * Test fix * Reverted disable_convert & disable_reorder * Bugfixes * Change default value for PerformanceHintNumRequestsOption * fixed excessive outputs copying (in case when the fallback happened) and updated the test for that (#10110) * fixed excessive outputs copying (in case when the fallback happened) and updated the test for that * enum eExecutionFlavor to cover initial state * Transformations: eltwise and FQ fusings fixes (#10078) * FQ fusings fixes * FQ Fusings: added negative test-cases for non-broadcasted constant * Disable single-image-super-resolution-1032 from MemCheck precommit (#10133) * add performance hint to time infer * disable model from memcheck * Fixed input cut for case when port is not specified. (#10134) * Fix for android type info comparison Co-authored-by: Aleksandr Korolev <aleksandr.korolev@intel.com> Co-authored-by: Maxim Shevtsov <maxim.y.shevtsov@intel.com> Co-authored-by: Vladislav Golubev <vladislav.golubev@intel.com> Co-authored-by: Victor Kuznetsov <victor.kuznetsov@intel.com> Co-authored-by: Anastasia Popova <anastasia.popova@intel.com>
This commit is contained in:
2 files changed
+39
-21
No files matched your search
@@ -203,6 +203,8 @@ class OPENVINO_API Any {
|
||||
throw ov::Exception{"Could read type without std::istream& operator>>(std::istream&, T) defined"};
|
||||
}
|
||||
|
||||
static bool equal(std::type_index lhs, std::type_index rhs);
|
||||
|
||||
/**
|
||||
* @brief Base API of erased type
|
||||
*/
|
||||
@@ -232,9 +234,11 @@ class OPENVINO_API Any {
|
||||
bool visit_attributes(AttributeVisitor&) const;
|
||||
std::string to_string() const;
|
||||
|
||||
bool is(const std::type_info& other) const;
|
||||
|
||||
template <class T>
|
||||
bool is() const {
|
||||
return typeid(decay_t<T>) == type_info();
|
||||
return is(typeid(decay_t<T>));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -474,11 +478,11 @@ public:
|
||||
template <class T>
|
||||
bool is() const {
|
||||
if (_impl != nullptr) {
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return true;
|
||||
}
|
||||
for (const auto& type_index : _impl->base_type_info()) {
|
||||
if (type_index == typeid(decay_t<T>)) {
|
||||
if (equal(type_index, typeid(decay_t<T>))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -497,7 +501,7 @@ public:
|
||||
_temp_impl = std::make_shared<Impl<decay_t<T>>>(T{});
|
||||
return _temp_impl->as<T>();
|
||||
} else {
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return std::move(*static_cast<decay_t<T>*>(_impl->addressof()));
|
||||
} else {
|
||||
auto runtime_attribute = _impl->as_runtime_attribute();
|
||||
@@ -532,7 +536,7 @@ public:
|
||||
_temp_impl = std::make_shared<Impl<decay_t<T>>>(T{});
|
||||
return _temp_impl->as<T>();
|
||||
} else {
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return *static_cast<decay_t<T>*>(_impl->addressof());
|
||||
} else {
|
||||
auto runtime_attribute = _impl->as_runtime_attribute();
|
||||
@@ -568,7 +572,7 @@ public:
|
||||
_temp_impl = std::make_shared<Impl<decay_t<T>>>(T{});
|
||||
return _temp_impl->as<T>();
|
||||
} else {
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return *static_cast<const decay_t<T>*>(_impl->addressof());
|
||||
} else {
|
||||
auto runtime_attribute = _impl->as_runtime_attribute();
|
||||
@@ -603,7 +607,7 @@ public:
|
||||
T>::type&&
|
||||
as() && {
|
||||
impl_check();
|
||||
if (_impl->type_info() == typeid(std::string)) {
|
||||
if (_impl->is(typeid(std::string))) {
|
||||
_temp_impl = std::make_shared<Impl<decay_t<T>>>();
|
||||
std::stringstream strm{as<std::string>()};
|
||||
_temp_impl->read(strm);
|
||||
@@ -624,16 +628,16 @@ public:
|
||||
T>::type&
|
||||
as() & {
|
||||
impl_check();
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return *static_cast<decay_t<T>*>(_impl->addressof());
|
||||
} else if (_impl->type_info() == typeid(std::string)) {
|
||||
} else if (_impl->is(typeid(std::string))) {
|
||||
_temp_impl = std::make_shared<Impl<decay_t<T>>>();
|
||||
std::stringstream strm{as<std::string>()};
|
||||
_temp_impl->read(strm);
|
||||
return *static_cast<decay_t<T>*>(_temp_impl->addressof());
|
||||
}
|
||||
for (const auto& type_index : _impl->base_type_info()) {
|
||||
if (type_index == typeid(decay_t<T>)) {
|
||||
if (equal(type_index, typeid(decay_t<T>))) {
|
||||
return *static_cast<decay_t<T>*>(_impl->addressof());
|
||||
}
|
||||
}
|
||||
@@ -651,16 +655,16 @@ public:
|
||||
T>::type&
|
||||
as() const& {
|
||||
impl_check();
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return *static_cast<const decay_t<T>*>(_impl->addressof());
|
||||
} else if (_impl->type_info() == typeid(std::string)) {
|
||||
} else if (_impl->is(typeid(std::string))) {
|
||||
_temp_impl = std::make_shared<Impl<decay_t<T>>>();
|
||||
std::stringstream strm{as<std::string>()};
|
||||
_temp_impl->read(strm);
|
||||
return *static_cast<const decay_t<T>*>(_temp_impl->addressof());
|
||||
}
|
||||
for (const auto& type_index : _impl->base_type_info()) {
|
||||
if (type_index == typeid(decay_t<T>)) {
|
||||
if (equal(type_index, typeid(decay_t<T>))) {
|
||||
return *static_cast<const decay_t<T>*>(_impl->addressof());
|
||||
}
|
||||
}
|
||||
@@ -693,11 +697,11 @@ public:
|
||||
T>::type&
|
||||
as() & {
|
||||
impl_check();
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return *static_cast<decay_t<T>*>(_impl->addressof());
|
||||
}
|
||||
for (const auto& type_index : _impl->base_type_info()) {
|
||||
if (type_index == typeid(decay_t<T>)) {
|
||||
if (equal(type_index, typeid(decay_t<T>))) {
|
||||
return *static_cast<decay_t<T>*>(_impl->addressof());
|
||||
}
|
||||
}
|
||||
@@ -715,11 +719,11 @@ public:
|
||||
T>::type&
|
||||
as() const& {
|
||||
impl_check();
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return *static_cast<const decay_t<T>*>(_impl->addressof());
|
||||
}
|
||||
for (const auto& type_index : _impl->base_type_info()) {
|
||||
if (type_index == typeid(decay_t<T>)) {
|
||||
if (equal(type_index, typeid(decay_t<T>))) {
|
||||
return *static_cast<const decay_t<T>*>(_impl->addressof());
|
||||
}
|
||||
}
|
||||
@@ -734,7 +738,7 @@ public:
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_same<T, std::string>::value, T>::type&& as() && {
|
||||
impl_check();
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return std::move(*static_cast<decay_t<T>*>(_impl->addressof()));
|
||||
} else {
|
||||
std::stringstream strm;
|
||||
@@ -752,7 +756,7 @@ public:
|
||||
template <class T>
|
||||
typename std::enable_if<std::is_same<T, std::string>::value, T>::type& as() & {
|
||||
impl_check();
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return *static_cast<decay_t<T>*>(_impl->addressof());
|
||||
} else {
|
||||
std::stringstream strm;
|
||||
@@ -770,7 +774,7 @@ public:
|
||||
template <class T>
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value, T>::type& as() const& {
|
||||
impl_check();
|
||||
if (_impl->type_info() == typeid(decay_t<T>)) {
|
||||
if (_impl->is(typeid(decay_t<T>))) {
|
||||
return *static_cast<const decay_t<T>*>(_impl->addressof());
|
||||
} else {
|
||||
std::stringstream strm;
|
||||
|
||||
+15
-1
@@ -8,8 +8,22 @@
|
||||
|
||||
namespace ov {
|
||||
|
||||
bool Any::equal(std::type_index lhs, std::type_index rhs) {
|
||||
auto result = lhs == rhs;
|
||||
#ifdef __ANDROID__
|
||||
if (!result) {
|
||||
result = std::strcmp(lhs.name(), rhs.name()) == 0;
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Any::Base::is(const std::type_info& other) const {
|
||||
return Any::equal(type_info(), other);
|
||||
}
|
||||
|
||||
void Any::Base::type_check(const std::type_info& type_info_) const {
|
||||
OPENVINO_ASSERT(type_info() == type_info_, "Bad cast from: ", type_info().name(), " To type: ", type_info_.name());
|
||||
OPENVINO_ASSERT(is(type_info_), "Bad cast from: ", type_info().name(), " To type: ", type_info_.name());
|
||||
}
|
||||
|
||||
std::shared_ptr<RuntimeAttribute> Any::Base::as_runtime_attribute() const {
|
||||
|
||||
Reference in new issue
Block a user