/usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/jit/passes
NameSizeModeActions
quantization/-0755rm
utils/-0755rm
annotate_warns.h1920644editdlrm
bailout_graph.h11290644editdlrm
batch_mm.h1630644editdlrm
canonicalize.h4920644editdlrm
canonicalize_graph_fuser_ops.h1770644editdlrm
clear_profiling.h3340644editdlrm
clear_undefinedness.h8890644editdlrm
common_subexpression_elimination.h1940644editdlrm
concat_opt.h4810644editdlrm
constant_pooling.h1770644editdlrm
constant_propagation.h12870644editdlrm
create_autodiff_subgraphs.h5520644editdlrm
create_functional_graphs.h3230644editdlrm
cuda_graph_fuser.h8600644editdlrm
dead_code_elimination.h15840644editdlrm
decompose_ops.h1680644editdlrm
erase_number_types.h8130644editdlrm
fixup_trace_scope_blocks.h16730644editdlrm
fold_conv_bn.h9950644editdlrm
freeze_module.h12360644editdlrm
frozen_conv_add_relu_fusion.h2330644editdlrm
frozen_conv_folding.h8720644editdlrm
frozen_graph_optimizations.h4350644editdlrm
frozen_ops_to_mkldnn.h4140644editdlrm
fuse_linear.h5260644editdlrm
fuse_relu.h2730644editdlrm
graph_fuser.h12510644editdlrm
graph_rewrite_helper.h17850644editdlrm
guard_elimination.h3900644editdlrm
hoist_conv_packed_params.h2110644editdlrm
inliner.h1990644editdlrm
inline_autodiff_subgraphs.h2750644editdlrm
inline_forked_closures.h2410644editdlrm
inline_fork_wait.h5470644editdlrm
inplace_check.h1680644editdlrm
insert_guards.h4530644editdlrm
integer_value_refinement.h2340644editdlrm
lift_closures.h2360644editdlrm
liveness.h6630644editdlrm
loop_unrolling.h10060644editdlrm
lower_grad_of.h3480644editdlrm
lower_graph.h7500644editdlrm
lower_tuples.h6660644editdlrm
metal_rewrite.h6060644editdlrm
normalize_ops.h5360644editdlrm
onnx.h9670644editdlrm
pass_manager.h46350644editdlrm
peephole.h5070644editdlrm
peephole_alias_sensitive.h3550644editdlrm
peephole_dict_idioms.h10000644editdlrm
peephole_list_idioms.h20030644editdlrm
peephole_non_tensor.h3420644editdlrm
prepack_folding.h3580644editdlrm
remove_dropout.h2800644editdlrm
remove_exceptions.h9540644editdlrm
remove_expands.h1750644editdlrm
remove_inplace_ops.h2960644editdlrm
remove_mutation.h26740644editdlrm
remove_redundant_profiles.h1960644editdlrm
requires_grad_analysis.h2600644editdlrm
restore_mutation.h18870644editdlrm
shape_analysis.h4630644editdlrm
specialize_autogradzero.h6560644editdlrm
subgraph_rewrite.h41120644editdlrm
symbolic_shape_analysis.h6410644editdlrm
tensorexpr_fuser.h20770644editdlrm
update_differentiable_graph_requires_grad.h7400644editdlrm
value_refinement_utils.h26690644editdlrm
variadic_ops.h9930644editdlrm
vulkan_rewrite.h5760644editdlrm
xnnpack_rewrite.h9170644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/jit/passes/subgraph_rewrite.h (4112B)
/** This file defines API for pattern-based subgraph rewrites. * * The API can be used for finding concrete patterns in the model and replacing * the corresponding subgraphs with another subgraph. A special case of such * rewrites is fusion, where the new subgraph consists of just a single node. * * There is a default set of the most common patterns that everyone could use. * Alternatively, an arbitrary pattern can be registered. */ #pragma once #include #include #include #include #include namespace torch { namespace jit { // Forward declarations. struct RewritePatternDescr; struct Match; using MatchFilter = std::function< bool(const Match&, const std::unordered_map&)>; /** Run pattern-based subgraph rewrites on all methods in the module. * * This pass will go through all methods in the module and try to replace all * recognized patterns (see SubgraphRewriter::RegisterDefaultPatterns for the * list of these patterns). */ TORCH_API Module PatternBasedRewrite(const Module& module); /** A class implementing API for pattern-based subgraph rewrites. * * To perform pattern-based subgraph rewrites on a module using this API, one * needs to create an object of such class, register rewrite patterns and run * the transformation pass (`runOnModule`). * * To use standard patterns, one could use `RegisterDefaultPatterns`. * * To enable rewrites of custom patterns, the custom patterns must be registered * with `RegisterRewritePattern`. */ class TORCH_API SubgraphRewriter { public: // Run pattern-based subgraph rewrite pass on the module. Module runOnModule(const Module& module); // Run pattern-based subgraph rewrite pass on the graph (used in testing). // `filter` is a function that does extra filtering on the match. If it // returns false for a given Match, we'll skip the Match. The filter // function's arguments consist of a Match and a value map from parsing the // pattern graph. Both the Match and the value map are necessary because we // need to 1) do extra filtering on the matched result as well as 2) refer to // the values in the matched result through the values in the pattern graph. void runOnGraph( std::shared_ptr& graph, const std::vector& filters); void runOnGraph( std::shared_ptr& graph, const MatchFilter& filter = [](const Match&, const std::unordered_map&) { return true; }) { runOnGraph(graph, std::vector({filter})); } // Register standard rewrite patterns. void RegisterDefaultPatterns(); /** Register a custom rewrite pattern. * * The method takes two parameters specifying the pattern: * \p PATTERN - IR string representing the pattern subgraph. * \p REPLACEMENT - IR string representing the replacement subgraph. * \p value name map - vector of pairs mapping values in the replacement graph * to the values in the pattern graph. Used for preserving source range info * across graph rewrite. * * See examples of pattern registering in `RegisterDefaultPatterns`. */ void RegisterRewritePattern( const std::string& pattern, const std::string& replacement, const std::vector>& value_name_pair = {}); private: std::vector patterns_; std::unordered_set nodes_to_delete_; void rewriteSinglePatternOnGraph( std::shared_ptr& graph, const RewritePatternDescr& pattern, const std::vector& filters); bool overlapsWithPreviousMatches(const Match* match); }; /** Rewrite pattern descriptor. * * This structure is used in the implementation of `SubgraphRewriter` and * is not supposed to be used externally. */ struct RewritePatternDescr { std::string pattern; std::string replacement; std::unordered_map value_name_map; }; } // namespace jit } // namespace torch