Skip to content
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

[fx] make fx.wrap idempotent #104838

Closed
wants to merge 1 commit into from
Closed

[fx] make fx.wrap idempotent #104838

wants to merge 1 commit into from

Commits on Jul 9, 2023

  1. [fx] make fx.wrap idempotent

    Previously, if you called `torch.fx.wrap()` on the same thing twice, it
    would add two entries to `_wrapped_fns_to_patch`. Then, when tracing,
    the patcher would process them both. On the second entry, the patcher
    would double-wrap the fn (e.g. `wrap(wrap(orig_fn))`)
    
    This makes it so that wrapping is observable after the trace. While
    normally, a Patcher instance will "revert" the wrapping after tracing,
    the double wrapped function goes from `wrap(wrap(orig_fn)) -> wrap(orig_fn)`.
    
    This happens to work in normal fx stuff (after all, the wrapper function
    will behave exactly like the original function). But it upsets
    torch.package, which is not expecting to see a weird wrapper function in
    the graph.
    suo committed Jul 9, 2023
    Configuration menu
    Copy the full SHA
    9ffe96b View commit details
    Browse the repository at this point in the history