Skip to content

Commit 79ae702

Browse files
Elias Ellisonfacebook-github-bot
authored andcommitted
add support for breaks and continues (#21692)
Summary: Add support for breaks and continues in the jit. We do with a Graph transform pre-SSA. A graph of the form ``` def test(): while i < 5: if i == 3: break i += 1 print(i) ``` has the body of the loop transformed to ``` if i == 3: did_break = True else: did_break = False if did_break: loop_exit = True else: i += 1 print(i) loop_exit = i < 5 ``` I am going to add more tests but I think it is ready for review now. Pull Request resolved: pytorch/pytorch#21692 Differential Revision: D16215807 Pulled By: eellison fbshipit-source-id: 365102f42de4861d9323caaeb39a96de7619a667
1 parent 09f3c4b commit 79ae702

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

aten/src/ATen/core/interned_strings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ namespace c10 {
4949
_(prim, IgnoredPythonOp) \
5050
_(prim, Reverse) \
5151
_(prim, Return) \
52+
_(prim, BreakStmt) \
53+
_(prim, ContinueStmt) \
5254
_(prim, Store) \
5355
_(prim, AutogradZero) \
5456
_(prim, AutogradAnyNonZero) \
@@ -109,6 +111,7 @@ namespace c10 {
109111
_(prim, TimePoint) \
110112
_(prim, CallFunction) \
111113
_(prim, CallMethod) \
114+
_(prim, LoopContinuation) \
112115
_(aten, append) \
113116
_(aten, item) \
114117
_(aten, format) \

0 commit comments

Comments
 (0)