提交 5e303955 编写于 作者: M Mihai Maruseac

[tflite] Don't check for buffers on every subgraph.

Buffers in the model are allocated globally, hence it makes sense to check for
their presence only once (O(1)) instead of on every subgraph (O(n)).

PiperOrigin-RevId: 323677724
Change-Id: I2da0c381093006828cc4c80f03dec8a917782861
上级 f23eb717
......@@ -728,6 +728,11 @@ TfLiteStatus InterpreterBuilder::operator()(
return cleanup_and_error();
}
if (!buffers) {
error_reporter_->Report("No buffers in the model.\n");
return cleanup_and_error();
}
interpreter->reset(new Interpreter(error_reporter_));
(*interpreter)->SetNumThreads(num_threads);
if (subgraphs->Length() > 1) {
......@@ -745,9 +750,9 @@ TfLiteStatus InterpreterBuilder::operator()(
(*interpreter)->subgraph(subgraph_index);
auto operators = subgraph->operators();
auto tensors = subgraph->tensors();
if (!operators || !tensors || !buffers) {
if (!operators || !tensors) {
error_reporter_->Report(
"Did not get operators, tensors, or buffers in subgraph %d.\n",
"Did not get operators or tensors in subgraph %d.\n",
subgraph_index);
return cleanup_and_error();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册