-
Notifications
You must be signed in to change notification settings - Fork 9
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
[api] add API for exporting model as c++ source #1341
Merged
Merged
+144
−17
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
|
|
|
nvukobratTT
approved these changes
Feb 27, 2025
1cd3281
to
011c185
Compare
svuckovicTT
approved these changes
Feb 28, 2025
|
Adding support for exporting compiled model as c++ source, via the MLIR `emitc` pipeline. To export the model, the user would call `export_to_cpp()` on the already compiled model (`CompiledModel` instance). This means that there are no changes in the compile flow. The `CompiledModel` will hold the `ForgeGraphModule` generated during the compile, so that it can execute the needed `tt-mlir` pipeline for generating c++ code on demand. The other option would be to hold the generated `ttir` text (during compile) in memory, so that the pipeline can be ran from that point onwards. I've chosen the first option, since it's simpler to fit in the existing flow, and I don't see a big improvement in the other approach. Existing code for running the MLIR compiler is refactored a bit to allow generating different outputs (flatbuffer or cpp) without duplicating the logic. Simple test is added to confirm the C++ generation completes successfully. Closes #1340
011c185
to
c38579b
Compare
|
|
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding support for exporting compiled model as c++ source, via the MLIR
emitc
pipeline.To export the model, the user would call
export_to_cpp()
on the already compiled model (CompiledModel
instance). This means that there are no changes in the compile flow.The
CompiledModel
will hold theForgeGraphModule
generated during the compile, so that it can execute the neededtt-mlir
pipeline for generating c++ code on demand. The other option would be to hold the generatedttir
text (during compile) in memory, so that the pipeline can be ran from that point onwards. I've chosen the first option, since it's simpler to fit in the existing flow, and I don't see a big improvement in the other approach.Existing code for running the MLIR compiler is refactored a bit to allow generating different outputs (flatbuffer or cpp) without duplicating the logic.
Simple test is added to confirm the C++ generation completes successfully.
Example usage:
Closes #1340
Closes tenstorrent/tt-mlir#1944