Caffe2 - Python API
A deep learning, cross platform ML framework
auto_symbolic.py
1 from torch.autograd._functions.utils import prepare_onnx_paddings
2 
3 
4 def reflectionpad_symbolic(g, input, *params):
5  mode = "reflect"
6  paddings = prepare_onnx_paddings(len(input.type().sizes()), params)
7  return g.op("Pad", input, pads_i=paddings, mode_s=mode)
8 
9 
10 def replicationpad_symbolic(g, input, *params):
11  mode = "edge"
12  paddings = prepare_onnx_paddings(len(input.type().sizes()), params)
13  return g.op("Pad", input, pads_i=paddings, mode_s=mode)
14 
15 
16 symbolic_fns = {
17  'ReflectionPad1d': reflectionpad_symbolic,
18  'ReflectionPad2d': reflectionpad_symbolic,
19  'ReplicationPad1d': replicationpad_symbolic,
20  'ReplicationPad2d': replicationpad_symbolic,
21  'ReplicationPad3d': replicationpad_symbolic,
22 }