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

[api] add API for exporting model as c++ source #1341

Merged
merged 1 commit into from
Feb 28, 2025
Merged

Conversation

pilkicTT
Copy link
Contributor

@pilkicTT pilkicTT commented Feb 27, 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.

Example usage:

compiled_model.export_to_cpp(file_name)

Closes #1340
Closes tenstorrent/tt-mlir#1944

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests616 ran484 passed132 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests675 ran538 passed137 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests616 ran484 passed132 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests675 ran538 passed137 skipped0 failed
TestResult
No test annotations available

@pilkicTT pilkicTT force-pushed the pilkic/emitc-option branch from 1cd3281 to 011c185 Compare February 28, 2025 15:53
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests675 ran543 passed132 skipped0 failed
TestResult
No test annotations available

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
@pilkicTT pilkicTT force-pushed the pilkic/emitc-option branch from 011c185 to c38579b Compare February 28, 2025 16:33
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests617 ran483 passed134 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests675 ran543 passed132 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests617 ran483 passed134 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests675 ran543 passed132 skipped0 failed
TestResult
No test annotations available

@pilkicTT pilkicTT merged commit cde0127 into main Feb 28, 2025
10 checks passed
@pilkicTT pilkicTT deleted the pilkic/emitc-option branch February 28, 2025 17:51
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.

[api] add user API for exporting compiled model as c++ source Pipe EmitC thru ForgeFE
3 participants