@@ -567,35 +567,31 @@ def _test_backward_with_batchsize(self, device, contiguous, batch_sz):
567
567
x , weight , offset , mask , bias , stride , padding , dilation = self .get_fn_args (device , contiguous , batch_sz )
568
568
569
569
def func (x_ , offset_ , mask_ , weight_ , bias_ ):
570
- return ops .deform_conv2d (x_ , offset_ , mask_ ,
571
- weight_ , bias_ , stride = stride ,
572
- padding = padding , dilation = dilation )
570
+ return ops .deform_conv2d (x_ , offset_ , weight_ , bias_ , stride = stride ,
571
+ padding = padding , dilation = dilation , mask = mask_ )
573
572
574
573
gradcheck (func , (x , offset , mask , weight , bias ), nondet_tol = 1e-5 )
575
574
576
575
def func_no_mask (x_ , offset_ , weight_ , bias_ ):
577
- return ops .deform_conv2d (x_ , offset_ , None ,
578
- weight_ , bias_ , stride = stride ,
579
- padding = padding , dilation = dilation )
576
+ return ops .deform_conv2d (x_ , offset_ , weight_ , bias_ , stride = stride ,
577
+ padding = padding , dilation = dilation , mask = None )
580
578
581
579
gradcheck (func_no_mask , (x , offset , weight , bias ), nondet_tol = 1e-5 )
582
580
583
581
@torch .jit .script
584
582
def script_func (x_ , offset_ , mask_ , weight_ , bias_ , stride_ , pad_ , dilation_ ):
585
583
# type:(Tensor, Tensor, Tensor, Tensor, Tensor, Tuple[int, int], Tuple[int, int], Tuple[int, int])->Tensor
586
- return ops .deform_conv2d (x_ , offset_ , mask_ ,
587
- weight_ , bias_ , stride = stride_ ,
588
- padding = pad_ , dilation = dilation_ )
584
+ return ops .deform_conv2d (x_ , offset_ , weight_ , bias_ , stride = stride_ ,
585
+ padding = pad_ , dilation = dilation_ , mask = mask_ )
589
586
590
587
gradcheck (lambda z , off , msk , wei , bi : script_func (z , off , msk , wei , bi , stride , padding , dilation ),
591
588
(x , offset , mask , weight , bias ), nondet_tol = 1e-5 )
592
589
593
590
@torch .jit .script
594
591
def script_func_no_mask (x_ , offset_ , weight_ , bias_ , stride_ , pad_ , dilation_ ):
595
592
# type:(Tensor, Tensor, Tensor, Tensor, Tuple[int, int], Tuple[int, int], Tuple[int, int])->Tensor
596
- return ops .deform_conv2d (x_ , offset_ , None ,
597
- weight_ , bias_ , stride = stride_ ,
598
- padding = pad_ , dilation = dilation_ )
593
+ return ops .deform_conv2d (x_ , offset_ , weight_ , bias_ , stride = stride_ ,
594
+ padding = pad_ , dilation = dilation_ , mask = None )
599
595
600
596
gradcheck (lambda z , off , wei , bi : script_func_no_mask (z , off , wei , bi , stride , padding , dilation ),
601
597
(x , offset , weight , bias ), nondet_tol = 1e-5 )
@@ -621,7 +617,7 @@ def script_func_no_mask(x_, offset_, weight_, bias_, stride_, pad_, dilation_):
621
617
622
618
for d in ["cpu" , "cuda" ]:
623
619
624
- out = ops .deform_conv2d (img .to (d ), offset .to (d ), mask .to (d ), weight .to (d ), padding = 1 )
620
+ out = ops .deform_conv2d (img .to (d ), offset .to (d ), weight .to (d ), padding = 1 , mask = mask .to (d ))
625
621
out .mean ().backward ()
626
622
if true_cpu_grads is None :
627
623
true_cpu_grads = init_weight .grad
0 commit comments