[fx-acc] PassManager (#67261)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/67261
Adds a `Pass(callable)`, `PassManager`, `PassConstraint(callable)`, `PassManagerBuilder`.
The idea is that a `Pass` modifies an IR in-place. `PassConstraint`s define a partial ordering on `Pass`s as a less than callable. `PassManager` manages the collection of `Pass`s, `PassConstraint`s and ensures validation before execution. `PassManagerBuilder` creates `PassManager`s (example usage in follow-up diff).
These are very loosely typed, so could be applied to different IRs as well as transformation between IRs.
Test Plan:
```
buck test mode/opt //caffe2/torch/fx/passes:test_pass_manager
```
```
ore details at https://www.internalfb.com/intern/buck/build/210
BUILD SUCCEEDED
Tpx test run coordinator for Facebook. See https://fburl.com/tpx for details.
Running with tpx session id: c635415b-cdc4-4574-9739-a16d2b93ad3a
Trace available for this run at /tmp/tpx-20220203-114748.608700/trace.log
RemoteExecution session id: reSessionID-c635415b-cdc4-4574-9739-a16d2b93ad3a-tpx
Started reporting to test run: https://www.internalfb.com/intern/testinfra/testrun/1970324927640328
✓ ListingSuccess: caffe2/torch/fx/passes:test_pass_manager : 3 tests discovered (0.332)
✓ Pass: caffe2/torch/fx/passes:test_pass_manager - test_this_before_that_pass_constraint (caffe2.torch.fx.passes.tests.test_pass_manager.TestPassManager) (0.232)
✓ Pass: caffe2/torch/fx/passes:test_pass_manager - test_these_before_those_pass_constraint (caffe2.torch.fx.passes.tests.test_pass_manager.TestPassManager) (0.231)
✓ Pass: caffe2/torch/fx/passes:test_pass_manager - test_pass_manager_builder (caffe2.torch.fx.passes.tests.test_pass_manager.TestPassManager) (0.231)
Summary
Pass: 3
ListingSuccess: 1
If you need help understanding your runs, please follow the wiki: https://fburl.com/posting_in_tpx_users
Finished test run: https://www.internalfb.com/intern/testinfra/testrun/1970324927640328
```
Reviewed By: jfix71, kflu
Differential Revision: D31316086
fbshipit-source-id: 4302c39e221cfa43e2b2eda9f26d6d78da4db0f1
(cherry picked from commit 13c981ab0055d89fc8c3a691266e2555dfce7211)