From 3362f81716405341130305024ab14f3d88b784b1 Mon Sep 17 00:00:00 2001 From: Eric Lunderberg Date: Wed, 10 Jan 2024 20:24:45 +0000 Subject: [PATCH] [Unity] Improve error message in tensor_to_shape struct inference If the tensor argument does not have a valid shape, then the error message will include the expression, the argument, and the struct info of the argument. --- src/relax/op/op.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/relax/op/op.cc b/src/relax/op/op.cc index f51d2cc74f51..489886e50f76 100644 --- a/src/relax/op/op.cc +++ b/src/relax/op/op.cc @@ -780,7 +780,9 @@ StructInfo ReturnTensorToShapeStructInfo(const Call& call, const BlockBuilder& c const auto* tsinfo = GetStructInfoAs(call->args[0]); ICHECK(tsinfo && tsinfo->shape.defined()); ShapeExpr shape_expr = Downcast(tsinfo->shape.value()); - ICHECK(shape_expr->values.size() == 1); + ICHECK(shape_expr->values.size() == 1) << "relax.tensor_to_shape expected argument to be 1-d, " + << "but " << call << " has argument " << call->args[0] + << " with struct info " << call->args[0]->struct_info_; const IntImmNode* ndim = shape_expr->values[0].as(); ICHECK(ndim); return ShapeStructInfo(ndim->value);