Skip to content

Commit 47424b3

Browse files
authored
[Unity] Improve error message in tensor_to_shape struct inference (#16473)
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.
1 parent 5012208 commit 47424b3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/relax/op/op.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,9 @@ StructInfo ReturnTensorToShapeStructInfo(const Call& call, const BlockBuilder& c
780780
const auto* tsinfo = GetStructInfoAs<TensorStructInfoNode>(call->args[0]);
781781
ICHECK(tsinfo && tsinfo->shape.defined());
782782
ShapeExpr shape_expr = Downcast<ShapeExpr>(tsinfo->shape.value());
783-
ICHECK(shape_expr->values.size() == 1);
783+
ICHECK(shape_expr->values.size() == 1) << "relax.tensor_to_shape expected argument to be 1-d, "
784+
<< "but " << call << " has argument " << call->args[0]
785+
<< " with struct info " << call->args[0]->struct_info_;
784786
const IntImmNode* ndim = shape_expr->values[0].as<IntImmNode>();
785787
ICHECK(ndim);
786788
return ShapeStructInfo(ndim->value);

0 commit comments

Comments
 (0)