static_typename (#4520)

* Use static_typename

* Disable RTTI outside of Release

* Fix unused var

* Add test types

* PR feedback
This commit is contained in:
Tiago Koji Castro Shibata 2020-07-16 16:31:02 -07:00 committed by GitHub
parent b43ce2d7ad
commit 2189c77e5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -432,8 +432,12 @@ struct SetMapTypes {
TensorElementTypeSetter<K>::SetMapKeyType(proto);
MLDataType dt = GetMLDataType<V, IsTensorContainedType<V>::value>::Get();
const auto* value_proto = dt->GetTypeProto();
#ifdef ORT_NO_RTTI
ORT_ENFORCE(value_proto != nullptr, "expected a registered ONNX type");
#else
ORT_ENFORCE(value_proto != nullptr, typeid(V).name(),
" expected to be a registered ONNX type");
#endif
CopyMutableMapValue(*value_proto, proto);
}
};
@ -449,8 +453,12 @@ struct SetSequenceType {
static void Set(ONNX_NAMESPACE::TypeProto& proto) {
MLDataType dt = GetMLDataType<T, IsTensorContainedType<T>::value>::Get();
const auto* elem_proto = dt->GetTypeProto();
#ifdef ORT_NO_RTTI
ORT_ENFORCE(elem_proto != nullptr, "expected a registered ONNX type");
#else
ORT_ENFORCE(elem_proto != nullptr, typeid(T).name(),
" expected to be a registered ONNX type");
#endif
CopyMutableSeqElement(*elem_proto, proto);
}
};

View file

@ -157,7 +157,11 @@ inline void CastFromStringData(const Tensor* in, Tensor* out, const TensorShape&
mutable_data[i] = std::stoull(in->Data<std::string>()[i]);
}
} else {
#ifdef ORT_NO_RTTI
ORT_THROW("Unsupported type in cast op");
#else
ORT_THROW("Unsupported type in cast op: from String to ", typeid(DstType).name());
#endif
}
} // namespace onnxruntime