Skip to content

Commit c78f06e

Browse files
dbortfacebook-github-bot
authored andcommitted
Migrate control_flow.md to the new docs tree
Summary: Move control_flow.md into the new docs tree, update references, and add it to the main table of contents. Differential Revision: D50612692
1 parent 17454e5 commit c78f06e

File tree

7 files changed

+20
-22
lines changed

7 files changed

+20
-22
lines changed

docs/source/getting-started-architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Starting from the program source code, below are the steps you would go through
3232

3333

3434
* Like all PyTorch use cases, ExecuTorch starts from model authoring, where standard `nn.Module` eager mode PyTorch programs are created.
35-
* Export-specific helpers are used to represent advanced features like [control flow](https://github.com/pytorch/executorch/blob/main/docs/website/docs/ir_spec/control_flow.md) (for example, helper functions to trace both branches of if-else) and [dynamic shapes](https://pytorch.org/get-started/pytorch-2.0/#pytorch-2x-faster-more-pythonic-and-as-dynamic-as-ever) (for example, data dependent dynamic shape constraint).
35+
* Export-specific helpers are used to represent advanced features like [control flow](./ir-control-flow.md) (for example, helper functions to trace both branches of if-else) and [dynamic shapes](https://pytorch.org/get-started/pytorch-2.0/#pytorch-2x-faster-more-pythonic-and-as-dynamic-as-ever) (for example, data dependent dynamic shape constraint).
3636

3737

3838
### Export

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Topics in this section will help you get started with ExecuTorch.
126126

127127
ir-exir
128128
ir-ops-set-definition
129+
ir-control-flow
129130

130131
.. toctree::
131132
:glob:

docs/website/docs/ir_spec/control_flow.md renamed to docs/source/ir-control-flow.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# (Prototype) Control Flow
1+
# IR Control Flow
22

33
EXIR has a couple of special operators used to help specify control flow within
44
some code, similar to jax's control flow operators. Currently these operators
55
are only supported for inference.
66

7-
## torch.ops.higher_order.cond
7+
## `torch.ops.higher_order.cond`
88

99
The `cond` function represents an “if” statement in other programming languages.
1010
It can logically be seen as implemented as follows:
@@ -105,10 +105,7 @@ class GraphModule(torch.nn.Module):
105105
return sin
106106
```
107107

108-
**See examples of advanced usage of `cond()` operator in ExportDB: [cond tag](https://www.internalfb.com/intern/staticdocs/exportdb/cond.html)**
109-
110-
111-
## torch.ops.higher_order.map
108+
## `torch.ops.higher_order.map`
112109

113110
The `map` function is similar to Python's builtin `map`, where it represents
114111
applying an operation in the first dimension of a tensor.
@@ -171,31 +168,30 @@ class GraphModule(torch.nn.Module):
171168
return [%add]
172169
```
173170

174-
**See examples of advanced usage of `map()` operator in ExportDB: [map tag](https://www.internalfb.com/intern/staticdocs/exportdb/map.html)**
171+
## `torch.ops.while`
175172

176-
## torch.ops.while
173+
A while loop is another control flow construct representing a repeated action.
177174

178-
TODO
179-
<!-- A while loop is another control flow construct representing a repeated action.
175+
TODO: Add more details.
180176

177+
<!--
178+
TODO:
181179
182180
#### Representation in FX
183181
184-
185182
```
186183
%name = call_function[target = exir.while_loop](args = (condition, body, init_val), kwargs = {})
187184
```
188185
189-
190186
Above, both condition and body are “functions” represented by GraphModule. The semantics of this node is interpreted as, while `condition` is true, keep executing `body`. The return value of this node is the last val produced by `body` (i.e. the one that failed `cond`).
191187
192188
The implementation of exir.while_loop matches this description:
193189
194-
195190
```
196191
def while_loop(condition, body, init_val):
197192
val = init_val
198193
while cond(*val):
199194
val = body(*val)
200195
return val
201-
``` -->
196+
```
197+
-->

docs/website/docs/export/00_export_manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ issues, please file an issue on Github and tag "export".
2626
- [Modules and Entrypoints](./modules_and_entrypoints.md)
2727
- [Constraints API](./constraint_apis.md)
2828
- [Exported Program](../ir_spec/00_exir.md#exportedprogram)
29-
- [Control Flow Operators](../ir_spec/control_flow.md)
29+
- [Control Flow Operators](https://pytorch.org/executorch/stable/ir-control-flow.html)
3030
- [Custom Operators](./custom_operators.md)
3131
- [ExportDB](./exportdb.md)

docs/website/docs/export/background.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Python feature, we strive to provide a workaround as part of the error message.
3939
Over time, we expect to fill in such gaps. On the other hand, not being able to
4040
decide which control flow path to continue tracing on is a necessary limitation
4141
of the compiler. You are required to use special operators to unblock such
42-
cases. See [Control Flow Operators](../ir_spec/control_flow.md).
42+
cases. See [Control Flow
43+
Operators](https://pytorch.org/executorch/stable/ir-control-flow.html).
4344

4445
## Shapes
4546

docs/website/docs/export/export_api_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
- [Modules and Entrypoints](./modules_and_entrypoints.md)
44
- [Constraints API](./constraint_apis.md)
5-
- [Control Flow Operators](../ir_spec/control_flow.md)
5+
- [Control Flow Operators](https://pytorch.org/executorch/stable/ir-control-flow.html)
66
- [Custom Operators](./custom_operators.md)

docs/website/docs/tutorials/exporting_to_executorch.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ The entrypoint to ExecuTorch is through the `torch._export.capture_pre_autograd_
3838
to fully capture a PyTorch Model (either `torch.nn.Module` or a callable) into a
3939
`torch.fx` graph representation.
4040

41-
In order for the model to
42-
be fully captured into a graph, it may require minor modifications to the user
43-
code, such as using [control flow operators](../ir_spec/control_flow.md) in
44-
place of if-statements to capture dynamic behavior. To learn more about what
41+
In order for the model to be fully captured into a graph, it may require
42+
minor modifications to the user code, such as using [control flow
43+
operators](https://pytorch.org/executorch/stable/ir-control-flow.html) in place
44+
of if-statements to capture dynamic behavior. To learn more about what
4545
is supported in the export flow, you can take a look at the examples in
4646
[exportdb](https://pytorch.org/docs/main/generated/exportdb/index.html).
4747
[Custom operators](./custom_ops.md) can also be traced into the graph

0 commit comments

Comments
 (0)