@@ -1150,6 +1150,17 @@ def ConstantOfShape(self, node):
1150
1150
outputs = [node .name ],
1151
1151
** layer_attrs )
1152
1152
1153
+ @print_mapping_info
1154
+ def GatherND (self , node ):
1155
+ print (len (node .inputs ), node .inputs )
1156
+ val_x = self .graph .get_input_node (node , idx = 0 , copy = True )
1157
+ val_y = self .graph .get_input_node (node , idx = 1 , copy = True )
1158
+ self .paddle_graph .add_layer (
1159
+ "paddle.gather_nd" ,
1160
+ inputs = {"x" : val_x .name ,
1161
+ "index" : val_y .name },
1162
+ outputs = [node .name ])
1163
+
1153
1164
@print_mapping_info
1154
1165
def Clip (self , node ):
1155
1166
val_x = self .graph .get_input_node (node , idx = 0 , copy = True )
@@ -1169,23 +1180,40 @@ def Clip(self, node):
1169
1180
outputs = [node .name ],
1170
1181
** layer_attrs )
1171
1182
else :
1172
- min_ipt = self .graph .get_input_node (node , idx = 1 , copy = True )
1173
- max_ipt = self .graph .get_input_node (node , idx = 2 , copy = True )
1174
- min_value = _const_weight_or_none (min_ipt )
1175
- max_value = _const_weight_or_none (max_ipt )
1176
- if max_value .shape == (1 , ):
1177
- max_value = max_value [0 ]
1178
- if min_value .shape == (1 , ):
1179
- min_value = min_value [0 ]
1180
- if max_value is not None and min_value is not None :
1181
- layer_attrs = {'max' : max_value , 'min' : min_value }
1183
+ if len (node .inputs ) == 2 :
1184
+ val_ipt = self .graph .get_input_node (node , idx = 1 , copy = True )
1185
+
1186
+ index = node .get_input_index (val_ipt .name )
1187
+
1188
+ val_value = _const_weight_or_none (val_ipt )
1189
+ if val_value .shape == (1 , ):
1190
+ val_value = val_value [0 ]
1191
+
1192
+ if index == 1 :
1193
+ layer_attrs = {'min' : val_value }
1194
+
1195
+ if index == 2 :
1196
+ layer_attrs = {'max' : val_value }
1197
+
1182
1198
self .paddle_graph .add_layer (
1183
1199
'paddle.clip' ,
1184
1200
inputs = {"x" : val_x .name },
1185
1201
outputs = [node .name ],
1186
1202
** layer_attrs )
1187
1203
else :
1188
- raise Exception ("max_value or min_value can't be None" )
1204
+ if len (node .inputs ) == 3 :
1205
+ min_ipt = self .graph .get_input_node (node , idx = 1 , copy = True )
1206
+ max_ipt = self .graph .get_input_node (node , idx = 2 , copy = True )
1207
+ self .paddle_graph .add_layer (
1208
+ 'paddle.clip' ,
1209
+ inputs = {
1210
+ "x" : val_x .name ,
1211
+ "min" : min_ipt .name ,
1212
+ "max" : max_ipt .name
1213
+ },
1214
+ outputs = [node .name ])
1215
+ else :
1216
+ raise Exception ("max_value or min_value can't be None" )
1189
1217
1190
1218
@print_mapping_info
1191
1219
def ReduceSum (self , node ):
@@ -1681,9 +1709,9 @@ def PRelu(self, node):
1681
1709
num_parameters = val_x .out_shapes [0 ][1 ]
1682
1710
else :
1683
1711
num_parameters = 1
1712
+ slope_data = self .weights [val_slope .name ]
1684
1713
_rename_or_remove_weight (self .weights , val_slope .name )
1685
- self .weights [op_name + '._weight' ] = np .reshape (
1686
- self .weights [val_slope .name ], [1 ])
1714
+ self .weights [op_name + '._weight' ] = np .reshape (slope_data , [1 ])
1687
1715
self .paddle_graph .add_layer (
1688
1716
"paddle.nn.PReLU" ,
1689
1717
inputs = {"x" : val_x .name },
0 commit comments