diff --git a/include/onnxruntime/core/framework/data_types.h b/include/onnxruntime/core/framework/data_types.h index fab910f23b..d89bdc555f 100644 --- a/include/onnxruntime/core/framework/data_types.h +++ b/include/onnxruntime/core/framework/data_types.h @@ -432,8 +432,12 @@ struct SetMapTypes { TensorElementTypeSetter::SetMapKeyType(proto); MLDataType dt = GetMLDataType::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::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); } }; diff --git a/onnxruntime/core/providers/cpu/tensor/cast_op.cc b/onnxruntime/core/providers/cpu/tensor/cast_op.cc index 7d74e1db25..8400cfe339 100644 --- a/onnxruntime/core/providers/cpu/tensor/cast_op.cc +++ b/onnxruntime/core/providers/cpu/tensor/cast_op.cc @@ -157,7 +157,11 @@ inline void CastFromStringData(const Tensor* in, Tensor* out, const TensorShape& mutable_data[i] = std::stoull(in->Data()[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