Dynamic TF Lite tensors using the TF Lite shim were not getting resized correctly. This fixes that problem and adds test for it on the byte_splitter op.
PiperOrigin-RevId: 453494714
diff --git a/tensorflow/lite/kernels/shim/tflite_op_shim.cc b/tensorflow/lite/kernels/shim/tflite_op_shim.cc
index 683b697..4f8b0e7 100644
--- a/tensorflow/lite/kernels/shim/tflite_op_shim.cc
+++ b/tensorflow/lite/kernels/shim/tflite_op_shim.cc
@@ -97,7 +97,8 @@
if (tflite_tensor == nullptr)
return absl::InternalError(
absl::StrCat("output tensor is null during invocation. idx: ", idx));
- if (tflite_tensor->data.raw == nullptr) {
+ if (tflite_tensor->data.raw == nullptr ||
+ tflite_tensor->allocation_type == kTfLiteDynamic) {
TfLiteIntArray* output_shape_array =
ShapeToTfLiteShape(output_shape.value());
context_->ResizeTensor(context_, tflite_tensor, output_shape_array);