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

Method task_init

caffe2/python/net_builder.py:367–387  ·  view source on GitHub ↗

Defines operations that will be executed once at task startup. Useful when implementing processors, that don't have access to the Task top-level structure. This setup will be run only once, even if multiple instances of the task will run in parallel. For ins

(self)

Source from the content-addressed store, hash-verified

365 return _RunWhileCondition(name=name)
366
367 def task_init(self):
368 """
369 Defines operations that will be executed once at task startup.
370 Useful when implementing processors, that don't have access to the Task
371 top-level structure.
372
373 This setup will be run only once, even if multiple instances of the task
374 will run in parallel. For instance-local initialization, use
375 `task_instance_init` instead.
376
377 Example:
378 def my_processor(rec):
379 with ops.task_init():
380 one = ops.Const(1)
381 two = ops.Const(1)
382 return Tuple(
383 ops.Add(rec[0](), zero), ops.Add(rec[1](), two))
384 """
385 setup = _SetupBuilder(_SetupBuilder.INIT)
386 self.net().add_attribute(Task.TASK_SETUP, setup)
387 return setup
388
389 def task_exit(self):
390 """

Callers 7

test_setupMethod · 0.80
test_multi_instanceMethod · 0.80
_runtime_threads_taskFunction · 0.80
_timed_taskMethod · 0.80
example_taskFunction · 0.80
procMethod · 0.80

Calls 3

netMethod · 0.95
_SetupBuilderClass · 0.85
add_attributeMethod · 0.80

Tested by 5

test_setupMethod · 0.64
test_multi_instanceMethod · 0.64
example_taskFunction · 0.64
procMethod · 0.64