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:
caffe2.python.session.LocalSession

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.


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. 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 20 of file session.py.

Member Function Documentation

def caffe2.python.session.Session.run (   self,
  runnable,
  workspace_type = None,
  setup_net_list = None 
)
Run the given runnable.

Args:
    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 133 of file session.py.


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