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

Method __init__

caffe2/python/task.py:491–535  ·  view source on GitHub ↗

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.

(
            self, step=None, outputs=None,
            workspace_type=None, group=None, node=None, name=None,
            num_instances=None)

Source from the content-addressed store, hash-verified

489 return cur_name
490
491 def __init__(
492 self, step=None, outputs=None,
493 workspace_type=None, group=None, node=None, name=None,
494 num_instances=None):
495 """
496 Instantiate a Task and add it to the current TaskGroup and Node.
497
498 Args:
499 step: If provided, this task will run this ExecutionStep.
500 outputs: If provided, the task will return the provided outputs
501 to the client at completion time.
502 node: If provided, force task execution on the given node.
503 name: Name of the Task.
504 num_instances: If provided, this task will be cloned num_instances
505 times at runtime, and all instances will run
506 concurrently.
507 """
508 if not name and isinstance(step, core.ExecutionStep):
509 name = step.Proto().name
510 if not name:
511 name = 'task'
512 # register this node name with active context
513 self.node = str(Node.current(None if node is None else Node(node)))
514 self.group = TaskGroup.current(group, required=False)
515
516 self.name = Task._get_next_name(self.node, self.group, name)
517
518 # may need to be temporarily removed later if Task used as a context
519 if self.group is not None:
520 self.group._tasks_to_add.append(self)
521
522 self._already_used = False
523 self._step = None
524 self._step_with_setup = None
525 self._outputs = []
526 if step is not None:
527 self.set_step(step)
528 if outputs is not None:
529 self.add_outputs(outputs)
530
531 self._pipeline = None
532 self._is_pipeline_context = False
533 self._workspace_type = workspace_type
534 self._report_net = None
535 self._num_instances = num_instances
536
537 def __enter__(self):
538 super().__enter__()

Callers

nothing calls this directly

Calls 8

set_stepMethod · 0.95
add_outputsMethod · 0.95
isinstanceFunction · 0.85
currentMethod · 0.80
_get_next_nameMethod · 0.80
NodeClass · 0.70
ProtoMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected