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

#9709: Add optional transpose_a and transpose_b to ttnn matmul and linear #9836

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

TT-BrianLiu
Copy link
Contributor

@TT-BrianLiu TT-BrianLiu commented Jun 28, 2024

Ticket

Link to Github Issue

Problem description

In GGML, inputs a and b to matmul may be "pre-transposed", so to perform matmul properly we need a corresponding transpose a or b.

What's changed

Easiest solution is to add an optional transpose op before running matmul. I added transpose_a and transpose_b flags to specify whether to run the transpose on the inputs or not. This should work for most interleaved cases. As a side note, I also had to fix transpose to respect padding when swapping dims during compute_output_shapes.

There are two concerns that can be addressed down the line:

  • Perf: We can technically support the optional transpose directly in the matmuls, but this is a lot more work and requires more testing. But it will give us better perf.
  • Functionality: Using composite ops to achieve transpose will limit the input specs available to matmul to what's supported by our transpose op. We can either uplift transpose to support what matmul supports, or if we did the transposes internally in matmul this problem will automatically go away.

Checklist

@TT-BrianLiu TT-BrianLiu merged commit 2008386 into main Jul 2, 2024
5 checks passed
@TT-BrianLiu TT-BrianLiu deleted the jedi branch July 2, 2024 18:01
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.

4 participants