/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
torch
/
csrc
/
jit
/
passes
/
/usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/jit/passes
mkdir
upload
Name
Size
Mode
Actions
quantization/
-
0755
rm
utils/
-
0755
rm
annotate_warns.h
192
0644
edit
dl
rm
bailout_graph.h
1129
0644
edit
dl
rm
batch_mm.h
163
0644
edit
dl
rm
canonicalize.h
492
0644
edit
dl
rm
canonicalize_graph_fuser_ops.h
177
0644
edit
dl
rm
clear_profiling.h
334
0644
edit
dl
rm
clear_undefinedness.h
889
0644
edit
dl
rm
common_subexpression_elimination.h
194
0644
edit
dl
rm
concat_opt.h
481
0644
edit
dl
rm
constant_pooling.h
177
0644
edit
dl
rm
constant_propagation.h
1287
0644
edit
dl
rm
create_autodiff_subgraphs.h
552
0644
edit
dl
rm
create_functional_graphs.h
323
0644
edit
dl
rm
cuda_graph_fuser.h
860
0644
edit
dl
rm
dead_code_elimination.h
1584
0644
edit
dl
rm
decompose_ops.h
168
0644
edit
dl
rm
erase_number_types.h
813
0644
edit
dl
rm
fixup_trace_scope_blocks.h
1673
0644
edit
dl
rm
fold_conv_bn.h
995
0644
edit
dl
rm
freeze_module.h
1236
0644
edit
dl
rm
frozen_conv_add_relu_fusion.h
233
0644
edit
dl
rm
frozen_conv_folding.h
872
0644
edit
dl
rm
frozen_graph_optimizations.h
435
0644
edit
dl
rm
frozen_ops_to_mkldnn.h
414
0644
edit
dl
rm
fuse_linear.h
526
0644
edit
dl
rm
fuse_relu.h
273
0644
edit
dl
rm
graph_fuser.h
1251
0644
edit
dl
rm
graph_rewrite_helper.h
1785
0644
edit
dl
rm
guard_elimination.h
390
0644
edit
dl
rm
hoist_conv_packed_params.h
211
0644
edit
dl
rm
inliner.h
199
0644
edit
dl
rm
inline_autodiff_subgraphs.h
275
0644
edit
dl
rm
inline_forked_closures.h
241
0644
edit
dl
rm
inline_fork_wait.h
547
0644
edit
dl
rm
inplace_check.h
168
0644
edit
dl
rm
insert_guards.h
453
0644
edit
dl
rm
integer_value_refinement.h
234
0644
edit
dl
rm
lift_closures.h
236
0644
edit
dl
rm
liveness.h
663
0644
edit
dl
rm
loop_unrolling.h
1006
0644
edit
dl
rm
lower_grad_of.h
348
0644
edit
dl
rm
lower_graph.h
750
0644
edit
dl
rm
lower_tuples.h
666
0644
edit
dl
rm
metal_rewrite.h
606
0644
edit
dl
rm
normalize_ops.h
536
0644
edit
dl
rm
onnx.h
967
0644
edit
dl
rm
pass_manager.h
4635
0644
edit
dl
rm
peephole.h
507
0644
edit
dl
rm
peephole_alias_sensitive.h
355
0644
edit
dl
rm
peephole_dict_idioms.h
1000
0644
edit
dl
rm
peephole_list_idioms.h
2003
0644
edit
dl
rm
peephole_non_tensor.h
342
0644
edit
dl
rm
prepack_folding.h
358
0644
edit
dl
rm
remove_dropout.h
280
0644
edit
dl
rm
remove_exceptions.h
954
0644
edit
dl
rm
remove_expands.h
175
0644
edit
dl
rm
remove_inplace_ops.h
296
0644
edit
dl
rm
remove_mutation.h
2674
0644
edit
dl
rm
remove_redundant_profiles.h
196
0644
edit
dl
rm
requires_grad_analysis.h
260
0644
edit
dl
rm
restore_mutation.h
1887
0644
edit
dl
rm
shape_analysis.h
463
0644
edit
dl
rm
specialize_autogradzero.h
656
0644
edit
dl
rm
subgraph_rewrite.h
4112
0644
edit
dl
rm
symbolic_shape_analysis.h
641
0644
edit
dl
rm
tensorexpr_fuser.h
2077
0644
edit
dl
rm
update_differentiable_graph_requires_grad.h
740
0644
edit
dl
rm
value_refinement_utils.h
2669
0644
edit
dl
rm
variadic_ops.h
993
0644
edit
dl
rm
vulkan_rewrite.h
576
0644
edit
dl
rm
xnnpack_rewrite.h
917
0644
edit
dl
rm
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 <torch/csrc/jit/api/module.h> #include <torch/csrc/jit/ir/ir.h> #include <functional> #include <unordered_set> #include <vector> namespace torch { namespace jit { // Forward declarations. struct RewritePatternDescr; struct Match; using MatchFilter = std::function< bool(const Match&, const std::unordered_map<std::string, Value*>&)>; /** 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>& graph, const std::vector<MatchFilter>& filters); void runOnGraph( std::shared_ptr<Graph>& graph, const MatchFilter& filter = [](const Match&, const std::unordered_map<std::string, Value*>&) { return true; }) { runOnGraph(graph, std::vector<MatchFilter>({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<std::pair<std::string, std::string>>& value_name_pair = {}); private: std::vector<RewritePatternDescr> patterns_; std::unordered_set<Node*> nodes_to_delete_; void rewriteSinglePatternOnGraph( std::shared_ptr<Graph>& graph, const RewritePatternDescr& pattern, const std::vector<MatchFilter>& 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<std::string, std::string> value_name_map; }; } // namespace jit } // namespace torch
Save
cmd:
run