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

Class LocalSession

caffe2/python/session.py:176–213  ·  view source on GitHub ↗

Session that runs in a single node. Tasks are all remapped to run in parallel in the 'local' node. Currently, LocalSession runs all parallel tasks in the same workspace, but this behavior may change in the future. Only tasks pointing to the same logical node are guaranteed to a

Source from the content-addressed store, hash-verified

174
175
176class LocalSession(Session):
177 """
178 Session that runs in a single node.
179 Tasks are all remapped to run in parallel in the 'local' node.
180
181 Currently, LocalSession runs all parallel tasks in the same workspace,
182 but this behavior may change in the future. Only tasks pointing to the
183 same logical node are guaranteed to always run in the same workspace.
184 """
185 def __init__(self, ws=None):
186 Session.__init__(self)
187 self._ws = ws or workspace.C.Workspace.current
188
189 @classmethod
190 def _compile_task_group(cls, task_group, setup_net_list=None):
191 with Cluster():
192 task = task_group.to_task()
193 plan = core.Plan('task_group_plan')
194 plan.AddStep(task.get_step())
195 return (plan, task.output_list(), task.workspace_type())
196
197 def _run_compiled(self, compiled):
198 plan, output_list, workspace_type = compiled
199
200 # make sure the output blobs belong to the parent workspace
201 outputs = []
202 for name in output_list.names():
203 self._ws.create_blob(str(name))
204 outputs.append(core.BlobReference(str(name)))
205 output_list.set_values(outputs, _fetch_func=self._fetch_output)
206 task_ws = (
207 workspace.C.Workspace(self._ws)
208 if workspace_type == WorkspaceType.PRIVATE else self._ws)
209 with workspace.WorkspaceGuard(task_ws):
210 task_ws.run(plan)
211
212 def _fetch_output(self, output):
213 return self._ws.blobs[str(output)].fetch()

Callers 15

builderMethod · 0.90
test_net_multi_useMethod · 0.90
test_loopsMethod · 0.90
test_setupMethod · 0.90
test_multi_instanceMethod · 0.90
test_dequeue_manyMethod · 0.90

Calls

no outgoing calls

Tested by 15

builderMethod · 0.72
test_net_multi_useMethod · 0.72
test_loopsMethod · 0.72
test_setupMethod · 0.72
test_multi_instanceMethod · 0.72
test_dequeue_manyMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…