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

Function _RemapParameterBlobsForSharedModel

caffe2/python/data_parallel_model.py:1275–1304  ·  view source on GitHub ↗
(model, all_params)

Source from the content-addressed store, hash-verified

1273
1274
1275def _RemapParameterBlobsForSharedModel(model, all_params):
1276 assert model._shared_model
1277 master_prefix = "{}_{}/".format(
1278 model._device_prefix, model._devices[0])
1279 log.info("Remapping param blobs to master -> {}".format(master_prefix))
1280 master_params = set(model.GetParams())
1281
1282 # Remove all but master params
1283 def modify_ops(net):
1284 ops = []
1285 for op in net.Proto().op:
1286 delete_op = False
1287 # Delete ops that output non-master version of parameter
1288 for outp in op.output:
1289 if outp in all_params and outp not in master_params:
1290 delete_op = True
1291 log.debug("Delete b/c {}: {}".format(outp, str(op)))
1292 break
1293 if delete_op:
1294 continue
1295 # Remap inputs to point to the master param
1296 for j, inp in enumerate(op.input):
1297 if inp in all_params and inp not in master_params:
1298 op.input[j] = master_prefix + stripBlobName(inp)
1299 ops.append(op)
1300 del net.Proto().op[:]
1301 net.Proto().op.extend(ops)
1302
1303 modify_ops(model.param_init_net)
1304 modify_ops(model.net)
1305
1306
1307class CollectivesConcurrencyControl:

Callers 1

ParallelizeFunction · 0.85

Calls 4

modify_opsFunction · 0.85
infoMethod · 0.80
GetParamsMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…