[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
This commit is contained in:
parent
b5013e29cc
commit
2369d14f9d
@ -609,7 +609,12 @@ TfLiteStatus InterpreterBuilder::operator()(
|
||||
auto* buffers = model_->buffers();
|
||||
|
||||
if (subgraphs->size() == 0) {
|
||||
error_reporter_->Report("No subgraph in the model.\n");
|
||||
TF_LITE_REPORT_ERROR(error_reporter_, "No subgraph in the model.\n");
|
||||
return cleanup_and_error();
|
||||
}
|
||||
|
||||
if (!buffers) {
|
||||
TF_LITE_REPORT_ERROR(error_reporter_, "No buffers in the model.\n");
|
||||
return cleanup_and_error();
|
||||
}
|
||||
|
||||
@ -630,10 +635,10 @@ TfLiteStatus InterpreterBuilder::operator()(
|
||||
(*interpreter)->subgraph(subgraph_index);
|
||||
auto operators = subgraph->operators();
|
||||
auto tensors = subgraph->tensors();
|
||||
if (!operators || !tensors || !buffers) {
|
||||
error_reporter_->Report(
|
||||
"Did not get operators, tensors, or buffers in subgraph %d.\n",
|
||||
subgraph_index);
|
||||
if (!operators || !tensors) {
|
||||
TF_LITE_REPORT_ERROR(error_reporter_,
|
||||
"Did not get operators or tensors in subgraph %d.\n",
|
||||
subgraph_index);
|
||||
return cleanup_and_error();
|
||||
}
|
||||
if (modified_subgraph->AddTensors(tensors->size()) != kTfLiteOk) {
|
||||
|
Loading…
Reference in New Issue
Block a user