masahi commented on code in PR #14150:
URL: https://github.com/apache/tvm/pull/14150#discussion_r1123868036
##########
python/tvm/contrib/cutlass/gen_tensor_op.py:
##########
@@ -653,4 +655,34 @@ def get_batch_stride(stride_annot, arg0_idx, arg1_idx,
arg0_axis_idx, arg1_axis_
code = instantiate_conv2d_template(attrs, func_args)
return CodegenResult(code, headers)
+ elif "attention" in func_name:
+ headers.append("kernel_forward.h")
+ data_type = dtype_map[annotations["arg0_dtype"]]
+ attrs["data_type"] = DataTypeTag[data_type]
+ attrs["num_batches"] = b = annotations["num_batches"]
+ attrs["num_queries"] = s = annotations["num_queries"]
+ attrs["num_keys"] = annotations["num_keys"]
+ attrs["num_heads"] = n = annotations["num_heads"]
+ attrs["head_dim"] = h = annotations["head_dim"]
+ attrs["head_dim_value"] = h_v = annotations["head_dim_value"]
+ data_type_size = DataTypeSize[data_type]
+ if (data_type_size * h // 8) % 16 == 0 and (data_type_size * h_v // 8)
% 16 == 0:
+ attrs["kIsAligned"] = True
+ elif (h % 4 == 0) and (h_v % 4 == 0):
+ attrs["kIsAligned"] = False
+ else:
+ raise NotImplementedError()
+ if h_v > 64:
+ attrs["kQueriesPerBlock"] = "32"
+ attrs["kKeysPerBlock"] = "128"
+ attrs["kSingleValueIteration"] = h_v <= 128
+ else:
+ attrs["kQueriesPerBlock"] = "64"
+ attrs["kKeysPerBlock"] = "64"
Review Comment:
We can also remove the quotation now.
--
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]