aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/interpreter.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-06-19 10:02:11 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-19 10:05:35 -0700
commit7f449920f8910561a4e57cc35b96fb7faf08ef98 (patch)
tree036ee28b10d59da6bb38a1e59625a5620b94924f /tensorflow/contrib/lite/interpreter.cc
parent5fc2bdd2d5f624a6bad9e83b992029e3799ab64e (diff)
Refresh allocations in the presence of dynamic tensors
PiperOrigin-RevId: 201193941
Diffstat (limited to 'tensorflow/contrib/lite/interpreter.cc')
-rw-r--r--tensorflow/contrib/lite/interpreter.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/interpreter.cc b/tensorflow/contrib/lite/interpreter.cc
index 3287f9c4fd..57b2c0f32b 100644
--- a/tensorflow/contrib/lite/interpreter.cc
+++ b/tensorflow/contrib/lite/interpreter.cc
@@ -605,9 +605,17 @@ TfLiteStatus Interpreter::Invoke() {
}
EnsureTensorsVectorCapacity();
+ tensor_resized_since_op_invoke_ = false;
if (OpInvoke(registration, &node) == kTfLiteError) {
status = kTfLiteError;
}
+
+ // Force execution prep for downstream ops if the latest op triggered the
+ // resize of a dynamic tensor.
+ if (tensor_resized_since_op_invoke_ &&
+ HasDynamicTensor(context_, node.outputs)) {
+ next_execution_plan_index_to_prepare_ = execution_plan_index + 1;
+ }
}
if (!allow_buffer_handle_output_) {
@@ -783,6 +791,8 @@ TfLiteStatus Interpreter::ResizeTensorImpl(TfLiteTensor* tensor,
if (tensor->allocation_type == kTfLiteArenaRw ||
tensor->allocation_type == kTfLiteDynamic ||
tensor->allocation_type == kTfLiteArenaRwPersistent) {
+ tensor_resized_since_op_invoke_ |=
+ TfLiteIntArrayEqual(tensor->dims, new_size) == 0;
if (tensor->type != kTfLiteString) {
size_t bytesRequired;
TfLiteStatus status = BytesRequired(tensor->type, new_size->data,