@ -23,23 +23,47 @@ from op_test import OpTest
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					from  test_conv2d_op  import  conv2d_forward_naive 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  create_test_padding_SAME_class ( parent ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    class  TestPaddingSMAECase ( parent ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            self . pad  =  [ 0 ,  0 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            self . padding_algorithm  =  " SAME " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    cls_name  =  " {0} _ {1} " . format ( parent . __name__ ,  " PaddingSAMEOp " ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    TestPaddingSMAECase . __name__  =  cls_name 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    globals ( ) [ cls_name ]  =  TestPaddingSMAECase 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  create_test_padding_VALID_class ( parent ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    class  TestPaddingVALIDCase ( parent ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            self . pad  =  [ 1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            self . padding_algorithm  =  " VALID " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    cls_name  =  " {0} _ {1} " . format ( parent . __name__ ,  " PaddingVALIDOp " ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    TestPaddingVALIDCase . __name__  =  cls_name 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    globals ( ) [ cls_name ]  =  TestPaddingVALIDCase 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestConv2dFusionOp ( OpTest ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  setUp ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . op_type  =  " conv2d_fusion " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . exhaustive_search  =  False 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . data_format  =  " AnyLayout " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . data_format  =  " NCHW " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . dtype  =  np . float32 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . activation  =  ' relu ' 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . add_bias  =  True 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . add_residual_data  =  True 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . channels  =  None 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . outputs  =  None 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXIPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . init_group ( ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . init_dilation ( ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . init_test_case ( ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . init_bias_residual ( ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . init_activation ( ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . init_paddings ( ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . set_search_method ( ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        conv2d_param  =  { 
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -52,7 +76,9 @@ class TestConv2dFusionOp(OpTest):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        filter  =  np . random . random ( self . filter_size ) . astype ( self . dtype ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . output ,  _ ,  _ ,  _ ,  _  =  conv2d_forward_naive ( 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            input ,  filter ,  self . groups ,  conv2d_param ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            input ,  filter ,  self . groups ,  conv2d_param ,  self . padding_algorithm , 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            self . data_format ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . output  =  self . output . astype ( self . dtype ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . inputs  =  { 
 
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -84,7 +110,8 @@ class TestConv2dFusionOp(OpTest):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            ' data_format ' :  self . data_format , 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            ' exhaustive_search ' :  self . exhaustive_search , 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            ' activation ' :  self . activation , 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            ' split_channels ' :  self . channels 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            ' split_channels ' :  self . channels , 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            ' padding_algorithm ' :  self . padding_algorithm 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        } 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . outputs  =  { ' Output ' :  self . output } 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -127,6 +154,10 @@ class TestConv2dFusionOp(OpTest):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  set_outputs ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        pass 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 0 ,  0 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithoutResidual ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_bias_residual ( self ) : 
 
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -186,5 +217,156 @@ class TestMultipleOutputs(TestConv2dFusionOp):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . outputs [ ' Outputs ' ]  =  [ ( ' out1 ' ,  out1 ) ,  ( ' out2 ' ,  out2 ) ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestAsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 0 ,  0 ,  1 ,  2 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithPad_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_test_case ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . stride  =  [ 1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . input_size  =  [ 2 ,  3 ,  10 ,  10 ]   # NCHW 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        assert  np . mod ( self . input_size [ 1 ] ,  self . groups )  ==  0 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f_c  =  self . input_size [ 1 ]  / /  self . groups 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . filter_size  =  [ 6 ,  f_c ,  3 ,  3 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 2 ,  1 ,  3 ,  2 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithStride_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_test_case ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . stride  =  [ 2 ,  2 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . input_size  =  [ 2 ,  3 ,  6 ,  6 ]   # NCHW 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        assert  np . mod ( self . input_size [ 1 ] ,  self . groups )  ==  0 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f_c  =  self . input_size [ 1 ]  / /  self . groups 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . filter_size  =  [ 6 ,  f_c ,  3 ,  3 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 2 ,  1 ,  3 ,  2 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWith1x1_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_test_case ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . stride  =  [ 1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . input_size  =  [ 2 ,  3 ,  5 ,  5 ]   # NCHW 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        assert  np . mod ( self . input_size [ 1 ] ,  self . groups )  ==  0 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f_c  =  self . input_size [ 1 ]  / /  self . groups 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . filter_size  =  [ 6 ,  f_c ,  1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_group ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . groups  =  3 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 2 ,  2 ,  4 ,  0 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithGroup_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_group ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . groups  =  3 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithDepthWise3x3_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_test_case ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . stride  =  [ 1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . input_size  =  [ 3 ,  4 ,  10 ,  10 ]   # NCHW 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        assert  np . mod ( self . input_size [ 1 ] ,  self . groups )  ==  0 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f_c  =  self . input_size [ 1 ]  / /  self . groups 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . filter_size  =  [ 8 ,  f_c ,  3 ,  3 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_dilation ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . dilations  =  [ 2 ,  2 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_group ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . groups  =  4 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 1 ,  3 ,  2 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithDepthWise5x5_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_test_case ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . stride  =  [ 1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . input_size  =  [ 2 ,  4 ,  10 ,  10 ]   # NCHW 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        assert  np . mod ( self . input_size [ 1 ] ,  self . groups )  ==  0 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f_c  =  self . input_size [ 1 ]  / /  self . groups 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . filter_size  =  [ 8 ,  f_c ,  5 ,  5 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_group ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . groups  =  4 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 0 ,  1 ,  1 ,  0 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithDepthWise7x7_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_test_case ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . stride  =  [ 2 ,  2 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . input_size  =  [ 2 ,  8 ,  10 ,  10 ]   # NCHW 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        assert  np . mod ( self . input_size [ 1 ] ,  self . groups )  ==  0 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f_c  =  self . input_size [ 1 ]  / /  self . groups 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . filter_size  =  [ 16 ,  f_c ,  7 ,  7 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_group ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . groups  =  8 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 1 ,  3 ,  4 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithDilation_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_test_case ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . stride  =  [ 1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . input_size  =  [ 2 ,  3 ,  10 ,  10 ]   # NCHW 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        assert  np . mod ( self . input_size [ 1 ] ,  self . groups )  ==  0 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f_c  =  self . input_size [ 1 ]  / /  self . groups 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . filter_size  =  [ 6 ,  f_c ,  3 ,  3 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_dilation ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . dilations  =  [ 2 ,  2 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_group ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . groups  =  3 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 0 ,  1 ,  3 ,  0 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					class  TestWithInput1x1Filter1x1_AsyPadding ( TestConv2dFusionOp ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_test_case ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . stride  =  [ 1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . input_size  =  [ 2 ,  3 ,  1 ,  1 ]   # NCHW 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        assert  np . mod ( self . input_size [ 1 ] ,  self . groups )  ==  0 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f_c  =  self . input_size [ 1 ]  / /  self . groups 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . filter_size  =  [ 6 ,  f_c ,  1 ,  1 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_group ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . groups  =  3 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  init_paddings ( self ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . pad  =  [ 0 ,  3 ,  4 ,  0 ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        self . padding_algorithm  =  " EXPLICIT " 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_SAME_class ( TestAsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_SAME_class ( TestWithPad_AsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_SAME_class ( TestWithStride_AsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_SAME_class ( TestWithGroup_AsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_SAME_class ( TestWithInput1x1Filter1x1_AsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_VALID_class ( TestAsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_VALID_class ( TestWithPad_AsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_VALID_class ( TestWithStride_AsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_VALID_class ( TestWithGroup_AsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					create_test_padding_VALID_class ( TestWithInput1x1Filter1x1_AsyPadding ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					if  __name__  ==  ' __main__ ' : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    unittest . main ( )