Add filter function to subgraph rewriter runGraph (#26223)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26223
add filter function to runGraph, if the function returns false for given `Match`,
the we'll skip the rewrite.
Test Plan:
will test in later PR that adds extra filtering on Constant nodes
Imported from OSS
Differential Revision: D17462529
fbshipit-source-id: 52abe52cb3e729a3871f7a60eddd5275060af36a