MCPcopy Create free account
hub / github.com/pytorch/pytorch / _InferBlobDevice

Function _InferBlobDevice

caffe2/python/data_parallel_model.py:1596–1618  ·  view source on GitHub ↗

Assign blob to device option based on the operator outputing it

(model)

Source from the content-addressed store, hash-verified

1594
1595
1596def _InferBlobDevice(model):
1597 '''
1598 Assign blob to device option based on the operator outputing it
1599 '''
1600 mapping = {}
1601
1602 def map_ops(proto):
1603 for op in proto.op:
1604 device_option = op.device_option
1605 if op.type == "Iter":
1606 # Hack for Iters which have blob in CPU context
1607 device_option = caffe2_pb2.DeviceOption()
1608 device_option.device_type = caffe2_pb2.CPU
1609 for b in list(op.input) + list(op.output):
1610 if b not in mapping:
1611 mapping[b] = device_option
1612 if op.type.startswith('RecurrentNetwork'):
1613 step_args = [a for a in op.arg if a.name.endswith("step_net")]
1614 for step_arg in step_args:
1615 map_ops(step_arg.n)
1616 map_ops(model.param_init_net.Proto())
1617 map_ops(model.net.Proto())
1618 model._blob_to_device = mapping
1619
1620def _IsIDEEPBlob(model, blob_name):
1621 if blob_name in model._blob_to_device:

Callers 2

ParallelizeFunction · 0.85
Parallelize_BMUFFunction · 0.85

Calls 2

map_opsFunction · 0.85
ProtoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…