|
4 | 4 | =============================================== |
5 | 5 | **Author:** `Nathan Inkawhich <https://github.com/inkawhich>`_ |
6 | 6 |
|
7 | | -Hybrid Frontend Information |
8 | | ---------------------------- |
9 | | -
|
10 | 7 | This document is meant to highlight the syntax of the Hybrid Frontend |
11 | 8 | through a non-code intensive example. The Hybrid Frontend is one of the |
12 | 9 | new shiny features of Pytorch 1.0 and provides an avenue for developers |
|
20 | 17 | PyTorch), then gradually transition the proven model to graph mode for |
21 | 18 | production, when speed and resouce consumption become critical. |
22 | 19 |
|
| 20 | +Hybrid Frontend Information |
| 21 | +--------------------------- |
| 22 | +
|
23 | 23 | The process for transitioning a model to graph mode is as follows. |
24 | 24 | First, the developer constructs, trains, and tests the model in eager |
25 | 25 | mode. Then they incrementally **trace** and **script** each |
@@ -60,21 +60,23 @@ class definitions. |
60 | 60 | The function we seek to implement, :math:`Y(x)`, is defined for |
61 | 61 | :math:`x \epsilon \mathbb{N}` as |
62 | 62 |
|
63 | | -.. math:: z(x) = \Biggl \lfloor \frac{\sqrt{\prod_{i=1}^{ | 2 x | } i}}{5} \Biggr \rfloor |
| 63 | +.. math:: |
| 64 | +
|
| 65 | + z(x) = \Biggl \lfloor \\frac{\sqrt{\prod_{i=1}^{|2 x|}i}}{5} \Biggr \\rfloor |
64 | 66 |
|
65 | 67 | .. math:: |
66 | 68 |
|
67 | | - Y(x) = \begin{cases} |
68 | | - \frac{z(x)}{2} & if z(x)\%2 == 0 \\ |
69 | | - z(x) & otherwise |
70 | | - \end{cases} |
| 69 | + Y(x) = \\begin{cases} |
| 70 | + \\frac{z(x)}{2} & \\text{if } z(x)\%2 == 0 \\ |
| 71 | + z(x) & \\text{otherwise} |
| 72 | + \end{cases} |
71 | 73 |
|
72 | 74 | .. math:: |
73 | 75 |
|
74 | | - \begin{array}{| r | r |} \hline |
75 | | - x &1 &2 &3 &4 &5 &6 &7 \\ \hline |
76 | | - Y(x) &0 &0 &-5 &20 &190 &-4377 &-59051 \\ \hline |
77 | | - \end{array} |
| 76 | + \\begin{array}{| r | r |} \hline |
| 77 | + x &1 &2 &3 &4 &5 &6 &7 \\ \hline |
| 78 | + Y(x) &0 &0 &-5 &20 &190 &-4377 &-59051 \\ \hline |
| 79 | + \end{array} |
78 | 80 |
|
79 | 81 | As mentioned, the computation is split into four parts. Part one is the |
80 | 82 | simple tensor calculation of :math:`|2x|`, which can be traced. Part two |
|
0 commit comments