Allows to run Nets, ExecutionSteps, Plans, Tasks and TaskGroups. A session can potentially run in multiple nodes concurrently. Example: from core import Net from caffe2.python.task import Task, TaskGroup, WorkspaceType net = Net('test1') net.Add([net.Const(1), net.Const(2)]) net2 = net.Clone() step = core.execution_step('step1', [net2]) with TaskGroup(WorkspaceType.GLOBAL) as init_tg: with Node('node1'): n1setup = net.Net('n1setup') n1msg = n1setup.Const('Hello from node 1.') Task(step=n1setup) with TaskGroup() as private_tg: with Node('node1'): n1 = net.Net('n1') n1.Print(n1msg, 0) Task(step=n1) with Node('node2'): n2 = net.Net('n2') n2.Print(n2.Const('Hello from node 2.'), 0) Task(step=n2) session = LocalSession() session.run(net) session.run(step) session.run(init_tg) session.run(private_tg) Global Workspace: At the beggining of the session, a global workspace is created and kept alive for the duration of the session. Private Workspace: Tasks can be run either directly on the global workspace, or they can instantiate a private child workspace that is released after each run. Blob visibility: Tasks running in different nodes in parallel will always run under different workspaces, so it must be assumed that they won't be able to access each other's blobs. On the other hand, tasks running on the same node are guaranteed to run on the same workspace within a run.
Definition at line 20 of file session.py.