Closed MasterJH5574 closed 1 year ago
[Upd: Done] Waiting for #349 to merge first and update the ConstantNode unit test.
one note perhaps we need to move PrintFatal to dispatch to script printing later. (cc @junrushao)
This one is now ready for review.
Thanks @YuchenJin! Just addressed your comments with one more case of constants, and string comparison for BindingBlock and SeqExpr. Please take another look :-)
Thanks @MasterJH5574 for patching the printing, it has bothered many of us for a while.
PR #306 introduces dedicated Relax Exprs, making Relax sub-class Expr independent of Relay Expr. This PR is a fix on the text printer accordingly.
Prior to this PR, TextPrinter::PrintFinal only dispatch VarNode, FunctionNode and ShapeExprNode to Relax printer, leaving all other kinds of Exprs to Relay text printer. This is fine at the time before PR #306, when we were reusing Exprs from Relay. But since #306 this becomes an issue, because Relax Exprs are not properly dispatched to Relax printer. As a result, when we print a CallNode or TupleNode on Python side, or structural-equality check finds mismatch on Tuples, the PrettyPrint as well as PrintFinal cannot dispatch the Expr, and will result in error like
which is not supposed and is also the least informative.
So this PR fixes the issue by adding our Relax Exprs to the dispatch rule. There are corresponding unit tests to make sure the printer issue is not likely to happen again.
cc @Hzfengsy @YuchenJin @tqchen