[inductor] Fix channels_last conv2d propagation when CuDNN is not found (#87266)

Fixes https://github.com/pytorch/torchdynamo/issues/1701

cc @jansel @lezcano @fdrocha @mlazos @voznesenskym @yanboliang
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87266
Approved by: https://github.com/anijain2305, https://github.com/jansel, https://github.com/voznesenskym
diff --git a/torch/_inductor/ir.py b/torch/_inductor/ir.py
index a9b6979..13cf5d7 100644
--- a/torch/_inductor/ir.py
+++ b/torch/_inductor/ir.py
@@ -3121,13 +3121,16 @@
 
             # CUDA channels_last path depend on cudnn version, see
             # https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/ConvUtils.h.
-            valid_device = True
+            valid_cudnn = False
             if (
-                x.get_device() == "cuda"
-                and torch.backends.cudnn.is_available()
-                and torch.backends.cudnn.version() < 8302
+                torch.backends.cudnn.is_available()
+                and torch.backends.cudnn.version() >= 7603
             ):
-                valid_device = False
+                valid_cudnn = True
+
+            valid_device = x.get_device().type == "cpu" or (
+                x.get_device().type == "cuda" and valid_cudnn
+            )
             if (
                 valid_device
                 and len(x.get_size()) == 4