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

Function _AdjustDims

caffe2/python/caffe_translator.py:81–107  ·  view source on GitHub ↗
(op_def, arg_map, pads, dim1, dim2)

Source from the content-addressed store, hash-verified

79
80
81def _AdjustDims(op_def, arg_map, pads, dim1, dim2):
82 n1, c1, h1, w1 = dim1
83 n2, c2, h2, w2 = dim2
84 assert(n1 == n2)
85 assert(c1 == c2)
86 is_pad = 'pad' in arg_map
87 if h1 != h2 or w1 != w2:
88 if h1 == h2 + 1:
89 pads['pad_b'] += 1
90 elif h1 != h2:
91 raise Exception("Unexpected dimensions for height:", h1, h2)
92 if w1 == w2 + 1:
93 pads['pad_r'] += 1
94 elif w1 != w2:
95 raise Exception("Unexpected dimensions for width:", w1, w2)
96 if is_pad:
97 op_def.arg.remove(arg_map['pad'])
98 args = []
99 for name in pads.keys():
100 arg = caffe2_pb2.Argument()
101 arg.name = name
102 arg.i = pads[name]
103 args.append(arg)
104 op_def.arg.extend(args)
105 else:
106 for name in pads.keys():
107 arg_map[name].i = pads[name]
108
109
110def _RemoveLegacyPad(net, net_params, input_dims):

Callers 1

_RemoveLegacyPadFunction · 0.85

Calls 5

ExceptionClass · 0.85
removeMethod · 0.45
keysMethod · 0.45
appendMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…