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

Adding ttnn.to_dtype op in TTNN dialect #2055

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sdjordjevicTT
Copy link
Contributor

@sdjordjevicTT sdjordjevicTT commented Jan 31, 2025

In this pull request (PR), I am introducing the ttnn.to_dtype operation for data type casting on the host within the TTNN dialect.

The existing ttnn.typecast function only supports data type casting on a device, which has led to failures when casting on the host. To address this, I have also restructured the TTNNDecomposeLayouts.cpp file to accommodate these changes. Additionally, I have included compiler and silicon tests for scenarios where the inputs are located on the host.

Since we are now managing this behavior within the compiler, there is no longer a need for runtime workarounds. As a result, I have removed those workarounds in this PR.

This improvement will benefit emitC, which previously lacked a runtime workaround and caused several tests to fail. Now, with these changes, we can ensure better compatibility and functionality.

I created tests for Silicon from the transform pass. Please review it, and if anyone has a better method for running this on Silicon, your input would be greatly appreciated. Comments are welcome! :)

With this change, we are fixing a couple of bugs noticed:
Closes #1938
Closes #1733
Closes #1658

}

// If the input tensor is on device, we can cast it on the device.
return this->createDataTypeCastingOp<ttnn::TypecastOp>(op, rewriter,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add assert here that inputLayout.getLayout() must be Tile in this case.

@sdjordjevicTT sdjordjevicTT force-pushed the sdjordjevic/add_to_dtype_op_in_ttnn branch from 6a219f2 to 1f9d5af Compare February 2, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant