Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/tir/analysis/estimate_flops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,20 @@ class FlopEstimator : private ExprFunctor<TResult(const PrimExpr& n)>,
return cond;
}

TResult VisitStmt_(const AssertStmtNode* op) override {
TResult result = VisitExpr(op->condition);
if (op->message.defined()) {
result += VisitExpr(op->message);
}
result += VisitStmt(op->body);
return result;
}
Comment on lines +196 to +203

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cost of evaluating the assertion message should likely be excluded from the FLOP count. The message is only evaluated on the exceptional path when the assertion fails, whereas FLOP estimation is typically concerned with the performance of the successful execution path. Including the message's FLOPs could lead to an overestimation, especially if the message formatting involves computations.

  TResult VisitStmt_(const AssertStmtNode* op) override {
    TResult result = VisitExpr(op->condition);
    result += VisitStmt(op->body);
    return result;
  }


TResult VisitExpr_(const VarNode* op) override { return TResult(); }
TResult VisitExpr_(const SizeVarNode* op) override { return TResult(); }
TResult VisitExpr_(const IntImmNode* op) override { return TResult(); }
TResult VisitExpr_(const FloatImmNode* op) override { return TResult(); }
TResult VisitExpr_(const StringImmNode* op) override { return TResult(); }
TResult VisitExpr_(const CastNode* op) override { return VisitExpr(op->value); }
TResult VisitStmt_(const AllocateConstNode* op) override { return VisitStmt(op->body); }
TResult VisitStmt_(const AllocateNode* op) override { return VisitStmt(op->body); }
Expand Down
Loading