Skip to content

[executorch][native] Add native runtime Program reader + DOT visualizer - #22218

Open
SS-JIA wants to merge 1 commit into
gh/SS-JIA/598/basefrom
gh/SS-JIA/598/head
Open

[executorch][native] Add native runtime Program reader + DOT visualizer#22218
SS-JIA wants to merge 1 commit into
gh/SS-JIA/598/basefrom
gh/SS-JIA/598/head

Conversation

@SS-JIA

@SS-JIA SS-JIA commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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 parses
    and verifies a serialized native graph (*.nptg). Program::load() copies
    the bytes, checks the NPTG FlatBuffer file identifier, runs the FlatBuffer
    verifier, and exposes a zero-copy view of the root; it throws
    std::runtime_error on failure. No ExecuTorch or torch dependency
    (flatbuffers only); exceptions allowed. Our sources build as C++20 -- the
    --cpp-std c++11 in the genrule sets the feature level of the generated
    accessors, not ours (flatc accepts only c++0x / c++11 / c++17).
  • ptn::to_dot(const Program&) (utils/ToDot.h / utils/ToDot.cpp): renders
    the 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_dot target rather than a
Program member, so a link that only reads programs does not carry it:
:runtime depends on the generated schema alone, while :to_dot pulls in
graph:format.

Also wires a --dot flag into the native_executor tool: load + verify via the
reader, then print the DOT to stdout.

The schema header is generated from serialization/native_graph.fbs via a
flatc genrule (:native_graph_schema). Mirrored into both the fbcode/ and
xplat/ trees to match the native backend layout.

Authored with Claude Code.

Differential Revision: D114396768

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22218

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant