|
def | __init__ (self, step=None, outputs=None, workspace_type=None, group=None, node=None, name=None, num_instances=None) |
|
def | __enter__ (self) |
|
def | __exit__ (self, type, value, traceback) |
|
def | workspace_type (self) |
|
def | add_output (self, output) |
|
def | add_outputs (self, outputs) |
|
def | set_step (self, step) |
|
def | get_step (self) |
|
def | output_list (self) |
|
def | outputs (self) |
|
def | __repr__ (self) |
|
A Task is composed of an execution step and zero or more outputs.
Tasks are executed in the context of a TaskGroup, which, in turn, can
be run by a Session.
Task outputs are fetched by the session at the end of the run.
The recommended way of creating a task is by using `net_builder.ops`.
Example:
from net_builder import ops
with Node('trainer'), Task(name='my_task', num_instances=2):
with ops.task_init():
globl = ops.Const(0)
with ops.task_instance_init():
local = ops.Const(0)
with ops.loop(100):
ops.Copy(globl, local)
with ops.task_instance_exit():
ops.Add([globl, local], [globl])
with ops.task_exit():
ops.Mul([globl, globl], [globl])
The task above will create 2 instances that will run in parallel.
Each instance will copy `local` to `globl` 100 times, Then Add `local`
to `globl` once. The `Mul` will only execute once, after all the instances
of the task have finished.
Definition at line 446 of file task.py.
def caffe2.python.task.Task.__init__ |
( |
|
self, |
|
|
|
step = None , |
|
|
|
outputs = None , |
|
|
|
workspace_type = None , |
|
|
|
group = None , |
|
|
|
node = None , |
|
|
|
name = None , |
|
|
|
num_instances = None |
|
) |
| |
Instantiate a Task and add it to the current TaskGroup and Node.
Args:
step: If provided, this task will run this ExecutionStep.
outputs: If provided, the task will return the provided outputs
to the client at completion time.
node: If provided, force task execution on the given node.
name: Name of the Task.
num_instances: If provided, this task will be cloned num_instances
times at runtime, and all instances will run
concurrently.
Definition at line 501 of file task.py.