Open Cookiee235 opened 2 months ago
Looks like this is a combination of a couple of factors.
R.call_tir
, the arguments in R.call_tir_inplace
must be an in-line relax::Tuple
(See the discussion in https://github.com/apache/tvm/pull/15916 for discussion on this requirement.)R.call_tir_inplace
is wrapped into an in-line tuple if it is not already an in-line tuple. While the normalization of R.call_tir_inplace
would handle this case if the expression is generated through C++, this wrapping generates a tuple of var-to-tuple (R.tuple(args)
), circumventing the normalization.R.call_tir_inplace
can be triggered by multiple conditions (argument is not a tensor, argument doesn't have known shape, argument's known shape does not match output shape), but the error message attempts to access the argument's known shape, triggering a segfault if it doesn't actually exist.I've submitted separate PR https://github.com/apache/tvm/pull/17242 which should provide a better error message (instead of a segfault) when this occurs.
For (2), we may be able to improve it by checking isinstance(args.struct_info, TupleStructInfo)
rather than isinstance(args. relax.Tuple)
. This way, a tuple that was defined earlier in the function wouldn't be modified, and would produce an error message at an earlier point. The normalization (which would produce the required in-line Tuple) is suppressed during TVMScript parsing, since TVMScript is frequently used for writing test cases that violate Relax assumptions. Maybe we should tie the normalization to the existing check_well_formed
flag, so those tests usually disable the well-formed checks as well.
And #17243 should address (2) by improving the error message.
@Lunderberg Thanks for your fixing. Segfault is a dangerous behavior, fixing it with an error message is a good strategy. Also thanks for your efforts in improving the well-formed checking for relay IR which is also very meaningful.
Actual behavior
Steps to reproduce
cc @Lunderberg @junrushao