[executorch][native] Add native runtime Program reader + DOT visualizer - #22274
[executorch][native] Add native runtime Program reader + DOT visualizer#22274SS-JIA wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22274
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit bad0d64 with merge base a5f15b5 ( NEW FAILURE - The following job has failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
digantdesai
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Stack from ghstack (oldest at bottom):
First C++ runtime components for the native backend, under
backends/native/runtime/:ptn::Program(Program.h/Program.cpp): a standalone reader that parsesand verifies a serialized native graph (
*.ptg).Program::load()copiesthe bytes, checks the
NPTGFlatBuffer file identifier, runs the FlatBufferverifier, and exposes a zero-copy view of the root; it throws
std::runtime_erroron failure. No ExecuTorch or torch dependency(flatbuffers only); exceptions allowed. Our sources build as C++20 -- the
--cpp-std c++11in the genrule sets the feature level of the generatedaccessors, not ours (flatc accepts only c++0x / c++11 / c++17).
ptn::to_dot(const Program&)(utils/ToDot.h/utils/ToDot.cpp): rendersthe program to Graphviz DOT text -- methods as clusters, dataflow / def-use
as labeled edges, tensor metadata, constants, alias / mutation facts, quant,
and HOP subgraphs. Pure string builder, no I/O. Doubles as the reference walk
of
native_backend::Program.The renderer is a free function in its own
:to_dottarget rather than aProgrammember, so a link that only reads programs does not carry it::runtimedepends on the generated schema alone, while:to_dotpulls ingraph:string_format.Also wires a
--dotflag into theptg_inspectortool: load + verify via thereader, then print the DOT to stdout.
The schema header is generated from
serialization/native_graph.fbsvia aflatcgenrule (:native_graph_schema). Mirrored into both thefbcode/andxplat/trees to match the native backend layout.Authored with Claude Code.
Differential Revision: D114396768