From 37c5bd1983aa5974ac3da93375d9c466426ebde8 Mon Sep 17 00:00:00 2001 From: Alan Kelly Date: Fri, 20 Sep 2024 02:35:57 -0700 Subject: [PATCH] Pad dynamically allocated tensors with XNN_EXTRA_BYTES Since XNNPack can now be applied to all models, these buffers may be passed to XNNPack. PiperOrigin-RevId: 676764594 --- tensorflow/lite/core/c/common.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/lite/core/c/common.cc b/tensorflow/lite/core/c/common.cc index d2cb82199bfce0..09e71d578f4c25 100644 --- a/tensorflow/lite/core/c/common.cc +++ b/tensorflow/lite/core/c/common.cc @@ -295,7 +295,8 @@ TfLiteStatus TfLiteTensorResizeMaybeCopy(size_t num_bytes, TfLiteTensor* tensor, #ifdef TF_LITE_TENSORFLOW_PROFILER tflite::PauseHeapMonitoring(/*pause=*/true); #endif - size_t alloc_bytes = num_bytes; + // This buffer may be consumed by XNNPack. + size_t alloc_bytes = num_bytes + /*XNN_EXTRA_BYTES=*/16; // TODO(b/145340303): Tensor data should be aligned. if (!tensor->data.data) { tensor->data.data = (char*)malloc(alloc_bytes);