Skip to content

Commit

Permalink
Pad dynamically allocated tensors with XNN_EXTRA_BYTES
Browse files Browse the repository at this point in the history
Since XNNPack can now be applied to all models, these buffers may be passed to XNNPack.

PiperOrigin-RevId: 676764594
  • Loading branch information
alankelly authored and tensorflower-gardener committed Sep 20, 2024
1 parent 598ebd5 commit 37c5bd1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tensorflow/lite/core/c/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 37c5bd1

Please sign in to comment.