提交 2e0cc0a3 编写于 作者: M Mihai Maruseac

Prevent loading saved models where constant nodes have no tensor value.

Also reorder fuzz generated test cases following f760f88b

PiperOrigin-RevId: 308339007
Change-Id: I11d825203964cf3397846c57fd4a6f458e8536f3
上级 893bab22
......@@ -69,6 +69,7 @@ uint64 GetLatencyMicroseconds(const uint64 start_microseconds) {
}
// Ensure that constant tensors loaded from the saved model have valid shape.
// Also ensure that constant nodes have a value assigned to them.
// TODO(b/154763635): this is temporary and will be replaced with a better audit
static Status ValidateSavedTensors(const GraphDef& graph_def) {
for (const auto& node : graph_def.node()) {
......@@ -84,6 +85,10 @@ static Status ValidateSavedTensors(const GraphDef& graph_def) {
node_shape.num_elements(), " elements");
}
}
} else if (node.op() == "Const") {
return errors::FailedPrecondition(
"Saved model contains node \"", node.name(),
"\" which is a constant tensor but no value has been provided");
}
}
return Status::OK();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册