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

Workaround pass - Initial implementation #1402

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

sdjordjevicTT
Copy link
Contributor

@sdjordjevicTT sdjordjevicTT commented Nov 25, 2024

This PR introduces the initial implementation of a workaround pass in the TTNN dialect. It establishes the foundation for handling operation-specific workarounds by defining interfaces and data structures and includes the initial logic for applying these workarounds. While the logic is disabled by default in this PR, future updates will gradually enable it in the compiler. Below is a summary of the changes:

  • Introduced TTNNWorkaround classes to abstract the workarounds we can currently specify
  • Introduced the TTNNWorkaroundInterface in the TTNN dialect
    • Interface for now retrieves the operation operand workarounds mentioned above for:
      • Tensor Layout
      • Tensor Buffer Type
      • Tensor Memory Layout
    • For now, the interface provides default values. However, as a proof of concept, custom workarounds have been implemented for the empty and abs operations, along with the corresponding test. Future PRs will extend and refine these workarounds.
  • New TTNN Workaround pass that utilizes the above interface to apply workarounds and produce the valid IR.
    • This pass is not yet enabled by default. Subsequent PRs will enable it incrementally as the implementation matures.

Closes #1136
Closes #1135

Copy link
Contributor

@rpavlovicTT rpavlovicTT left a comment

Choose a reason for hiding this comment

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

Reviewed up to lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp file.

include/ttmlir/Dialect/TTNN/IR/TTNNWorkaroundInterface.td Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/Transforms/Passes.td Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@svuckovicTT svuckovicTT left a comment

Choose a reason for hiding this comment

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

Left some comments, brain's fried, will finish the rest of the lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp tmr.

include/ttmlir/Dialect/TTNN/IR/TTNNWorkaroundInterface.td Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkaroundInterface.td Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNOps.td Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch 4 times, most recently from 653d8c8 to 96e5056 Compare November 26, 2024 17:25
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

include/ttmlir/Dialect/TTNN/IR/TTNNWorkaroundInterface.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/Utils/TransformUtils.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch from 96e5056 to 8348b0d Compare November 27, 2024 09:45
Copy link
Contributor

@azecevicTT azecevicTT left a comment

Choose a reason for hiding this comment

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

I will review lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp later today.

include/ttmlir/Dialect/TTNN/IR/TTNNWorkaroundInterface.td Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/Transforms/Passes.td Outdated Show resolved Hide resolved
lib/Dialect/TTNN/IR/TTNNWorkaroundInterface.cpp Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch 4 times, most recently from 7db2dd6 to 1d475a9 Compare November 27, 2024 12:49
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch 3 times, most recently from 65136c7 to ab9d422 Compare November 27, 2024 14:41
lib/Dialect/TTNN/IR/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch 2 times, most recently from 0049be3 to 2e12e73 Compare November 28, 2024 10:54
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch 5 times, most recently from bf4ce73 to 2c0c550 Compare November 29, 2024 15:18
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
include/ttmlir/Utils.h Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch 2 times, most recently from 3bc34b7 to 8fb0ca6 Compare December 2, 2024 18:16
Copy link
Contributor

@nsmithtt nsmithtt left a comment

Choose a reason for hiding this comment

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

Thank you!

@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch from 8fb0ca6 to 0d9f578 Compare December 3, 2024 08:16
include/ttmlir/Dialect/TTNN/IR/TTNNOps.td Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
include/ttmlir/Dialect/TTNN/IR/TTNNWorkarounds.h Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
lib/Dialect/TTNN/Transforms/TTNNWorkarounds.cpp Outdated Show resolved Hide resolved
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch 7 times, most recently from 4dff361 to a66bc8e Compare December 3, 2024 22:57
@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/workaround_interface branch from a66bc8e to 8a59402 Compare December 4, 2024 08:32
@sdjordjevicTT sdjordjevicTT merged commit 06b7a45 into main Dec 4, 2024
21 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.

[TTNN] Introduce GetOperandConstraints op interface [TTNN] Introduce the workaround pass in TTNN
6 participants