@@ -710,9 +710,23 @@ def splitv_op(ctx, node, name, args):
710
710
711
711
712
712
def pad_op (ctx , node , name , args ):
713
- # T output = Pad(T input, Tpaddings paddings, @type Tpaddings)
713
+ # T output = Pad(T input, int32 paddings, @type Tpaddings), CONST model using default value
714
+ # or PadV2(T input, int32 paddings, T constant_value, @type Tpaddings), CONST mode - default value specified
715
+ # or MirrorPad(T input, int32 paddings, @type Tpaddings, @STRING mode), other mode.
714
716
# T output = Pad(T data, @STRING mode, @INTS pads, @FLOAT value)
715
717
paddings = np .array (node .inputs [1 ].get_tensor_value ()).transpose ().flatten ()
718
+ mode = node .get_attr ("mode" )
719
+ if mode :
720
+ mode = mode .s .decode ("utf-8" ).lower ()
721
+ node .set_attr ("mode" , mode )
722
+ if mode not in [None , "constant" , "reflect" ]:
723
+ raise ValueError (mode + " pad mode is not supported" )
724
+
725
+ if mode in [None , "constant" ] and len (node .input ) == 3 :
726
+ const_val = node .inputs [2 ].get_tensor_value ()[0 ]
727
+ node .set_attr ("value" , const_val )
728
+ ctx .remove_input (node , node .input [2 ])
729
+
716
730
ctx .remove_input (node , node .input [1 ])
717
731
node .set_attr ("pads" , paddings )
718
732
return node
@@ -1063,11 +1077,13 @@ def fused_batchnorm_op7(ctx, node, name, args):
1063
1077
"Mean" : (reduce_op , ["ReduceMean" ]),
1064
1078
"Min" : (reduce_op , ["ReduceMin" ]),
1065
1079
"Minimum" : (minmax_op , ["Min" ]),
1080
+ "MirrorPad" : (pad_op , ["Pad" ]),
1066
1081
"Mul" : (broadcast_op , []),
1067
1082
"Neg" : (direct_op , []),
1068
1083
"NoOp" : (no_op , []),
1069
1084
"NotEqual" : (direct_op , ["Not" ]),
1070
1085
"Pad" : (pad_op , []),
1086
+ "PadV2" : (pad_op , ["Pad" ]),
1071
1087
"Placeholder" : (placeholder_op , []),
1072
1088
"PlaceholderV2" : (placeholder_op , []),
1073
1089
"PlaceholderWithDefault" : (placeholder_op , []),
0 commit comments