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

Function _GetLegacyDims

caffe2/python/caffe_translator.py:50–66  ·  view source on GitHub ↗
(net, net_params, dummy_input, legacy_pad_ops)

Source from the content-addressed store, hash-verified

48
49
50def _GetLegacyDims(net, net_params, dummy_input, legacy_pad_ops):
51 dim_map = {}
52 ws = workspace.C.Workspace()
53 for param in net_params.protos:
54 ws.create_blob(param.name) \
55 .feed(utils.Caffe2TensorToNumpyArray(param))
56 external_input = net.op[0].input[0]
57 ws.create_blob(external_input).feed(dummy_input)
58 # Get dimensions with legacy pad
59 for i in range(len(net.op)):
60 op_def = net.op[i]
61 ws._run_operator(op_def.SerializeToString())
62 if i in legacy_pad_ops:
63 output = op_def.output[0]
64 blob_legacy = ws.fetch_blob(output)
65 dim_map[i] = blob_legacy.shape
66 return dim_map
67
68
69def _GetLegacyPadArgs(op_def, arg_map):

Callers 1

_RemoveLegacyPadFunction · 0.85

Calls 1

rangeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…