Switch to CUDA implementation if batch size >= 65536 for affine_grid (#16403)
authorvishwakftw <cs15btech11043@iith.ac.in>
Sat, 26 Jan 2019 19:14:19 +0000 (11:14 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 26 Jan 2019 19:18:57 +0000 (11:18 -0800)
Summary:
Changelog:

- Append a condition that switches to the native CUDA implementation for affine_grid

Fixes #16365

Differential Revision: D13832192

Pulled By: soumith

fbshipit-source-id: 3f484e6673d71e3ba7627b170cb8f1611e12b9b2

torch/nn/_functions/vision.py

index 159025e..018e93b 100644 (file)
@@ -6,7 +6,7 @@ from ..._jit_internal import weak_script
 @weak_script
 def affine_grid_generator(theta, size):
     # type: (Tensor, List[int]) -> Tensor
-    if theta.is_cuda and cudnn.enabled and cudnn.is_acceptable(theta) and len(size) == 4:
+    if theta.is_cuda and cudnn.enabled and cudnn.is_acceptable(theta) and len(size) == 4 and size[0] < 65536:
         N, C, H, W = size
         ret = torch.cudnn_affine_grid_generator(theta, N, C, H, W)
     else: