[executorch][native] Add Method + ValueRole to the in-memory IR - #22281
[executorch][native] Add Method + ValueRole to the in-memory IR#22281SS-JIA wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22281
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 809a1f7 with merge base a5f15b5 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
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):
Adds
ptn::Method, the stateful wrapper around one top-levelGraph, and theper-value
ValueRoleclassification it drives.Graphis a pure function body;Methodbinds its placeholder and output values to the things outside the puredataflow — external constant data, non-persistent buffers, and the per-output
classification that separates a real result from a state writeback. It mirrors
the schema
Methodbut resolves every in-graph reference to aValueId.Methodlives atruntime/(peer to theProgramreader), above thegraph/arena package, since it is a method-level rather than a graph-level concept.
New types:
ValueRole(onValue, ingraph/Value.h): UserInput / Parameter / Buffer /ConstantTensor / Intermediate. The placeholder roles are pinned to the schema
InputKindids;Intermediateextends them for a value a node produces.Stamped by the deserializer, it gives an O(1) per-value answer 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 aplaceholder
ValueIdto external storage.keyis the fqn (anexternal-constant-file key when
has_data, else the buffer's cross-methodidentity), and the binding is the only place it lives;
has_dataselects theload path (fetch bytes vs zero-init at load);
mutatedmarks a Buffer writtenin place whose state persists across executions;
rolemirrors the boundvalue's role for direct access when iterating bindings.
OutputKind(graph-level: UserOutput / BufferMutation / UserInputMutation) andOutputSpec(aligned tograph.output_idsby index). A mutation output'starget_idis aValueIdto 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
targetstring; the wire fqn /SSA name is recovered from that value.
Methoditself:name,Graph graph,data_bindings,output_specs. HOPsubgraphs carry no bindings (their params are lifted here and passed as
operands), which is why
MethodwrapsGraphrather than folding into it.to_string(const Method&)(utils/Print.{h,cpp}, targetruntime:print) —the method layer of the IR printer, split from the graph-level one only
because
Methodsits above thegraph/package.Pure std only (no ExecuTorch, no flatbuffers).
Differential Revision: D114426388