Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unity][BYOC] Use arith.Analyzer to check batch equality of matmul in cublas #16982

Merged
merged 3 commits into from May 9, 2024

Conversation

rickzx
Copy link
Contributor

@rickzx rickzx commented May 8, 2024

For workloads with a mixture of symbolic shape and concrete shape as batch sizes, we cannot directly use int() to obtain the batch size. Instead, we can use arith.Analyzer to check equality.

For example:

permute_dims1: R.Tensor((batch_size, 12, seq_len, 64), dtype="float16") = R.permute_dims(split_0, axes=[0, 2, 1, 3])
permute_dims2: R.Tensor((batch_size, 12, seq_len, 64), dtype="float16") = R.permute_dims(split_1, axes=[0, 2, 1, 3])
permute_dims3: R.Tensor((batch_size, 12, seq_len, 64), dtype="float16") = R.permute_dims(split_2, axes=[0, 2, 1, 3])
permute_dims4: R.Tensor((batch_size, 12, 64, seq_len), dtype="float16") = R.permute_dims(permute_dims2, axes=[0, 1, 3, 2])
matmul1: R.Tensor((batch_size, 12, seq_len, seq_len), dtype="float16") = R.matmul(permute_dims1, permute_dims4, out_dtype="float16")

@rickzx
Copy link
Contributor Author

rickzx commented May 8, 2024

cc: @MasterJH5574

Copy link
Contributor

@MasterJH5574 MasterJH5574 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@tqchen tqchen merged commit fffd168 into apache:main May 9, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants