MCPcopy Index your code
hub / github.com/pytorch/pytorch / example_loop

Function example_loop

caffe2/python/net_printer_test.py:13–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12
13def example_loop():
14 with Task():
15 total = ops.Const(0)
16 total_large = ops.Const(0)
17 total_small = ops.Const(0)
18 total_tiny = ops.Const(0)
19 with ops.loop(10) as loop:
20 outer = ops.Mul([loop.iter(), ops.Const(10)])
21 with ops.loop(loop.iter()) as inner:
22 val = ops.Add([outer, inner.iter()])
23 with ops.If(ops.GE([val, ops.Const(80)])) as c:
24 ops.Add([total_large, val], [total_large])
25 with c.Elif(ops.GE([val, ops.Const(50)])) as c:
26 ops.Add([total_small, val], [total_small])
27 with c.Else():
28 ops.Add([total_tiny, val], [total_tiny])
29 ops.Add([total, val], total)
30
31
32def example_task():

Callers 1

example_jobFunction · 0.85

Calls 8

TaskClass · 0.90
ConstMethod · 0.80
IfMethod · 0.80
ElifMethod · 0.80
loopMethod · 0.45
iterMethod · 0.45
AddMethod · 0.45
ElseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…