[executorch][native] Add Argument tagged union to the in-memory IR - #22278
[executorch][native] Add Argument tagged union to the in-memory IR#22278SS-JIA wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22278
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit 73ba529 with merge base a5f15b5 ( 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):
Adds
ptn::Argument, the in-memory form of an fx node argument, mirroring theschema
ArgumentValueunion but with in-graph references resolved toValueIdarena indices instead of SSA-name strings (the deserializer will do the name ->
id resolution).
Argumentis a tagged union over the 13 payload structs (TensorArg,IntArg,TensorListArg,GraphArg, ...), backed by astd::variantwhose alternativesare declared in
ArgKindorder sokind()is the variant's index. Astatic_assertpins each kind to its alternative and checks the two lists arethe same length, so they cannot drift apart -- and the variant keeps the
non-trivial payloads (
std::string,std::vector) correct without hand-writtenlifetime management. Payloads are read via
kind()+ throwingas_*()accessors, the same idiom as
Value.Symbolic scalar args carry both a literal
valueand anid(validid=>symbolic, e.g. a
sym_sizeresult).OptionalTensorListArgcollapses theschema's parallel
has_value[]into akInvalidsentinel per element.GraphArgholds aGraphId(index into a subgraph arena that lands withGraph/Model), not an owned subgraph, soArgumentneeds noGraphdependency, forward declaration, or incomplete-type destructor.
NamedArgumentwraps an
Argumentwith its op-schema parameter name and an in-placemutatedflag.
Also adds
using GraphId = int32_t;toIds.hfor theGraphArghandle, andextends the IR printer (
utils/Print.{h,cpp}) withto_string(const Argument&).Pure std only (no ExecuTorch, no flatbuffers), consistent with the rest of the
standalone
ptnruntime.Differential Revision: D114396764