4949namespace tvm {
5050namespace tirx {
5151
52+ namespace {
53+
54+ bool IsOp (const CallNode* call, const Op& compat_op, const char * canonical_name) {
55+ if (call->op .same_as (compat_op)) {
56+ return true ;
57+ }
58+ const auto * op_node = call->op .as <OpNode>();
59+ return op_node != nullptr && op_node->name == canonical_name;
60+ }
61+
62+ } // namespace
63+
5264// Rewrite Rule
5365//
5466// There is no special warp memory in most GPUs.
@@ -117,13 +129,14 @@ class WarpStoreCoeffFinder : private StmtExprVisitor {
117129 private:
118130 // / Visitor implementation
119131 void VisitExpr_ (const CallNode* op) final {
120- if (op->op .same_as (builtin::ptx_ldmatrix ()) && op->args [3 ].as <VarNode>() == buffer_) {
132+ if (IsOp (op, builtin::ptx_ldmatrix (), " tirx.ptx.ldmatrix" ) &&
133+ op->args [3 ].as <VarNode>() == buffer_) {
121134 UpdatePattern (op->args [4 ]);
122135 } else if (op->op .same_as (builtin::mma_fill ()) && op->args [1 ].as <VarNode>() == buffer_) {
123136 auto * local_size = op->args [0 ].as <IntImmNode>();
124137 TVM_FFI_ICHECK (local_size) << " Integer expected for the first argument of mma_fill" ;
125138 warp_coeff_ = local_size->value ;
126- } else if (op-> op . same_as ( builtin::ptx_ldmatrix_legacy ()) &&
139+ } else if (IsOp (op, builtin::ptx_ldmatrix_legacy (), " tirx.ptx.ldmatrix_legacy " ) &&
127140 op->args [3 ].as <VarNode>() == buffer_) {
128141 // ldmatrix writes the warp buffer; its local_offset carries
129142 // ``... + lift(local_size) * tx`` from which the warp coefficient
@@ -295,11 +308,11 @@ class WarpAccessRewriter : protected StmtExprMutator {
295308 }
296309
297310 PrimExpr VisitExpr_ (const CallNode* op) override {
298- if (op-> op . same_as ( builtin::ptx_mma ())) {
311+ if (IsOp (op, builtin::ptx_mma (), " tirx.ptx.mma " )) {
299312 return RewriteIndicesAt (op, {6 , 8 , 10 });
300313 }
301314
302- if (op-> op . same_as ( builtin::ptx_ldmatrix ())) {
315+ if (IsOp (op, builtin::ptx_ldmatrix (), " tirx.ptx.ldmatrix " )) {
303316 return RewriteIndicesAt (op, {3 });
304317 }
305318
@@ -312,10 +325,10 @@ class WarpAccessRewriter : protected StmtExprMutator {
312325 }
313326
314327 // Legacy variants: (ptr_var, offset) pairs in apache positions.
315- if (op-> op . same_as ( builtin::ptx_mma_legacy ())) {
328+ if (IsOp (op, builtin::ptx_mma_legacy (), " tirx.ptx.mma_legacy " )) {
316329 return RewriteIndicesAt (op, {6 , 8 , 10 });
317330 }
318- if (op-> op . same_as ( builtin::ptx_ldmatrix_legacy ())) {
331+ if (IsOp (op, builtin::ptx_ldmatrix_legacy (), " tirx.ptx.ldmatrix_legacy " )) {
319332 // args: trans, num, type, local_ptr, local_offset, smem_ptr_call, smem_offset
320333 // Only local_ptr is a raw warp buffer Var; smem_ptr is an
321334 // access_ptr Call wrapping a shared-scope var.
0 commit comments