From b109936080cfa3189922fc290c1d409e715e9ea4 Mon Sep 17 00:00:00 2001 From: Matthew Brookhart Date: Sat, 6 Feb 2021 01:54:01 -0700 Subject: [PATCH] check for dynamic rank before accessing value (#7414) --- src/relay/op/dyn/tensor/transform.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/relay/op/dyn/tensor/transform.cc b/src/relay/op/dyn/tensor/transform.cc index 8bad3943f5ce..9724a92e8776 100644 --- a/src/relay/op/dyn/tensor/transform.cc +++ b/src/relay/op/dyn/tensor/transform.cc @@ -64,8 +64,9 @@ bool ReshapeRel(const Array& types, int num_inputs, const Attrs& attrs, return false; } - // Doesn't support dynamic output rank - for (int i = 0; i < newshape->shape[0].as()->value; i++) { + const IntImmNode* rank = newshape->shape[0].as(); + ICHECK(rank != nullptr) << "Dynamic Reshape doesn't support Dynamic Rank"; + for (int i = 0; i < rank->value; i++) { oshape.push_back(Any()); }