aboutsummaryrefslogtreecommitdiff
path: root/delegate/classic/src/Redefine.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'delegate/classic/src/Redefine.hpp')
-rw-r--r--delegate/classic/src/Redefine.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/delegate/classic/src/Redefine.hpp b/delegate/classic/src/Redefine.hpp
index 6b10e448e7..c3422a2fb5 100644
--- a/delegate/classic/src/Redefine.hpp
+++ b/delegate/classic/src/Redefine.hpp
@@ -166,6 +166,18 @@ TfLiteStatus VisitReshapeOperator(DelegateData& delegateData,
return kTfLiteError;
}
+ // Check the target shape to check if there is zero in the shape.
+ if (std::find(targetShape.begin(), targetShape.end(), 0) != targetShape.end() &&
+ inputTensorInfo0.GetNumElements() != 0)
+ {
+ TF_LITE_MAYBE_KERNEL_LOG(tfLiteContext,
+ "TfLiteArmnnDelegate: Input to reshape is a tensor with elements, "
+ "but the requested shape has 0. "
+ "operator #%d node #%d: ",
+ operatorCode, nodeIndex);
+ return kTfLiteError;
+ }
+
// Use the data to create the required tensor shape.
if (CreateOutputTensorShape(inputTensorInfo0, targetShape, reshapeDesc) != kTfLiteOk)
{