torch.fx.subgraph_rewriter.replace_pattern_with_filters#
- torch.fx.subgraph_rewriter.replace_pattern_with_filters(gm, pattern, replacement=None, match_filters=None, ignore_literals=False, replacement_callback=None, node_name_match='')[source]#
See replace_pattern for documentation. This function is an overload with an additional match_filter argument.
- Parameters:
match_filters (list[Callable[[InternalMatch, Graph, Graph], bool]] | None) – A list of functions that take in (match: InternalMatch, original_graph: Graph, pattern_graph: Graph) and return a boolean indicating whether the match satisfies the condition. See matcher_utils.py for definition of InternalMatch.
replacement_callback (Callable[[InternalMatch, Graph, Graph], Graph] | None) – A function that takes in a match and returns a Graph to be used as the replacement. This allows you to construct a replacement graph based on the match.
node_name_match (str) – Node name to match. If not empty, it will try to match the node name.
- Return type:
list[ReplacedPatterns]
Warning
This API is experimental and is NOT backward-compatible.