Commit Graph

61 Commits

Author SHA1 Message Date
Sherlock Huang
03e322c8d6 Switch fx.replace_pattern to use new SubgraphMatcher (#83717)
This is a duplicate of https://github.com/pytorch/pytorch/pull/82295
Pull Request resolved: https://github.com/pytorch/pytorch/pull/83717
Approved by: https://github.com/ezyang
2022-08-19 15:55:44 +00:00
anjali411
3bcc19b29a Add __all__ to various submodules in torch.fx, distributions, distributed, package (#80367)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80367
Approved by: https://github.com/albanD
2022-06-27 21:27:30 +00:00
thomasw21
191b48b12f [torch.fx] Fix replace pattern mechanism (#66442)
Summary:
Fixes #{issue number}

The following code would not return the pattern correctly:

```python
        def f(x):
            x = torch.sigmoid(x)
            x = torch.sigmoid(x)
            return torch.sigmoid(x)

        def pattern(x):
            return torch.sigmoid(x)

        def replacement(x):
            return torch.exp(x)

        def comparison(x):
            x = torch.exp(x)
            x = torch.exp(x)
            return torch.exp(x)

        traced = symbolic_trace(f)
        comparison_fn = symbolic_trace(comparison)

        subgraph_rewriter.replace_pattern(traced, pattern, replacement) # Only one sigmoid gets converted.
```

This PR fixes this by adding a new test.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/66442

Reviewed By: ZolotukhinM

Differential Revision: D32238424

Pulled By: ansley

fbshipit-source-id: 386e777174c639baafc166d5ffbc0658a96b1ee9
2021-11-07 13:23:02 -08:00
James Reed
538647fe1f [WIP][FX] BC guarantees for 1.10 (#63888)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63888

Test Plan: Imported from OSS

Reviewed By: pbelevich

Differential Revision: D30523133

Pulled By: jamesr66a

fbshipit-source-id: b04cc0d842a74862f42ecba98b757310cd2ec7b0
2021-08-30 19:56:46 -07:00
James Reed
7b73fdf597 [FX] Fix retracing wrapped functions (#58061)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/58061

Test Plan: Imported from OSS

Reviewed By: yuhc

Differential Revision: D28358801

Pulled By: jamesr66a

fbshipit-source-id: c7c9a8a80e5bfe1eb1f6d2cf858ac7e57153a860
2021-05-17 19:50:16 -07:00
Ansley Ussery
233f2cd29f Maintain submodule references during subgraph rewriting (#55463)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55463

Test Plan: Imported from OSS

Reviewed By: jamesr66a

Differential Revision: D27621650

Pulled By: ansley

fbshipit-source-id: e3558c64cdc2c1d846355fa58307a18c0714874b
2021-04-30 16:46:44 -07:00
Ansley Ussery
18e61d1ce9 Improve placeholder matching in subgraph rewriter (#54958)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54958

Test Plan: Imported from OSS

Reviewed By: jamesr66a

Differential Revision: D27431889

Pulled By: ansley

fbshipit-source-id: 8b1b4f2f0202305530b9648b6b770f9e2ecacfe2
2021-03-30 11:40:33 -07:00
Ansley Ussery
f2c4deabeb Extend subgraph_rewriter logic (#51532)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51532

- Change output of `replace_pattern` to `List[Match]` reflecting the
pattern(s) matched in the original graph
- Ensure that all Callables (not just FunctionType objects) work with
the rewriter
- Fix incorrect matching in degenerate case (`test_subgraph_rewriter_correct_output_replacement`)
- Verify that pattern matching works when pattern and original graph are
the same

Test Plan: Imported from OSS

Reviewed By: jamesr66a

Differential Revision: D26193082

Pulled By: ansley

fbshipit-source-id: 7f40c3862012a44adb88f403ade7afc37e50417f
2021-02-03 18:14:37 -08:00
Ansley Ussery
ab4623da16 Document FX debugging (#51530)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/51530

Test Plan: Imported from OSS

Reviewed By: jamesr66a

Differential Revision: D26192641

Pulled By: ansley

fbshipit-source-id: c69ab1bb2451d8ee5a729445f52bccc66e6f431b
2021-02-02 23:17:51 -08:00
Ansley Ussery
41e4c55379 Correct subgraph rewriter pattern containment rules (#51529)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/51529

Test Plan: Imported from OSS

Reviewed By: jamesr66a

Differential Revision: D26192470

Pulled By: ansley

fbshipit-source-id: 6e44f7df1e245835365ec868ae9cc539ecc873f2
2021-02-02 05:13:03 -08:00
Ansley Ussery
4c97ef8d77 Create subgraph rewriter (#49540)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/49540

Test Plan: Imported from OSS

Reviewed By: pbelevich

Differential Revision: D25869707

Pulled By: ansley

fbshipit-source-id: 93d3889f7ae2ecc5e8cdd7f4fb6b0446dbb3cb31
2021-01-12 16:32:13 -08:00