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

Add options to ttmlir-translate to output C++ from TTKernel dialect #1602

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

TT-billteng
Copy link

@TT-billteng TT-billteng commented Dec 15, 2024

Shardon requires emitting C++ from python kernels. To help with the testing and debug process, I've added a TTKernel to C++ target and options to ttmlir-translate to directly dump C++ from TTKernel dialect.

There are separate Noc and Tensix kernel dumping options because shardon users need to explicitly control the definition of Noc and Tensix kernels separately.

@TT-billteng TT-billteng force-pushed the bteng/shardon_emitc branch 7 times, most recently from d77935c to 3a50482 Compare December 20, 2024 23:56
@TT-billteng TT-billteng changed the title initial check-in Add options to dump noc and tensix kernels directly to C++ Dec 28, 2024
emitKernelAsCpp(mlir::ModuleOp op, llvm::raw_ostream &os, const ttkernel::ThreadType &threadType )
{
std::vector<func::FuncOp> ops;
op->walk([&](func::FuncOp entry) {
Copy link
Author

Choose a reason for hiding this comment

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

Is there a better way to extract the nested FuncOp from ModuleOp?

//TODO: Should generalize this to read kernel type from Attribute?
void registerTensixKernelToCpp() {
TranslateFromMLIRRegistration reg(
"tensixkernel-to-cpp", "translate tensix kernel to C++",
Copy link
Author

Choose a reason for hiding this comment

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

Feel like I need to change the option to ttkernel-to-cpp=noc and ttkernel-to-cpp=tensix

Copy link
Author

Choose a reason for hiding this comment

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

Is this possible? If so, where can I find an example?

@TT-billteng TT-billteng changed the title Add options to dump noc and tensix kernels directly to C++ Add TTKernel to C++ target and new options to ttmlir-translate Dec 28, 2024
@TT-billteng TT-billteng changed the title Add TTKernel to C++ target and new options to ttmlir-translate Add new options to ttmlir-translate to output C++ from TTKernel dialect Dec 28, 2024
@TT-billteng TT-billteng changed the title Add new options to ttmlir-translate to output C++ from TTKernel dialect Add options to ttmlir-translate to output C++ from TTKernel dialect Dec 28, 2024
@TT-billteng TT-billteng marked this pull request as ready for review December 28, 2024 08:26
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.

1 participant