diff options
author | Andrew Selle <aselle@google.com> | 2018-08-22 14:27:53 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-08-22 14:39:01 -0700 |
commit | 091c9809b8dfdb361a476472cb5d10d79b7cd41f (patch) | |
tree | a9900f9fcd5520824fc2907fff35e482eadf9cec /tensorflow/contrib/lite/model.cc | |
parent | 915fd68aa46f0f402a6939e547dded4a6b6dc60b (diff) |
Preallocate the node structure std::vector
PiperOrigin-RevId: 209830234
Diffstat (limited to 'tensorflow/contrib/lite/model.cc')
-rw-r--r-- | tensorflow/contrib/lite/model.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/model.cc b/tensorflow/contrib/lite/model.cc index 5f8d5c318a..e10a53b9a2 100644 --- a/tensorflow/contrib/lite/model.cc +++ b/tensorflow/contrib/lite/model.cc @@ -802,6 +802,10 @@ TfLiteStatus InterpreterBuilder::ParseNodes( const flatbuffers::Vector<flatbuffers::Offset<Operator>>* operators, Interpreter* interpreter) { TfLiteStatus status = kTfLiteOk; + + // Reduce the number of redundant allocations + interpreter->ReserveNodes(operators->Length()); + for (int i = 0; i < operators->Length(); ++i) { const auto* op = operators->Get(i); int index = op->opcode_index(); |