Skip to content

Update how we input kwargs #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exir/capture/_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def capture( # noqa: C901
# input spec, but due to some limitations in pytree implementation, it doesn't
# recognize the make_fx graph with torchdynamo input spec. We workaround it
# by getting the input spec directly from user argument.
in_spec = pytree.tree_flatten(args)[1]
in_spec = pytree.tree_flatten((args, {}))[1]

if config.enable_functionalization and not config.enable_aot:
args = copy.deepcopy(args)
Expand Down
3 changes: 2 additions & 1 deletion exir/emit/test/test_emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def f(x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, List[torch.Tensor]]:
)

self.assertEqual(
program.execution_plan[0].container_meta_type.encoded_inp_str, "T1#1($)"
program.execution_plan[0].container_meta_type.encoded_inp_str,
"T2#1#0(T1#1($),D0())",
)

def test_buffers_with_perfect_alignment(self) -> None:
Expand Down
3 changes: 1 addition & 2 deletions exir/program/_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ def __init__(

def __call__(self, *args: Any, **kwargs: Any) -> Any:
import torch._export.error as error
from torch._export import combine_args_kwargs

if self.call_spec.in_spec is not None:
user_args = combine_args_kwargs(args, kwargs)
user_args = args
try:
args = fx_pytree.tree_flatten_spec(user_args, self.call_spec.in_spec) # type: ignore[assignment]
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion exir/tests/fixtures/basic_sin_max.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "forward",
"container_meta_type": {
"encoded_inp_str": "T1#1($)",
"encoded_inp_str": "T2#1#0(T1#1($),D0())",
"encoded_out_str": "$"
},
"values": [
Expand Down
2 changes: 1 addition & 1 deletion exir/tests/fixtures/composite_delegate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "forward",
"container_meta_type": {
"encoded_inp_str": "T3#1#1#1($,$,$)",
"encoded_inp_str": "T2#3#0(T3#1#1#1($,$,$),D0())",
"encoded_out_str": "$"
},
"values": [
Expand Down
2 changes: 1 addition & 1 deletion exir/verification/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def run(self, *raw_args: torch.Tensor) -> PyTree:
"""

# pyre-fixme[16]: Module `pytree` has no attribute `tree_flatten`.
args, pytree = ex_pytree.tree_flatten(raw_args)
args, pytree = ex_pytree.tree_flatten((raw_args, {}))

if pytree.to_str() != self.container_metatype.encoded_inp_str:
raise TypeError(
Expand Down