Fix segmentation fault caused by invalid tensor type (#4467)

* Fix segmentation fault caused by invalid tensor type

* Addressed review comment
This commit is contained in:
Prabhat 2020-07-10 11:23:12 +01:00 committed by GitHub
parent ccbf49e59f
commit 04586fc09d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -842,6 +842,10 @@ Graph::Graph(const Model& owning_model,
NodeArg* matching_graph_input = GetNodeArg(tensor.name());
TypeProto t{TypeProtoFromTensorProto(tensor)};
if (!utils::HasElemType(t.tensor_type())) {
ORT_THROW("This is an invalid model. Tensor does not have type information.");
}
if (ir_version_ < 4) {
// initializers can have matching graph inputs but are treated as constant,
// so we prefer the shape from the initializer