-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ttmlir-translate
docs and cpp gen example (#152)
* add `ttmlir-translate` docs and cpp gen example * add piped version
- Loading branch information
1 parent
4da2db8
commit 732d081
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# `ttmlir-translate` | ||
|
||
The `ttmlir-translate` translation utility. Unlike `ttmlir-opt` tool which is used to run passes within the MLIR world, `ttmlir-translate` allows us to ingest something (e.g. code) into MLIR world, and also produce something (e.g. executable binary, or even code again) from MLIR. | ||
## Generate C++ code from MLIR | ||
|
||
```bash | ||
# First, let's run `ttmlir-opt` to convert to proper dialect | ||
./build/bin/ttmlir-opt --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn --convert-ttnn-to-emitc test/ttmlir/Dialect/TTNN/simple_multiply.mlir -o c.mlir | ||
|
||
# Now run `ttmlir-translate` to produce C++ code | ||
./build/bin/ttmlir-translate -mlir-to-cpp c.mlir -allow-unregistered-dialect | ||
``` | ||
|
||
Bonus: These two commands can be piped, to avoid writing a `mlir` file to disk, like so: | ||
```bash | ||
./build/bin/ttmlir-opt --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn --convert-ttnn-to-emitc test/ttmlir/Dialect/TTNN/simple_multiply.mlir | ./build/bin/ttmlir-translate -mlir-to-cpp -allow-unregistered-dialect | ||
``` |