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