xref: /aosp_15_r20/external/pytorch/torch/csrc/jit/passes/frozen_conv_folding.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <torch/csrc/jit/ir/ir.h>
4 
5 namespace torch::jit {
6 
7 // Fuses Convolution -> Batchnorm into a single Convolution by
8 // folding batchnorm weights into conv weights.
9 // This pass only works on Frozen Graphs; otherwise it is a No-Op.
10 TORCH_API bool FoldFrozenConvBatchnorm(std::shared_ptr<Graph>& graph);
11 
12 // Fuses Convolution -> Add/Sub into a single Convolution by
13 // folding add constant tensor into conv weights.
14 // This pass only works on Frozen Graphs; otherwise it is a No-Op.
15 TORCH_API bool FoldFrozenConvAddOrSub(std::shared_ptr<Graph>& graph);
16 
17 // Fuses Convolution -> Mul/Div into a single Convolution by
18 // folding add constant tensor into conv weights.
19 // This pass only works on Frozen Graphs; otherwise it is a No-Op.
20 TORCH_API bool FoldFrozenConvMulOrDiv(std::shared_ptr<Graph>& graph);
21 
22 } // namespace torch::jit
23