Skip to content

Commit 3b20912

Browse files
authored
Correction for dynamic tensor checks (#3183)
@tensorflow/micro Correct legacy scalar check. Correct wording for modern scalar tensors. Revert MicroInterpreter test copyright date. bug=correction of PR #3180
1 parent 8eb17a7 commit 3b20912

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tensorflow/lite/micro/micro_interpreter_graph.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@ int CheckDynamicTensors(const TfLiteIntArray* const tensor_indices,
6060
if (tensor_index < 0) {
6161
continue;
6262
}
63+
6364
// Check shape for dims <= 0.
64-
// This code handles legacy scalar tensors (dims->size == 0).
6565
const TfLiteEvalTensor* const tp = eval_tensors + tensor_index;
66+
if (tp->dims->size == 1 && tp->dims->data[0] == 0) {
67+
// Legacy scalar shapes (dims->size == 1 && dims->data[0] == 0)
68+
continue;
69+
}
70+
// This code can handle scalar tensors (dims->size == 0)
6671
if (!std::all_of(tp->dims->data, tp->dims->data + tp->dims->size,
6772
[](int dim) { return dim > 0; })) {
6873
return tensor_index;

tensorflow/lite/micro/micro_interpreter_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2025 The TensorFlow Authors. All Rights Reserved.
1+
/* Copyright 2024 The TensorFlow Authors. All Rights Reserved.
22
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)