aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/arena_planner.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-02-05 10:39:18 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-02-05 10:45:07 -0800
commitbccd80c45dab8f2856c176d45df7e7c72f35e14e (patch)
tree5429e28464f74889cc4ca8c179da0e35f6e61a80 /tensorflow/contrib/lite/arena_planner.cc
parenta9034babfd0100f0b998e900d074dd3d839d18bc (diff)
Proper reallocation of dynamic tensors.
PiperOrigin-RevId: 184550199
Diffstat (limited to 'tensorflow/contrib/lite/arena_planner.cc')
-rw-r--r--tensorflow/contrib/lite/arena_planner.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/tensorflow/contrib/lite/arena_planner.cc b/tensorflow/contrib/lite/arena_planner.cc
index bf1bcdd1a7..87b17c338e 100644
--- a/tensorflow/contrib/lite/arena_planner.cc
+++ b/tensorflow/contrib/lite/arena_planner.cc
@@ -185,8 +185,12 @@ TfLiteStatus ArenaPlanner::CalculateAllocations(int first_node, int last_node) {
TfLiteStatus ArenaPlanner::ResolveTensorAllocation(int tensor_index) {
TfLiteTensor& tensor = *graph_info_->tensor(tensor_index);
if (tensor.allocation_type == kTfLiteArenaRw) {
- TF_LITE_ENSURE_STATUS(
- arena_.ResolveAlloc(context_, allocs_[tensor_index], &tensor.data.raw));
+ // Skip resolution if the size of the tensor is zero, leaving it as a
+ // nullptr.
+ if (allocs_[tensor_index].size != 0) {
+ TF_LITE_ENSURE_STATUS(arena_.ResolveAlloc(context_, allocs_[tensor_index],
+ &tensor.data.raw));
+ }
}
if (tensor.allocation_type == kTfLiteArenaRwPersistent) {
TF_LITE_ENSURE_STATUS(persistent_arena_.ResolveAlloc(