yelite commented on code in PR #14166:
URL: https://github.com/apache/tvm/pull/14166#discussion_r1122615865


##########
python/tvm/contrib/cutlass/gen_tensor_op.py:
##########
@@ -548,17 +549,20 @@ def get_batch_stride(stride_annot, arg0_idx, arg1_idx, 
arg0_axis_idx, arg1_axis_
         attrs["ElementInputB"] = 
DataTypeTag[dtype_map[annotations[f"arg{rhs_arg_idx}_dtype"]]]
         attrs["ElementOutput"] = 
DataTypeTag[dtype_map[annotations["ret_dtype"]]]
 
-        attrs["K"] = str(int(lhs_shape[batched_offset + 1]))
-        attrs["M"] = get_dim(lhs_shape[batched_offset], lhs_arg, 0, 
batched_offset)
+        attrs["K"] = str(int(lhs_shape[lhs_batched_offset + 1]))
+        attrs["M"] = get_dim(lhs_shape[lhs_batched_offset], lhs_arg, 0, 
lhs_batched_offset)
 
         if transposed:
-            attrs["N"] = get_dim(rhs_shape[batched_offset], rhs_arg, 0, 
batched_offset)
+            attrs["N"] = get_dim(rhs_shape[rhs_batched_offset], rhs_arg, 0, 
rhs_batched_offset)
         else:
-            attrs["N"] = get_dim(rhs_shape[batched_offset + 1], rhs_arg, 1, 
batched_offset)
+            attrs["N"] = get_dim(rhs_shape[rhs_batched_offset + 1], rhs_arg, 
1, rhs_batched_offset)
 
         if batched:
             headers.append("cutlass/gemm/device/gemm_batched.h")
-            attrs["batch"] = get_dim(lhs_shape[0], lhs_arg, 0)
+            # TODO: Support dynamic shape
+            # With the support of more general broadcasting in batch matmul,
+            # it needs more sophisticated code to handle dynamic shape
+            attrs["batch"] = str(int(annotations["batch"]))

Review Comment:
   Yes, for example, matmul with shape (a, b, c, 5, 5) x (5, 5) has batch `a * 
b * c`. I reverted the change on this line. Right now the check function in the 
cutlass pattern table requires static shape anyway. I will create a followup PR 
for formal dynamic shape support in cutlass matmul.



-- 
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]

Reply via email to