jasonfan commited on
Commit
b1e8716
·
verified ·
1 Parent(s): d7fe2a7

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/clear_undefinedness.h +27 -0
  2. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/common_subexpression_elimination.h +14 -0
  3. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/concat_opt.h +22 -0
  4. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/constant_pooling.h +14 -0
  5. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/constant_propagation.h +35 -0
  6. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/create_autodiff_subgraphs.h +22 -0
  7. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/create_functional_graphs.h +17 -0
  8. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/dbr_quantization/remove_redundant_aliases.h +24 -0
  9. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/dead_code_elimination.h +45 -0
  10. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/decompose_ops.h +14 -0
  11. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/device_type_analysis.h +16 -0
  12. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/dtype_analysis.h +20 -0
  13. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/eliminate_no_ops.h +20 -0
  14. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/erase_number_types.h +26 -0
  15. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fixup_trace_scope_blocks.h +50 -0
  16. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fold_conv_bn.h +40 -0
  17. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fold_linear_bn.h +32 -0
  18. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/freeze_module.h +39 -0
  19. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_concat_linear.h +16 -0
  20. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_conv_add_relu_fusion.h +18 -0
  21. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_conv_folding.h +27 -0
  22. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_graph_optimizations.h +25 -0
  23. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_linear_folding.h +17 -0
  24. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_linear_transpose.h +16 -0
  25. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_ops_to_mkldnn.h +18 -0
  26. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fuse_linear.h +27 -0
  27. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fuse_relu.h +14 -0
  28. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/graph_fuser.h +40 -0
  29. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/graph_rewrite_helper.h +55 -0
  30. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/guard_elimination.h +22 -0
  31. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/hoist_conv_packed_params.h +15 -0
  32. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inline_autodiff_subgraphs.h +18 -0
  33. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inline_fork_wait.h +19 -0
  34. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inline_forked_closures.h +15 -0
  35. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inliner.h +17 -0
  36. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inplace_check.h +14 -0
  37. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/insert_guards.h +24 -0
  38. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/integer_value_refinement.h +15 -0
  39. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/lift_closures.h +15 -0
  40. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/liveness.h +27 -0
  41. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/loop_unrolling.h +39 -0
  42. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/lower_grad_of.h +20 -0
  43. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/lower_graph.h +25 -0
  44. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/lower_tuples.h +23 -0
  45. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/metal_rewrite.h +20 -0
  46. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/mkldnn_rewrite.h +37 -0
  47. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/mobile_optimizer_type.h +18 -0
  48. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/normalize_ops.h +21 -0
  49. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/onednn_graph_fuser.h +66 -0
  50. miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/onnx.h +33 -0
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/clear_undefinedness.h ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <ATen/ATen.h>
5
+ #include <ATen/core/ivalue.h>
6
+ #include <ATen/core/jit_type.h>
7
+ #include <torch/csrc/Export.h>
8
+ #include <torch/csrc/jit/ir/ir.h>
9
+
10
+ namespace torch::jit {
11
+
12
+ // Undefinedness makes argument matching fail for regular tensor operations
13
+ // if 1+ arguments are undefined or possibly undefined tensors.
14
+ // Technically, undefined tensors are **not** tensors as the regular tensor
15
+ // operations do not know how to handle them.
16
+ // However, in practice, there are guards and conversion operators that
17
+ // **always** gate regular operations if undefined tensors may be present
18
+ // Eventually, we would love to move to the world where we use optionals
19
+ // in lieu of undefined tensors.
20
+ // When this happens, this pass will be removed
21
+ TORCH_API void ClearUndefinedness(const std::shared_ptr<Graph>& graph);
22
+
23
+ } // namespace torch::jit
24
+
25
+ #else
26
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
27
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/common_subexpression_elimination.h ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ TORCH_API bool EliminateCommonSubexpression(
9
+ const std::shared_ptr<Graph>& graph);
10
+ }
11
+
12
+ #else
13
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
14
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/concat_opt.h ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Eliminates common inputs among `aten::cat` ops.
9
+ TORCH_API bool EliminateConcatCommonInputs(const std::shared_ptr<Graph>& graph);
10
+
11
+ // Expands `aten::cat` ops into `aten::copy` ops and eliminates redudancies
12
+ // in the buffers used for concatenation if possible.
13
+ TORCH_API void ExpandConcatAndEliminateRedundancy(
14
+ const std::shared_ptr<Graph>& graph);
15
+
16
+ TORCH_API bool CombineConcats(const std::shared_ptr<Graph>& graph);
17
+
18
+ } // namespace torch::jit
19
+
20
+ #else
21
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
22
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/constant_pooling.h ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ TORCH_API void ConstantPooling(const std::shared_ptr<Graph>& graph);
9
+
10
+ }
11
+
12
+ #else
13
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
14
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/constant_propagation.h ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Runs constant propagation on all objects unless ignore_custom_classes is
9
+ // specified as true, in which case user defined classes are skipped. This is
10
+ // useful to prevent early fusion of packing operations, which end up lowering
11
+ // away information about their constructors (e.g. packed::linear_clamp_prepack
12
+ // and prepacked::conv2d_clamp_prepack)
13
+ // Returns True if the pass made a change to the graph
14
+ TORCH_API bool ConstantPropagation(
15
+ std::shared_ptr<Graph>& graph,
16
+ bool ignore_custom_classes = false);
17
+
18
+ // runs constant propagation only on ops that have non-aliasing inputs & outputs
19
+ // Returns True if the pass made a change to the graph
20
+ TORCH_API bool ConstantPropagationImmutableTypes(std::shared_ptr<Graph>& graph);
21
+
22
+ // Runs the node if its inputs are constants. Callers of this function must
23
+ // make their own determination if constant prop is appropriate - for example
24
+ // non-deterministic ops or ops with side effects. If ignore_custom_classes is
25
+ // specified, nodes that output user defined classes are not run.
26
+ TORCH_API std::optional<Stack> runNodeIfInputsAreConstant(
27
+ const Node* node,
28
+ bool ignore_custom_classes = false,
29
+ AliasDb* db = nullptr);
30
+
31
+ } // namespace torch::jit
32
+
33
+ #else
34
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
35
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/create_autodiff_subgraphs.h ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/Export.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+
7
+ #include <cstddef>
8
+
9
+ namespace torch::jit {
10
+
11
+ // insert GraphExecutor nodes that group together
12
+ // subgraphs that are differentiable by the jit's autodiff passes
13
+ // threshold - minimum number of nodes that will appear in a block
14
+ // returns all differentiable blocks that have been found
15
+ TORCH_API std::vector<Node*> CreateAutodiffSubgraphs(
16
+ const std::shared_ptr<Graph>& graph,
17
+ size_t threshold = 2);
18
+ } // namespace torch::jit
19
+
20
+ #else
21
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
22
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/create_functional_graphs.h ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/Export.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+
7
+ namespace torch::jit {
8
+
9
+ TORCH_API void CreateFunctionalGraphs(const std::shared_ptr<Graph>& graph);
10
+
11
+ TORCH_API void InlineFunctionalGraphs(const std::shared_ptr<Graph>& graph);
12
+
13
+ } // namespace torch::jit
14
+
15
+ #else
16
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
17
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/dbr_quantization/remove_redundant_aliases.h ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/api/module.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // This function replaces instances of
9
+ //
10
+ // %b = aten::alias(%a)
11
+ // %c = foo(%b)
12
+ //
13
+ // with
14
+ //
15
+ // %c = foo(%a)
16
+ //
17
+ // on the module forward, if it's safe to do so.
18
+ TORCH_API Module DBRQuantRemoveRedundantAliases(Module& module);
19
+
20
+ } // namespace torch::jit
21
+
22
+ #else
23
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
24
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/dead_code_elimination.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // If given a top-level graph, DCE will construct do alias analysis that allows
9
+ // for "smarter" dead code elimination (we will eliminate mutable ops if we can
10
+ // prove the mutated values are not used). Otherwise, we will not allow DCE to
11
+ // eliminate mutable ops.
12
+ //
13
+ // So, prefer to use the graph version if you can.
14
+ enum class DCESideEffectPolicy : uint8_t {
15
+ // default behavior: dead code elimination will check if a node has side
16
+ // effects
17
+ // and not delete it if it does.
18
+ DONT_DELETE_NODES_WITH_SIDE_EFFECTS,
19
+ // with this flag, dead code elimination will not check if a node has side
20
+ // effects and treat nodes with side effects like any other node,
21
+ // i.e. delete them if their outputs aren't used anywhere.
22
+ ALLOW_DELETING_NODES_WITH_SIDE_EFFECTS
23
+ };
24
+
25
+ TORCH_API void EliminateDeadCode(
26
+ const std::shared_ptr<Graph>& graph,
27
+ DCESideEffectPolicy sideEffectPolicy =
28
+ DCESideEffectPolicy::DONT_DELETE_NODES_WITH_SIDE_EFFECTS);
29
+ TORCH_API void EliminateDeadCode(
30
+ Block* block,
31
+ bool recurse = true,
32
+ DCESideEffectPolicy sideEffectPolicy =
33
+ DCESideEffectPolicy::DONT_DELETE_NODES_WITH_SIDE_EFFECTS);
34
+
35
+ // Invoke the user-provided callback on all live values before deleting anything
36
+ TORCH_API void EliminateDeadCode(
37
+ Block* block,
38
+ std::function<void(const std::unordered_set<const Value*>&)> cb,
39
+ DCESideEffectPolicy sideEffectPolicy =
40
+ DCESideEffectPolicy::DONT_DELETE_NODES_WITH_SIDE_EFFECTS);
41
+ } // namespace torch::jit
42
+
43
+ #else
44
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
45
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/decompose_ops.h ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ TORCH_API void DecomposeOps(std::shared_ptr<Graph>& graph);
9
+
10
+ }
11
+
12
+ #else
13
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
14
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/device_type_analysis.h ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+ struct Graph;
8
+
9
+ // Propagates Device type info throughout the given graph.
10
+ TORCH_API bool DeviceTypePropagation(std::shared_ptr<Graph>& graph);
11
+
12
+ } // namespace torch::jit
13
+
14
+ #else
15
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
16
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/dtype_analysis.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/Export.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+ #include <memory>
7
+
8
+ namespace torch::jit {
9
+ struct Graph;
10
+
11
+ // Propagate tensor properties (e.g., dtype, device, is_contiguous, layout)
12
+ // propagation on all tensor objects. Currently, we only support dtype
13
+ // propagation
14
+ TORCH_API bool DtypePropagation(std::shared_ptr<Graph>& graph);
15
+
16
+ } // namespace torch::jit
17
+
18
+ #else
19
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
20
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/eliminate_no_ops.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Remove ops that do nothing on the forward pass (like aten::detach).
9
+ // This pass is invoked as a part of freeze_module.
10
+ // This function also takes a set of custom ops to eliminate. All ops in this
11
+ // set must take their output as their first input, i.e. x = f(x, ...)
12
+ TORCH_API bool EliminateNoOps(
13
+ std::shared_ptr<Graph>& graph,
14
+ std::unordered_set<c10::Symbol> custom_ops = {});
15
+
16
+ } // namespace torch::jit
17
+
18
+ #else
19
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
20
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/erase_number_types.h ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Erase NumberType information. This is necessary for and only used in
9
+ // exporting to ONNX. This pass ensures that no remaining Values have
10
+ // NumberType types, replacing them with tensors.
11
+ // The following things are done to erase NumberType info:
12
+ // - NumberType outputs are changed to DynamicType.
13
+ // - prim::Constant nodes which are numbers get changed into 0-dim tensors of
14
+ // the corresponding type
15
+ // - prim::TensorToNum, aten::Float, aten::Int and prim::NumToTensor nodes
16
+ // are erased.
17
+ //
18
+ // The pass assumes that DCE will be called sometime after.
19
+ TORCH_API void EraseNumberTypes(const std::shared_ptr<Graph>& graph);
20
+ TORCH_API void EraseNumberTypesOnBlock(Block* block);
21
+
22
+ } // namespace torch::jit
23
+
24
+ #else
25
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
26
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fixup_trace_scope_blocks.h ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/api/module.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+
7
+ namespace torch::jit {
8
+
9
+ // Directly after tracing, we have an ill-formed graph with blocks inserted.
10
+ // Example:
11
+ //
12
+ // graph(%self : ClassType<Module>,
13
+ // %input.1 : Float(3, 4)):
14
+ // %1 : ClassType<Module> = prim::GetAttr[name="relu1"](%self)
15
+ // %2 : ClassType<Module> = prim::GetAttr[name="relu2"](%self)
16
+ // %3 : ClassType<Module> = prim::GetAttr[name="rrr"](%2)
17
+ // = prim::TracedModuleForward[scope="__module.relu1"]()
18
+ // block0():
19
+ // %input : Float(3, 4) = aten::relu(%input.1),
20
+ // -> ()
21
+ // = prim::TracedModuleForward[scope="__module.relu2"](),
22
+ // block0():
23
+ // = prim::TracedModuleForward[scope="__module.relu2.rrr"](),
24
+ // block0():
25
+ // %6 : Float(3, 4) = aten::relu(%input),
26
+ // -> ()
27
+ // -> ()
28
+ // return (%6)
29
+ //
30
+ // In this pass, we:
31
+ // 1) Lift Value defs to as high of a scope as needed to ensure that
32
+ // they dominate all their uses. For example, `input` in the above
33
+ // graph needs to be lifted to the top-level block so that its use
34
+ // in the second `relu` operator is dominated.
35
+ // 2) Lambda lift the blocks. This ensures that all values used within
36
+ // each scope have their defs captured.
37
+ // 3) Convert the scope blocks into methods on their respective Modules,
38
+ // and convert TracedModuleForward nodes to CallMethod nodes into those
39
+ // methods.
40
+ //
41
+ // Then, we'll have a well-formed graph with proper method calls.
42
+ TORCH_API void FixupTraceScopeBlocks(
43
+ std::shared_ptr<Graph>& graph,
44
+ Module* self);
45
+
46
+ } // namespace torch::jit
47
+
48
+ #else
49
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
50
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fold_conv_bn.h ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/api/module.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ /** \brief Fold Conv2d-BatchNorm2d into Conv2d in all methods of this
9
+ * module and all its submodules, forward is included by default.
10
+ *
11
+ * The weight and bias of the Conv2d are correspondingly updated. Should only be
12
+ * used on modules in eval mode.
13
+ */
14
+ TORCH_API Module FoldConvBatchNorm(const Module& module);
15
+
16
+ struct TORCH_API ConvBNParameters {
17
+ at::Tensor conv_w;
18
+ at::Tensor conv_b;
19
+ at::Tensor bn_rm;
20
+ at::Tensor bn_rv;
21
+ double bn_eps = 0.0;
22
+ at::Tensor bn_w;
23
+ at::Tensor bn_b;
24
+ };
25
+
26
+ /**
27
+ * Given the current weight and bias tensors of a Conv module and parameters
28
+ * of the BatchNorm module we're folding with, compute the updated values
29
+ * for the weight and bias.
30
+ *
31
+ * The function is basically copied from torch/nn/utils/fusion.py
32
+ */
33
+ TORCH_API std::tuple<at::Tensor, at::Tensor> computeUpdatedConvWeightAndBias(
34
+ const ConvBNParameters& p);
35
+
36
+ } // namespace torch::jit
37
+
38
+ #else
39
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
40
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fold_linear_bn.h ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/api/module.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ struct TORCH_API LinearBNParameters {
9
+ at::Tensor linear_w;
10
+ at::Tensor linear_b;
11
+ at::Tensor bn_rm;
12
+ at::Tensor bn_rv;
13
+ double bn_eps = 0.0;
14
+ at::Tensor bn_w;
15
+ at::Tensor bn_b;
16
+ };
17
+
18
+ /**
19
+ * Given the current weight and bias tensors of a Linear module and parameters
20
+ * of the BatchNorm module we're folding with, compute the updated values
21
+ * for the weight and bias.
22
+ *
23
+ * The function is basically copied from torch/nn/utils/fusion.py
24
+ */
25
+ TORCH_API std::tuple<at::Tensor, at::Tensor> computeUpdatedLinearWeightAndBias(
26
+ const LinearBNParameters& p);
27
+
28
+ } // namespace torch::jit
29
+
30
+ #else
31
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
32
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/freeze_module.h ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /** \brief This file defines freezing Torchscript module API.
3
+ *
4
+ * This API has python-binding and can be invoked directly or as a part of
5
+ * general optimization pipeline.
6
+ */
7
+ #pragma once
8
+
9
+ #include <torch/csrc/jit/api/module.h>
10
+ #include <torch/csrc/jit/ir/ir.h>
11
+
12
+ /** \brief Freeze Module, i.e., Assume all attributes are constants.
13
+ *
14
+ * Freezing module is a functionality that allows the JIT to internalize
15
+ * immutable attributes. Combined with inlining, the module is aggressively
16
+ * optimized and significant overhead is optimized away. The freezeModule API
17
+ * produces a cloned frozen module.
18
+ */
19
+
20
+ namespace torch::jit {
21
+
22
+ TORCH_API Module freeze_module(
23
+ const Module& module,
24
+ std::vector<std::string> preservedAttrs = std::vector<std::string>(),
25
+ bool freezeInterfaces = true,
26
+ bool preserveParameters = false);
27
+
28
+ // Clone-free version of freeze_module. This modifies the module inplace.
29
+ // Use this version to avoid extra memory usage incurred by cloning the module.
30
+ TORCH_API void freeze_module_inplace(
31
+ Module* module,
32
+ std::vector<std::string> preservedAttrs = std::vector<std::string>(),
33
+ bool freezeInterfaces = true,
34
+ bool preserveParameters = false);
35
+ } // namespace torch::jit
36
+
37
+ #else
38
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
39
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_concat_linear.h ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Concats multiple linear ops with the same Tensor input
9
+ // into a single linear op.
10
+ TORCH_API bool FrozenConcatLinear(std::shared_ptr<Graph>& graph);
11
+
12
+ } // namespace torch::jit
13
+
14
+ #else
15
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
16
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_conv_add_relu_fusion.h ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/api/module.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+
7
+ namespace torch::jit {
8
+
9
+ TORCH_API extern std::function<void(std::shared_ptr<Graph>&)>&
10
+ getFuseFrozenConvAddReluImpl();
11
+
12
+ TORCH_API void FuseFrozenConvAddRelu(std::shared_ptr<Graph>& graph);
13
+
14
+ } // namespace torch::jit
15
+
16
+ #else
17
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
18
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_conv_folding.h ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Fuses Convolution -> Batchnorm into a single Convolution by
9
+ // folding batchnorm weights into conv weights.
10
+ // This pass only works on Frozen Graphs; otherwise it is a No-Op.
11
+ TORCH_API bool FoldFrozenConvBatchnorm(std::shared_ptr<Graph>& graph);
12
+
13
+ // Fuses Convolution -> Add/Sub into a single Convolution by
14
+ // folding add constant tensor into conv weights.
15
+ // This pass only works on Frozen Graphs; otherwise it is a No-Op.
16
+ TORCH_API bool FoldFrozenConvAddOrSub(std::shared_ptr<Graph>& graph);
17
+
18
+ // Fuses Convolution -> Mul/Div into a single Convolution by
19
+ // folding add constant tensor into conv weights.
20
+ // This pass only works on Frozen Graphs; otherwise it is a No-Op.
21
+ TORCH_API bool FoldFrozenConvMulOrDiv(std::shared_ptr<Graph>& graph);
22
+
23
+ } // namespace torch::jit
24
+
25
+ #else
26
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
27
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_graph_optimizations.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ /** \brief Runs a set of Optimizations that Optimize Frozen Graphs
7
+ *
8
+ * Currently this set of optimizations is:
9
+ * - FoldFrozenConvBatchnorm
10
+ * - FoldFrozenConvAddOrSub
11
+ * - FoldFrozenConvMulOrDiv
12
+ * - FoldFrozenLinearBatchnorm
13
+ */
14
+
15
+ namespace torch::jit {
16
+
17
+ TORCH_API void OptimizeFrozenGraph(
18
+ std::shared_ptr<Graph>& graph,
19
+ bool optimize_numerics = true);
20
+
21
+ } // namespace torch::jit
22
+
23
+ #else
24
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
25
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_linear_folding.h ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Fuses Linear -> BatchNormNd into a single Linear by
9
+ // folding batchnorm weights into linear weights.
10
+ // This pass only works on Frozen Graphs; otherwise it is a No-Op.
11
+ TORCH_API bool FoldFrozenLinearBatchnorm(std::shared_ptr<Graph>& graph);
12
+
13
+ } // namespace torch::jit
14
+
15
+ #else
16
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
17
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_linear_transpose.h ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Transposes the weight matrix for frozen linear modules.
9
+ // and converts it into a matmul
10
+ TORCH_API bool FrozenLinearTranspose(std::shared_ptr<Graph>& graph);
11
+
12
+ } // namespace torch::jit
13
+
14
+ #else
15
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
16
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/frozen_ops_to_mkldnn.h ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Converts operators & their parameters to mkldnn if it is profitable
9
+ // Currently encompassing Conv2d and Conv3d, and Linear
10
+ // Op must be in float32 and mkldnn must be built
11
+ // This pass only works on frozen graph
12
+ TORCH_API void ConvertFrozenOpsToMKLDNN(std::shared_ptr<Graph>& graph);
13
+
14
+ } // namespace torch::jit
15
+
16
+ #else
17
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
18
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fuse_linear.h ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ /** \brief Fusing linear patterns as single at::linear for easier pattern
3
+ * matching in later passes
4
+ */
5
+ #pragma once
6
+
7
+ #include <torch/csrc/jit/ir/ir.h>
8
+
9
+ namespace torch::jit {
10
+
11
+ /** \brief Match the at::linear pattern and fuse it into a single at::linear
12
+ * This pass fuse the addmm or matmul + add generated by JIT back to linear
13
+ * This pass can be deleted once the JIT can emit the aten::linear in the future
14
+ */
15
+ TORCH_API void FuseLinear(std::shared_ptr<Graph>& graph);
16
+
17
+ /** Swap functional linear CallFunctions to aten::linear
18
+ */
19
+ TORCH_API void SwapFunctionalLinear(std::shared_ptr<Graph>& graph);
20
+ /** Swap all functional linear CallFunctions in module
21
+ */
22
+ TORCH_API void SwapFunctionalLinear(Module& module);
23
+ } // namespace torch::jit
24
+
25
+ #else
26
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
27
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/fuse_relu.h ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/api/module.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+
7
+ namespace torch::jit {
8
+ TORCH_API void FuseAddRelu(script::Module& module);
9
+ TORCH_API void FuseAddRelu(std::shared_ptr<Graph>& graph);
10
+ } // namespace torch::jit
11
+
12
+ #else
13
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
14
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/graph_fuser.h ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ TORCH_API bool canFuseOnCPULegacy();
9
+ TORCH_API void overrideCanFuseOnCPULegacy(bool value);
10
+
11
+ // NB: Be sure to run DCE before fusion, because dead instructions
12
+ // can prevent fusion opportunities from being exploited.
13
+ // On Windows will noop, NYI
14
+ TORCH_API void FuseGraph(
15
+ std::shared_ptr<Graph>& graph,
16
+ bool strict_fuser_check = false);
17
+
18
+ // \brief Custom fusion pass using a node-level callback to
19
+ // determine the inclusion of nodes in a subgraph.
20
+ //
21
+ // This helper omits aliased inputs and fusion across control flow
22
+ // boundaries.
23
+ //
24
+ // \arg graph The graph to be modified in-place
25
+ // \arg is_fusable A callback run on each fusable node in the graph.
26
+ // \arg kind The label given to the resultant fused subgraph
27
+ // \arg arg_limit The maximum number of args the resultant fused subgraph
28
+ // should have. Note: This will likely develop into a general
29
+ // post condition on the fused subgraph.
30
+ TORCH_API void CustomFuseGraph(
31
+ std::shared_ptr<Graph>& graph,
32
+ const std::function<bool(Node*)>& is_fusable,
33
+ Symbol kind,
34
+ size_t arg_limit = std::numeric_limits<size_t>::max());
35
+
36
+ } // namespace torch::jit
37
+
38
+ #else
39
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
40
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/graph_rewrite_helper.h ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+ #include <torch/csrc/jit/ir/irparser.h>
6
+ #include <torch/csrc/jit/ir/subgraph_matcher.h>
7
+ #include <torch/csrc/jit/passes/subgraph_rewrite.h>
8
+
9
+ namespace torch::jit::graph_rewrite_helper {
10
+
11
+ std::string getFuncName(Value* func_value);
12
+ Value* getValue(
13
+ const std::string& name,
14
+ const std::unordered_map<const Value*, Value*>& match_vmap,
15
+ const std::unordered_map<std::string, Value*>& vmap);
16
+ std::optional<IValue> getIValue(
17
+ const std::string& name,
18
+ const std::unordered_map<const Value*, Value*>& match_vmap,
19
+ const std::unordered_map<std::string, Value*>& vmap);
20
+ TORCH_API void replaceConvolutionWithAtenConv(std::shared_ptr<Graph>& graph);
21
+
22
+ bool isClampFusable(
23
+ const Match& match,
24
+ const std::unordered_map<std::string, Value*>& vmap);
25
+
26
+ // This struct contains a compiled IR patterns slated for use in the
27
+ // findPatternMatches function. The struct encapsulates the common
28
+ // information from parseIR that is used in conjunction with the
29
+ // pattern matching facility. A const instance of this struct can
30
+ // also be stored away to cache the compiled IR pattern and reduce
31
+ // runtime cost
32
+ struct PatternInfo {
33
+ std::string pattern_string;
34
+ std::unique_ptr<Graph> pattern_graph;
35
+ std::unordered_map<std::string, Value*> vmap;
36
+ std::vector<MatchFilter> filters;
37
+
38
+ static PatternInfo parse_from_str(
39
+ std::string pattern_string,
40
+ const std::vector<MatchFilter>& filters = {}) {
41
+ PatternInfo rv{
42
+ std::move(pattern_string),
43
+ std::make_unique<Graph>(),
44
+ decltype(vmap){},
45
+ filters};
46
+ parseIR(rv.pattern_string, rv.pattern_graph.get(), rv.vmap);
47
+ return rv;
48
+ }
49
+ };
50
+
51
+ } // namespace torch::jit::graph_rewrite_helper
52
+
53
+ #else
54
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
55
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/guard_elimination.h ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <ATen/ATen.h>
5
+ #include <ATen/core/ivalue.h>
6
+ #include <ATen/core/jit_type.h>
7
+ #include <ATen/core/stack.h>
8
+ #include <torch/csrc/Export.h>
9
+ #include <torch/csrc/jit/ir/ir.h>
10
+
11
+ #include <list>
12
+ #include <vector>
13
+
14
+ namespace torch::jit {
15
+
16
+ TORCH_API void EliminateRedundantGuards(std::shared_ptr<Graph> graph);
17
+
18
+ } // namespace torch::jit
19
+
20
+ #else
21
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
22
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/hoist_conv_packed_params.h ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/api/module.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+
7
+ namespace torch::jit {
8
+
9
+ void HoistConvPackedParams(script::Module& m);
10
+
11
+ } // namespace torch::jit
12
+
13
+ #else
14
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
15
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inline_autodiff_subgraphs.h ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ TORCH_API bool canRunWithAutograd(Node* node);
9
+
10
+ TORCH_API void InlineAutodiffSubgraphs(
11
+ std::shared_ptr<Graph>& graph,
12
+ size_t threshold = 5);
13
+
14
+ } // namespace torch::jit
15
+
16
+ #else
17
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
18
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inline_fork_wait.h ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Inline Fork and Wait calls. This is used, for example, in ONNX export, where
9
+ // we do not support the explicit parallelism structures and would rather
10
+ // just have a flat graph. This inlines the forked section in the fork()
11
+ // callsite and replaces uses of the result of wait() calls with the values
12
+ // produced from the (now-inlined) forked section.
13
+ TORCH_API void InlineForkWait(const std::shared_ptr<Graph>& graph);
14
+
15
+ } // namespace torch::jit
16
+
17
+ #else
18
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
19
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inline_forked_closures.h ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/Export.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+
7
+ namespace torch::jit {
8
+
9
+ TORCH_API void inlineForkedClosures(std::shared_ptr<Graph>& to_clean);
10
+
11
+ } // namespace torch::jit
12
+
13
+ #else
14
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
15
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inliner.h ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // Inline function and method calls.
9
+ TORCH_API void Inline(Graph& graph);
10
+
11
+ TORCH_API GraphFunction* tryToGraphFunction(Node* n);
12
+
13
+ } // namespace torch::jit
14
+
15
+ #else
16
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
17
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/inplace_check.h ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ TORCH_API void CheckInplace(std::shared_ptr<Graph>& graph);
9
+
10
+ }
11
+
12
+ #else
13
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
14
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/insert_guards.h ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <ATen/ATen.h>
5
+ #include <ATen/core/ivalue.h>
6
+ #include <ATen/core/jit_type.h>
7
+ #include <ATen/core/stack.h>
8
+ #include <torch/csrc/Export.h>
9
+ #include <torch/csrc/jit/ir/ir.h>
10
+
11
+ #include <list>
12
+ #include <vector>
13
+
14
+ namespace torch::jit {
15
+
16
+ TORCH_API void InsertGuards(std::shared_ptr<Graph> graph);
17
+
18
+ TORCH_API void RemoveProfilingNodes(const std::shared_ptr<Graph>& graph);
19
+
20
+ } // namespace torch::jit
21
+
22
+ #else
23
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
24
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/integer_value_refinement.h ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // return true if graph is modified
9
+ TORCH_API bool RefineIntegerValues(const std::shared_ptr<Graph>& graph);
10
+
11
+ } // namespace torch::jit
12
+
13
+ #else
14
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
15
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/lift_closures.h ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/Export.h>
5
+ #include <torch/csrc/jit/ir/ir.h>
6
+
7
+ namespace torch::jit {
8
+
9
+ TORCH_API void liftClosures(const std::shared_ptr<Graph>& graph);
10
+
11
+ } // namespace torch::jit
12
+
13
+ #else
14
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
15
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/liveness.h ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <ATen/ATen.h>
5
+ #include <ATen/core/ivalue.h>
6
+ #include <ATen/core/jit_type.h>
7
+ #include <ATen/core/stack.h>
8
+ #include <c10/util/sparse_bitset.h>
9
+ #include <torch/csrc/Export.h>
10
+ #include <torch/csrc/jit/ir/ir.h>
11
+ #include <list>
12
+ #include <unordered_map>
13
+ #include <vector>
14
+
15
+ namespace torch::jit {
16
+
17
+ using SparseBitVector = ::c10::SparseBitVector<256>;
18
+
19
+ // BuildLivenessSets computes "bailout" liveness which is equivalent to
20
+ // "{LIVE_IN} or {GEN}" or "{LIVE_OUT} - {KILL}"
21
+ TORCH_API std::unordered_map<Node*, std::vector<Value*>> BuildLivenessSets(
22
+ std::shared_ptr<Graph> graph);
23
+ } // namespace torch::jit
24
+
25
+ #else
26
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
27
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/loop_unrolling.h ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // return true if graph is modified
9
+ TORCH_API bool UnrollLoops(std::shared_ptr<Graph>& graph);
10
+
11
+ // Only unrolls constant loops. Will unroll them regardless of loop block size
12
+ TORCH_API bool UnrollConstantLoops(std::shared_ptr<Graph>& graph);
13
+
14
+ TORCH_API Node* PeelLoop(Node* n, size_t times);
15
+
16
+ // return true if graph is modified
17
+ TORCH_API bool PeelProfilingLoops(const std::shared_ptr<Graph>& graph);
18
+
19
+ struct TORCH_API LoopsPeeler {
20
+ LoopsPeeler(std::function<bool(Node* n)> callback, size_t num_iterations = 1)
21
+ : callback_(std::move(callback)), num_iterations_(num_iterations) {}
22
+
23
+ bool run(const std::shared_ptr<Graph>& graph);
24
+
25
+ private:
26
+ void collectLoop(Node* n);
27
+ void collectLoops(Block* block);
28
+ void peelLoops();
29
+
30
+ std::function<bool(Node* n)> callback_ = nullptr;
31
+ Node* in_loop_ = nullptr;
32
+ std::list<Node*> loops_to_peel_;
33
+ size_t num_iterations_ = 1;
34
+ };
35
+ } // namespace torch::jit
36
+
37
+ #else
38
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
39
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/lower_grad_of.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // This pass removes 'grad_of' nodes, replacing them with conditionals of
9
+ // the form:
10
+ // if any_defined(inputs):
11
+ // outputs = <original_computation>
12
+ // else:
13
+ // outputs = undefineds
14
+ TORCH_API void LowerGradOf(Graph& g);
15
+
16
+ } // namespace torch::jit
17
+
18
+ #else
19
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
20
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/lower_graph.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ using ModulePtr = c10::intrusive_ptr<c10::ivalue::Object>;
9
+
10
+ // Given a graph with of a method which first argument is %self, lower it to a
11
+ // graph where all attributes accesses are replaced with explicit inputs of the
12
+ // graph (rather than results of prim::GetAttr executed on %self).
13
+ //
14
+ // Returns a tuple (graph, parameters) where the last module.parameters.size()
15
+ // inputs to the graph are the trainable parameters used in this method. The
16
+ // remaining inputs are the true inputs to the function.
17
+ TORCH_API std::pair<std::shared_ptr<Graph>, std::vector<IValue>> LowerGraph(
18
+ Graph& graph,
19
+ const ModulePtr& self);
20
+
21
+ } // namespace torch::jit
22
+
23
+ #else
24
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
25
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/lower_tuples.h ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // removes tuples where TupleConstruct and TupleUnpack are matched
9
+ // but leaves tuples in place across if statements, loops, and as inputs/outputs
10
+ TORCH_API void LowerSimpleTuples(const std::shared_ptr<Graph>& graph);
11
+
12
+ // removes _all_ tuples and raises an error if some cannot be removed
13
+ // this is used by ONNX to ensure there are not tuples before conversion,
14
+ // but will not work on graphs whose inputs contain tuples.
15
+ TORCH_API void LowerAllTuples(const std::shared_ptr<Graph>& graph);
16
+
17
+ TORCH_API void LowerSimpleTuples(Block* block);
18
+
19
+ } // namespace torch::jit
20
+
21
+ #else
22
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
23
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/metal_rewrite.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+ #include <torch/csrc/jit/api/module.h>
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+ #include <string>
6
+ #include <vector>
7
+
8
+ namespace torch::jit {
9
+ TORCH_API void metalInsertPrePackedOps(std::shared_ptr<Graph>& graph);
10
+ TORCH_API void metalInsertPrePackedOps(script::Module& module);
11
+ TORCH_API void metalFusePrePackedConvWithClamp(script::Module& module);
12
+ TORCH_API void metalFoldPrePackingOps(script::Module& module);
13
+ TORCH_API script::Module metalOptimizeForMobile(
14
+ const script::Module& module,
15
+ const std::vector<std::string>& preserved_methods);
16
+ } // namespace torch::jit
17
+
18
+ #else
19
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
20
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/mkldnn_rewrite.h ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <ATen/Config.h>
5
+ #include <torch/csrc/jit/api/module.h>
6
+ #include <torch/csrc/jit/ir/ir.h>
7
+ #include <torch/csrc/jit/passes/subgraph_rewrite.h>
8
+
9
+ #if AT_MKLDNN_ENABLED()
10
+
11
+ #include <ideep/tensor.hpp>
12
+
13
+ #endif // AT_MKLDNN_ENABLED()
14
+
15
+ namespace torch::jit {
16
+
17
+ #if AT_MKLDNN_ENABLED()
18
+
19
+ namespace mkldnn {
20
+
21
+ const static std::map<std::string, std::vector<torch::jit::MatchFilter>>
22
+ fusion_rewrite_map = {
23
+ {"none", {}},
24
+ {"relu", {}},
25
+ };
26
+
27
+ } // namespace mkldnn
28
+
29
+ #endif // AT_MKLDNN_ENABLED()
30
+
31
+ void FuseConvWithEltwise(std::shared_ptr<Graph>& graph);
32
+
33
+ } // namespace torch::jit
34
+
35
+ #else
36
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
37
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/mobile_optimizer_type.h ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <cstdint>
5
+
6
+ enum class MobileOptimizerType : int8_t {
7
+ CONV_BN_FUSION,
8
+ INSERT_FOLD_PREPACK_OPS,
9
+ REMOVE_DROPOUT,
10
+ FUSE_ADD_RELU,
11
+ HOIST_CONV_PACKED_PARAMS,
12
+ CONV_1D_TO_2D,
13
+ VULKAN_AUTOMATIC_GPU_TRANSFER,
14
+ };
15
+
16
+ #else
17
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
18
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/normalize_ops.h ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+
6
+ namespace torch::jit {
7
+
8
+ // This pass converts aten ops to a normalized form. It is
9
+ // run immediately after IR generation in both the tracer and compiler,
10
+ // so downstream consumers of the IR do not need handle ops in their
11
+ // pre-normalized form.
12
+ // Currently only handles normalization of op aliases.
13
+ TORCH_API void NormalizeOps(const std::shared_ptr<Graph>& graph);
14
+
15
+ const std::unordered_map<Symbol, Symbol>& getOperatorAliasMap();
16
+
17
+ } // namespace torch::jit
18
+
19
+ #else
20
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
21
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/onednn_graph_fuser.h ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+ #include <torch/csrc/jit/passes/pass_manager.h>
6
+
7
+ #include <ATen/Config.h>
8
+
9
+ namespace torch::jit {
10
+
11
+ namespace fuser::onednn {
12
+
13
+ static std::atomic<bool> onednn_enabled{true};
14
+
15
+ static std::atomic<bool>& getLlgaEnabled() {
16
+ return onednn_enabled;
17
+ }
18
+
19
+ TORCH_API void fuseGraph(std::shared_ptr<Graph>& g);
20
+
21
+ } // namespace fuser::onednn
22
+
23
+ struct C10_EXPORT RegisterLlgaFuseGraph
24
+ : public PassManager<RegisterLlgaFuseGraph> {
25
+ static bool setEnabled(bool enabled) {
26
+ TORCH_CHECK(
27
+ AT_MKLDNN_ENABLED(),
28
+ "Running oneDNN Graph fuser is only supported with MKLDNN builds.");
29
+ bool oldState = fuser::onednn::getLlgaEnabled();
30
+ fuser::onednn::getLlgaEnabled() = enabled;
31
+ if (enabled) {
32
+ registerPass(fuser::onednn::fuseGraph);
33
+ } else {
34
+ clearPass();
35
+ }
36
+ return oldState;
37
+ }
38
+
39
+ static bool isEnabled() {
40
+ return fuser::onednn::getLlgaEnabled();
41
+ }
42
+
43
+ // override PassManager::registerPass to register pre-pass
44
+ static bool registerPass(GraphPass p) {
45
+ if (!isRegistered()) {
46
+ passID(registerPrePass(std::move(p)), true);
47
+ isRegistered(true);
48
+ return false;
49
+ }
50
+ return true;
51
+ }
52
+
53
+ // override PassManager::clearPass to clear pre-pass
54
+ static void clearPass() {
55
+ if (isRegistered()) {
56
+ clearPrePass(passID());
57
+ isRegistered(true);
58
+ }
59
+ }
60
+ };
61
+
62
+ } // namespace torch::jit
63
+
64
+ #else
65
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
66
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/jit/passes/onnx.h ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
2
+ #pragma once
3
+
4
+ #include <torch/csrc/jit/ir/ir.h>
5
+ #include <torch/csrc/onnx/onnx.h>
6
+ #include <torch/csrc/utils/pybind.h>
7
+
8
+ namespace torch::jit {
9
+
10
+ TORCH_API std::shared_ptr<Graph> ToONNX(
11
+ std::shared_ptr<Graph>& state,
12
+ ::torch::onnx::OperatorExportTypes operator_export_type);
13
+ TORCH_API py::dict BlockToONNX(
14
+ Block* old_block,
15
+ Block* new_block,
16
+ ::torch::onnx::OperatorExportTypes operator_export_type,
17
+ py::dict& env,
18
+ py::set& values_in_env,
19
+ bool is_sub_block = false);
20
+ TORCH_API void NodeToONNX(
21
+ Node* old_node,
22
+ Block* new_block,
23
+ ::torch::onnx::OperatorExportTypes operator_export_type,
24
+ py::dict& env,
25
+ py::set& values_in_env);
26
+ TORCH_API void RemovePrintOps(std::shared_ptr<Graph>& graph);
27
+ TORCH_API void PreprocessCaffe2Ops(std::shared_ptr<Graph>& graph);
28
+
29
+ } // namespace torch::jit
30
+
31
+ #else
32
+ #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
33
+ #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)