Skip to content

Commit d4dddaa

Browse files
committed
update
1 parent 4b0fede commit d4dddaa

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

intermediate_source/fx_conv_bn_fuser.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
# -*- coding: utf-8 -*-
22
"""
33
Building a Convolution/Batch Norm fuser with torch.compile
4-
******************************************************************
5-
**Author**: `Horace He <https://github.com/chillee>`__, `Will Feng <https://github.com/yf225>`__
4+
===========================================================
65
7-
In this tutorial, we are going to use torch.compile and its pattern matching
8-
capabilities to do the following:
6+
**Author:** `Horace He <https://github.com/chillee>`_, `Will Feng <https://github.com/yf225>`_
97
10-
1) Find patterns of conv/batch norm in the data dependencies.
11-
2) For the patterns found in 1), fold the batch norm statistics into the convolution weights.
8+
.. grid:: 2
129
13-
Note that this specific optimization only works for models in inference mode (i.e. `mode.eval()`).
14-
But the pattern matching system in torch.compile works for both training and inference.
10+
.. grid-item-card:: :octicon:`mortar-board;1em;` What you will learn
11+
:class-card: card-prerequisites
1512
16-
We will demonstrate how to register custom fusion patterns with torch.compile's
17-
pattern matcher to optimize model performance.
13+
* How to register custom fusion patterns with torch.compile's pattern matcher
14+
15+
.. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites
16+
:class-card: card-prerequisites
17+
18+
* PyTorch v2.7.0
19+
20+
.. note::
21+
This optimization only works for models in inference mode (i.e. ``model.eval()``).
22+
However, torch.compile's pattern matching system works for both training and inference.
1823
1924
"""
2025

intermediate_source/fx_profiling_tutorial.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ def summary(self, should_sort : bool = False) -> str:
216216
#
217217
# * ``MaxPool2d`` takes up the most time. This is a known issue:
218218
# https://github.com/pytorch/pytorch/issues/51393
219-
# * BatchNorm2d also takes up significant time. We can continue this
220-
# line of thinking and optimize this in the Conv-BN Fusion with torch.compile
221-
# `tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_conv_bn_fuser.html>`_.
222219
#
223220
#
224221
# Conclusion

0 commit comments

Comments
 (0)