Lunderberg commented on code in PR #16067:
URL: https://github.com/apache/tvm/pull/16067#discussion_r1383511660
##########
src/relax/analysis/well_formed.cc:
##########
@@ -301,13 +302,38 @@ class WellFormedChecker : public relax::ExprVisitor,
}
}
- for (const StructInfo& sinfo_arg : op->sinfo_args) {
+ for (const StructInfo& sinfo_arg : call->sinfo_args) {
this->VisitStructInfo(sinfo_arg);
}
- CheckStructInfo(op);
- if (is_dataflow_ && check_struct_info_ && IsImpureCall(GetRef<Call>(op))) {
- Malformed(Diagnostic::Error(op) << "There cannot be an impure call
inside a dataflow block.");
+ CheckStructInfo(call);
+ if (is_dataflow_ && check_struct_info_ &&
IsImpureCall(GetRef<Call>(call))) {
+ Malformed(Diagnostic::Error(call)
+ << "There cannot be an impure call inside a dataflow block.");
+ }
+
+ // If the operation has defined a custom normalization function
+ // using the FNormalize attribute, the call node must be normalized in
order to be well-formed.
Review Comment:
> While this is general. It also comes with overhead of creating a
BlockBuilder.
I did a few benchmarks to verify, and the creation of a `BlockBuilder` has
negligible overhead. The overhead of constructing it is about 1 microsecond.
Measuring this requiring removing several larger overheads, including the
`LOG(DEBUG)` on ill-formed output (6 microseconds), and the overhead of passing
the error message through the PackedFunc interface (~50 microseconds).
Since the overhead is negligible, we can avoid duplication of the same
checks by implementing the well-formed check in terms of normalization. That
is, being well-formed requires being normalized.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]