Caffe2 - Python API
A deep learning, cross platform ML framework
Public Member Functions | List of all members
caffe2.python.session.Session Class Reference
Inheritance diagram for caffe2.python.session.Session:

Public Member Functions

def __init__ (self)
def is_open (self)
def compile (cls, runnable, workspace_type=None, setup_net_list=None)
def run (self, runnable, workspace_type=None, setup_net_list=None)
def close (self)
def fetch_output (self, output)
def __enter__ (self)
def __exit__ (self, ex_type, value, traceback)

Detailed Description

Allows to run Nets, ExecutionSteps, Plans, Tasks and TaskGroups.
A session can potentially run in multiple nodes concurrently.

    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.')

    with TaskGroup() as private_tg:
        with Node('node1'):
            n1 = net.Net('n1')
            n1.Print(n1msg, 0)
        with Node('node2'):
            n2 = net.Net('n2')
            n2.Print(n2.Const('Hello from node 2.'), 0)

    session = LocalSession()

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. Tasks running on the same node will follow
    Workspace hierarchy rules: tasks running on separate private workspaces
    will only be able to share blobs defined on a common parent Workspace.

Definition at line 35 of file

Member Function Documentation

def (   self,
  workspace_type = None,
  setup_net_list = None 
Run the given runnable.

    runnable: Object recognized by the Session. Currently, we support
TaskGroup, Task, Plan, ExecutionStep, and Net.
    workspace_type: A string defined in the WorkspaceType object.
    setup_net_list: A list of Net objects or a list of NetDef protos.
So far this is only used by the DistributedSession, in which we
need to pass a list of special nets to setup the master.

Definition at line 148 of file

The documentation for this class was generated from the following file: