@@ -182,372 +182,6 @@ def parseNodeCtxt(self,
182182 return ctxt , False
183183
184184
185- class PULPFPDWConv2DParser (Conv2DParser ):
186-
187- def __init__ (self , noBiasHoisting = True ):
188- super ().__init__ (noBiasHoisting )
189-
190- def parseNode (self , node : gs .Node ) -> (bool ):
191- # Parse root conv 2D information
192- wellFormed = super ().parseNode (node )
193-
194- if wellFormed :
195- # Check if the node is a depthwise convolution
196- ret = all ([
197- # Make sure padding is square
198- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][2 ],
199- self .operatorRepresentation ['pads' ][1 ] == self .operatorRepresentation ['pads' ][3 ],
200- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][1 ],
201-
202- # Check number of inputs
203- # 2 inputs if no bias, 3 if layer has bias
204- len (node .inputs ) in [2 , 3 ],
205- ])
206-
207- # Extract additional attributes
208- self .operatorRepresentation ['padding_y_top' ] = int (self .operatorRepresentation ['pads' ][0 ])
209- self .operatorRepresentation ['padding_x_left' ] = int (self .operatorRepresentation ['pads' ][1 ])
210- self .operatorRepresentation ['padding_y_bottom' ] = int (self .operatorRepresentation ['pads' ][2 ])
211- self .operatorRepresentation ['padding_x_right' ] = int (self .operatorRepresentation ['pads' ][3 ])
212-
213- return ret
214- return False
215-
216- def parseNodeCtxt (self ,
217- ctxt : NetworkContext ,
218- node : gs .Node ,
219- channels_first : bool = True ) -> Tuple [NetworkContext , bool ]:
220- # Parse node context for 2D conv
221- newCtxt , ret = super ().parseNodeCtxt (ctxt , node , channels_first )
222-
223- if ret :
224- # Define input names
225- inputs = ['data_in' , 'weight' ]
226-
227- # Handle bias, if present
228- if len (node .inputs ) == 2 :
229- self .operatorRepresentation ["has_bias" ] = "false"
230- self .operatorRepresentation ["bias" ] = "NULL"
231- else :
232- inputs .append ("bias" )
233- self .operatorRepresentation ["has_bias" ] = "true"
234-
235- # Map input nodes to operator representation
236- for idx , inputNode in enumerate (node .inputs ):
237- self .operatorRepresentation [inputs [idx ]] = ctxt .lookup (inputNode .name ).name
238-
239- # Check if DW
240- if self .operatorRepresentation ['group' ] == self .operatorRepresentation ['ch_im_in' ]:
241- return newCtxt , True
242-
243- return ctxt , False
244-
245-
246- class PULPFPDWConv2DParser (Conv2DParser ):
247-
248- def __init__ (self , noBiasHoisting = True ):
249- super ().__init__ (noBiasHoisting )
250-
251- def parseNode (self , node : gs .Node ) -> (bool ):
252- # Parse root conv 2D information
253- wellFormed = super ().parseNode (node )
254-
255- if wellFormed :
256- # Check if the node is a depthwise convolution
257- ret = all ([
258- # Make sure padding is square
259- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][2 ],
260- self .operatorRepresentation ['pads' ][1 ] == self .operatorRepresentation ['pads' ][3 ],
261- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][1 ],
262-
263- # Check number of inputs
264- # 2 inputs if no bias, 3 if layer has bias
265- len (node .inputs ) in [2 , 3 ],
266- ])
267-
268- # Extract additional attributes
269- self .operatorRepresentation ['padding_y_top' ] = int (self .operatorRepresentation ['pads' ][0 ])
270- self .operatorRepresentation ['padding_x_left' ] = int (self .operatorRepresentation ['pads' ][1 ])
271- self .operatorRepresentation ['padding_y_bottom' ] = int (self .operatorRepresentation ['pads' ][2 ])
272- self .operatorRepresentation ['padding_x_right' ] = int (self .operatorRepresentation ['pads' ][3 ])
273-
274- return ret
275- return False
276-
277- def parseNodeCtxt (self ,
278- ctxt : NetworkContext ,
279- node : gs .Node ,
280- channels_first : bool = True ) -> Tuple [NetworkContext , bool ]:
281- # Parse node context for 2D conv
282- newCtxt , ret = super ().parseNodeCtxt (ctxt , node , channels_first )
283-
284- if ret :
285- # Define input names
286- inputs = ['data_in' , 'weight' ]
287-
288- # Handle bias, if present
289- if len (node .inputs ) == 2 :
290- self .operatorRepresentation ["has_bias" ] = "false"
291- self .operatorRepresentation ["bias" ] = "NULL"
292- else :
293- inputs .append ("bias" )
294- self .operatorRepresentation ["has_bias" ] = "true"
295-
296- # Map input nodes to operator representation
297- for idx , inputNode in enumerate (node .inputs ):
298- self .operatorRepresentation [inputs [idx ]] = ctxt .lookup (inputNode .name ).name
299-
300- # Check if DW
301- if self .operatorRepresentation ['group' ] == self .operatorRepresentation ['ch_im_in' ]:
302- return newCtxt , True
303-
304- return ctxt , False
305-
306-
307- class PULPFPDWConv2DParser (Conv2DParser ):
308-
309- def __init__ (self , noBiasHoisting = True ):
310- super ().__init__ (noBiasHoisting )
311-
312- def parseNode (self , node : gs .Node ) -> (bool ):
313- # Parse root conv 2D information
314- wellFormed = super ().parseNode (node )
315-
316- if wellFormed :
317- # Check if the node is a depthwise convolution
318- ret = all ([
319- # Make sure padding is square
320- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][2 ],
321- self .operatorRepresentation ['pads' ][1 ] == self .operatorRepresentation ['pads' ][3 ],
322- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][1 ],
323-
324- # Check number of inputs
325- # 2 inputs if no bias, 3 if layer has bias
326- len (node .inputs ) in [2 , 3 ],
327- ])
328-
329- # Extract additional attributes
330- self .operatorRepresentation ['padding_y_top' ] = int (self .operatorRepresentation ['pads' ][0 ])
331- self .operatorRepresentation ['padding_x_left' ] = int (self .operatorRepresentation ['pads' ][1 ])
332- self .operatorRepresentation ['padding_y_bottom' ] = int (self .operatorRepresentation ['pads' ][2 ])
333- self .operatorRepresentation ['padding_x_right' ] = int (self .operatorRepresentation ['pads' ][3 ])
334-
335- return ret
336- return False
337-
338- def parseNodeCtxt (self ,
339- ctxt : NetworkContext ,
340- node : gs .Node ,
341- channels_first : bool = True ) -> Tuple [NetworkContext , bool ]:
342- # Parse node context for 2D conv
343- newCtxt , ret = super ().parseNodeCtxt (ctxt , node , channels_first )
344-
345- if ret :
346- # Define input names
347- inputs = ['data_in' , 'weight' ]
348-
349- # Handle bias, if present
350- if len (node .inputs ) == 2 :
351- self .operatorRepresentation ["has_bias" ] = "false"
352- self .operatorRepresentation ["bias" ] = "NULL"
353- else :
354- inputs .append ("bias" )
355- self .operatorRepresentation ["has_bias" ] = "true"
356-
357- # Map input nodes to operator representation
358- for idx , inputNode in enumerate (node .inputs ):
359- self .operatorRepresentation [inputs [idx ]] = ctxt .lookup (inputNode .name ).name
360-
361- # Check if DW
362- if self .operatorRepresentation ['group' ] == self .operatorRepresentation ['ch_im_in' ]:
363- return newCtxt , True
364-
365- return ctxt , False
366-
367-
368- class PULPFPDWConv2DParser (Conv2DParser ):
369-
370- def __init__ (self , noBiasHoisting = True ):
371- super ().__init__ (noBiasHoisting )
372-
373- def parseNode (self , node : gs .Node ) -> (bool ):
374- # Parse root conv 2D information
375- wellFormed = super ().parseNode (node )
376-
377- if wellFormed :
378- # Check if the node is a depthwise convolution
379- ret = all ([
380- # Make sure padding is square
381- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][2 ],
382- self .operatorRepresentation ['pads' ][1 ] == self .operatorRepresentation ['pads' ][3 ],
383- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][1 ],
384-
385- # Check number of inputs
386- # 2 inputs if no bias, 3 if layer has bias
387- len (node .inputs ) in [2 , 3 ],
388- ])
389-
390- # Extract additional attributes
391- self .operatorRepresentation ['padding_y_top' ] = int (self .operatorRepresentation ['pads' ][0 ])
392- self .operatorRepresentation ['padding_x_left' ] = int (self .operatorRepresentation ['pads' ][1 ])
393- self .operatorRepresentation ['padding_y_bottom' ] = int (self .operatorRepresentation ['pads' ][2 ])
394- self .operatorRepresentation ['padding_x_right' ] = int (self .operatorRepresentation ['pads' ][3 ])
395-
396- return ret
397- return False
398-
399- def parseNodeCtxt (self ,
400- ctxt : NetworkContext ,
401- node : gs .Node ,
402- channels_first : bool = True ) -> Tuple [NetworkContext , bool ]:
403- # Parse node context for 2D conv
404- newCtxt , ret = super ().parseNodeCtxt (ctxt , node , channels_first )
405-
406- if ret :
407- # Define input names
408- inputs = ['data_in' , 'weight' ]
409-
410- # Handle bias, if present
411- if len (node .inputs ) == 2 :
412- self .operatorRepresentation ["has_bias" ] = "false"
413- self .operatorRepresentation ["bias" ] = "NULL"
414- else :
415- inputs .append ("bias" )
416- self .operatorRepresentation ["has_bias" ] = "true"
417-
418- # Map input nodes to operator representation
419- for idx , inputNode in enumerate (node .inputs ):
420- self .operatorRepresentation [inputs [idx ]] = ctxt .lookup (inputNode .name ).name
421-
422- # Check if DW
423- if self .operatorRepresentation ['group' ] == self .operatorRepresentation ['ch_im_in' ]:
424- return newCtxt , True
425-
426- return ctxt , False
427-
428-
429- class PULPFPDWConv2DParser (Conv2DParser ):
430-
431- def __init__ (self , noBiasHoisting = True ):
432- super ().__init__ (noBiasHoisting )
433-
434- def parseNode (self , node : gs .Node ) -> (bool ):
435- # Parse root conv 2D information
436- wellFormed = super ().parseNode (node )
437-
438- if wellFormed :
439- # Check if the node is a depthwise convolution
440- ret = all ([
441- # Make sure padding is square
442- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][2 ],
443- self .operatorRepresentation ['pads' ][1 ] == self .operatorRepresentation ['pads' ][3 ],
444- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][1 ],
445-
446- # Check number of inputs
447- # 2 inputs if no bias, 3 if layer has bias
448- len (node .inputs ) in [2 , 3 ],
449- ])
450-
451- # Extract additional attributes
452- self .operatorRepresentation ['padding_y_top' ] = int (self .operatorRepresentation ['pads' ][0 ])
453- self .operatorRepresentation ['padding_x_left' ] = int (self .operatorRepresentation ['pads' ][1 ])
454- self .operatorRepresentation ['padding_y_bottom' ] = int (self .operatorRepresentation ['pads' ][2 ])
455- self .operatorRepresentation ['padding_x_right' ] = int (self .operatorRepresentation ['pads' ][3 ])
456-
457- return ret
458- return False
459-
460- def parseNodeCtxt (self ,
461- ctxt : NetworkContext ,
462- node : gs .Node ,
463- channels_first : bool = True ) -> Tuple [NetworkContext , bool ]:
464- # Parse node context for 2D conv
465- newCtxt , ret = super ().parseNodeCtxt (ctxt , node , channels_first )
466-
467- if ret :
468- # Define input names
469- inputs = ['data_in' , 'weight' ]
470-
471- # Handle bias, if present
472- if len (node .inputs ) == 2 :
473- self .operatorRepresentation ["has_bias" ] = "false"
474- self .operatorRepresentation ["bias" ] = "NULL"
475- else :
476- inputs .append ("bias" )
477- self .operatorRepresentation ["has_bias" ] = "true"
478-
479- # Map input nodes to operator representation
480- for idx , inputNode in enumerate (node .inputs ):
481- self .operatorRepresentation [inputs [idx ]] = ctxt .lookup (inputNode .name ).name
482-
483- # Check if DW
484- if self .operatorRepresentation ['group' ] == self .operatorRepresentation ['ch_im_in' ]:
485- return newCtxt , True
486-
487- return ctxt , False
488-
489-
490- class PULPFPDWConv2DParser (Conv2DParser ):
491-
492- def __init__ (self , noBiasHoisting = True ):
493- super ().__init__ (noBiasHoisting )
494-
495- def parseNode (self , node : gs .Node ) -> (bool ):
496- # Parse root conv 2D information
497- wellFormed = super ().parseNode (node )
498-
499- if wellFormed :
500- # Check if the node is a depthwise convolution
501- ret = all ([
502- # Make sure padding is square
503- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][2 ],
504- self .operatorRepresentation ['pads' ][1 ] == self .operatorRepresentation ['pads' ][3 ],
505- self .operatorRepresentation ['pads' ][0 ] == self .operatorRepresentation ['pads' ][1 ],
506-
507- # Check number of inputs
508- # 2 inputs if no bias, 3 if layer has bias
509- len (node .inputs ) in [2 , 3 ],
510- ])
511-
512- # Extract additional attributes
513- self .operatorRepresentation ['padding_y_top' ] = int (self .operatorRepresentation ['pads' ][0 ])
514- self .operatorRepresentation ['padding_x_left' ] = int (self .operatorRepresentation ['pads' ][1 ])
515- self .operatorRepresentation ['padding_y_bottom' ] = int (self .operatorRepresentation ['pads' ][2 ])
516- self .operatorRepresentation ['padding_x_right' ] = int (self .operatorRepresentation ['pads' ][3 ])
517-
518- return ret
519- return False
520-
521- def parseNodeCtxt (self ,
522- ctxt : NetworkContext ,
523- node : gs .Node ,
524- channels_first : bool = True ) -> Tuple [NetworkContext , bool ]:
525- # Parse node context for 2D conv
526- newCtxt , ret = super ().parseNodeCtxt (ctxt , node , channels_first )
527-
528- if ret :
529- # Define input names
530- inputs = ['data_in' , 'weight' ]
531-
532- # Handle bias, if present
533- if len (node .inputs ) == 2 :
534- self .operatorRepresentation ["has_bias" ] = "false"
535- self .operatorRepresentation ["bias" ] = "NULL"
536- else :
537- inputs .append ("bias" )
538- self .operatorRepresentation ["has_bias" ] = "true"
539-
540- # Map input nodes to operator representation
541- for idx , inputNode in enumerate (node .inputs ):
542- self .operatorRepresentation [inputs [idx ]] = ctxt .lookup (inputNode .name ).name
543-
544- # Check if DW
545- if self .operatorRepresentation ['group' ] == self .operatorRepresentation ['ch_im_in' ]:
546- return newCtxt , True
547-
548- return newCtxt , False
549-
550-
551185class PULPDWConv1DParser (RQSConv1DParser ):
552186
553187 def __init__ (self , noBiasHoisting = True ):
0 commit comments