Skip kOptionalTensor(-1) in IsAllAllowedTensors()
PiperOrigin-RevId: 313121707
Change-Id: I04062b6413f5db677294e3a78495d954c9307fff
diff --git a/tensorflow/lite/delegates/gpu/common/model_builder.cc b/tensorflow/lite/delegates/gpu/common/model_builder.cc
index 18b4858..64b335f 100644
--- a/tensorflow/lite/delegates/gpu/common/model_builder.cc
+++ b/tensorflow/lite/delegates/gpu/common/model_builder.cc
@@ -2763,10 +2763,13 @@
->IsSupported(context, node, registration);
}
-bool IsAllAllowedTensors(TfLiteContext* context, const TfLiteIntArray* array,
+bool IsAllAllowedTensors(TfLiteContext* context,
+ const TfLiteIntArray* tensor_indices,
bool allow_quant_ops = false) {
- for (int i = 0; i < array->size; ++i) {
- const TfLiteTensor* t = context->tensors + array->data[i];
+ for (int i = 0; i < tensor_indices->size; ++i) {
+ int tensor_idx = tensor_indices->data[i];
+ if (tensor_idx == kTfLiteOptionalTensor) continue;
+ const TfLiteTensor* t = &context->tensors[tensor_idx];
bool type_supported =
(t->type == kTfLiteFloat32 || t->type == kTfLiteFloat16);
if (allow_quant_ops) {