Skip to content

[executorch][native] Add Method + ValueRole to the in-memory IR - #22104

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

[executorch][native] Add Method + ValueRole to the in-memory IR#22104
SS-JIA wants to merge 1 commit into
gh/SS-JIA/593/basefrom
gh/SS-JIA/593/head

Conversation

@SS-JIA

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

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Adds ptn::Method, the stateful wrapper around one top-level Graph, and the
per-value ValueRole classification it drives. Graph is a pure function body;
Method binds its placeholder and output values to the things outside the pure
dataflow — external constant data, non-persistent buffers, and the per-output
classification that separates a real result from a state writeback. It mirrors
the schema Method but resolves every in-graph reference to a ValueRef.

Method lives at runtime/ (peer to the Program reader), above the graph/
arena package, since it is a method-level rather than a graph-level concept.

New types:

  • ValueRole (on Value, in graph/Value.h): Intermediate / UserInput /
    Parameter / Buffer / ConstantTensor. Value also gains a data_key string.
    Both are stamped by the deserializer and give O(1) per-value answers to "how
    is this value's storage owned / sourced" (the memory planner and runtime
    binder are the eventual consumers).

  • DataBinding (schema NamedTensorRef + MutableBufferSpec, merged): binds a
    placeholder ValueRef to external storage. key is the namespace-3 fqn (an
    external-constant-file key when has_data, else the buffer's cross-method
    identity); has_data selects the load path (fetch bytes vs zero-init at
    load); mutated marks a Buffer written in place whose state persists across
    executions; role mirrors the bound value's role for direct access when
    iterating bindings.

  • OutputKind (graph-level: UserOutput / BufferMutation / UserInputMutation) and
    OutputSpec (aligned to graph.output_refs by index). A mutation output's
    target_ref is a ValueRef to the mutated placeholder value in this graph
    (both the mutated user input and the mutated buffer are lifted placeholders
    here), replacing the schema's dual-namespace target string; the wire fqn /
    SSA name is recovered from that value.

  • Method itself: name, Graph graph, data_bindings, output_specs, plus a
    to_string() debug dump. HOP subgraphs carry no bindings (their params are
    lifted here and passed as operands), which is why Method wraps Graph
    rather than folding into it.

Pure std only (no ExecuTorch, no flatbuffers).

Differential Revision: D114426388

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 5441f30 with merge base 9a2d135 (image):

NEW FAILURE - The following job has failed:

  • pull / android / run-emulator (gh)
    adb: failed to install android-test-debug-androidTest.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package org.pytorch.executorch.test signatures do not match newer version; ignoring!]

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.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 24, 2026
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