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

Function example_task

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

Source from the content-addressed store, hash-verified

30
31
32def example_task():
33 with Task():
34 with ops.task_init():
35 one = ops.Const(1)
36 two = ops.Add([one, one])
37 with ops.task_init():
38 three = ops.Const(3)
39 accum = ops.Add([two, three])
40 # here, accum should be 5
41 with ops.task_exit():
42 # here, accum should be 6, since this executes after lines below
43 seven_1 = ops.Add([accum, one])
44 six = ops.Add([accum, one])
45 ops.Add([accum, one], [accum])
46 seven_2 = ops.Add([accum, one])
47 o6 = final_output(six)
48 o7_1 = final_output(seven_1)
49 o7_2 = final_output(seven_2)
50
51 with Task(num_instances=2):
52 with ops.task_init():
53 one = ops.Const(1)
54 with ops.task_instance_init():
55 local = ops.Const(2)
56 ops.Add([one, local], [one])
57 ops.LogInfo('ble')
58
59 return o6, o7_1, o7_2
60
61def example_job():
62 with Job() as job:

Callers 1

example_jobFunction · 0.85

Calls 8

TaskClass · 0.90
final_outputFunction · 0.90
task_initMethod · 0.80
ConstMethod · 0.80
task_exitMethod · 0.80
task_instance_initMethod · 0.80
LogInfoMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…