From 51e5f4319b4557a2f50f77b4d867a241ed6125f8 Mon Sep 17 00:00:00 2001
From: Christian Sigg <csigg@google.com>
Date: Wed, 1 Jul 2020 11:15:50 -0700
Subject: [PATCH] Clean up cuDNN compatible version check.

This became simpler, now that the minimum supported version is cuDNN 7.

PiperOrigin-RevId: 319260739
Change-Id: I16548b2fed93491b2cee4099039faaf15987cb99
---
 tensorflow/stream_executor/cuda/cudnn_version.cc     | 12 ++++--------
 .../stream_executor/cuda/cudnn_version_test.cc       | 11 +----------
 2 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/tensorflow/stream_executor/cuda/cudnn_version.cc b/tensorflow/stream_executor/cuda/cudnn_version.cc
index 9ef8bc95e56..889a6d81b1e 100644
--- a/tensorflow/stream_executor/cuda/cudnn_version.cc
+++ b/tensorflow/stream_executor/cuda/cudnn_version.cc
@@ -23,17 +23,13 @@ bool IsSourceCompatibleWithCudnnLibrary(CudnnVersion source_version,
   // Major version is neither forward or backward compatible and therefore major
   // versions needs to match between source and library.
   //
-  // Minor version is backward-compatible beginning with CuDNN 7 and therefore
-  // minor version of library needs to be same or higher.
+  // Minor version is backward-compatible and therefore minor version of library
+  // needs to be same or higher.
   //
   // Patch releases are always forward and backward compatible and therefore
   // need not match.
-  if (loaded_version.major_version != source_version.major_version) {
-    return false;
-  }
-  return ((loaded_version.minor_version == source_version.minor_version) ||
-          (source_version.major_version >= 7 &&
-           loaded_version.minor_version >= source_version.minor_version));
+  return loaded_version.major_version == source_version.major_version &&
+         loaded_version.minor_version >= source_version.minor_version;
 }
 
 }  // namespace gpu
diff --git a/tensorflow/stream_executor/cuda/cudnn_version_test.cc b/tensorflow/stream_executor/cuda/cudnn_version_test.cc
index cfe114662d4..e50493ac103 100644
--- a/tensorflow/stream_executor/cuda/cudnn_version_test.cc
+++ b/tensorflow/stream_executor/cuda/cudnn_version_test.cc
@@ -46,7 +46,7 @@ TEST(IsSourceCompatibleWithCudnnLibraryTest, Basic) {
       /*loaded_version=*/CudnnVersion(7, 0, 14)));
 
   // Returns true if the loaded version is equal or higher because minor version
-  // are backward compatible with CuDNN version 7.
+  // are backward compatible.
   EXPECT_TRUE(IsSourceCompatibleWithCudnnLibrary(
       /*source_version=*/CudnnVersion(7, 0, 14),
       /*loaded_version=*/CudnnVersion(7, 1, 14)));
@@ -56,15 +56,6 @@ TEST(IsSourceCompatibleWithCudnnLibraryTest, Basic) {
   EXPECT_FALSE(IsSourceCompatibleWithCudnnLibrary(
       /*source_version=*/CudnnVersion(7, 1, 15),
       /*loaded_version=*/CudnnVersion(7, 0, 14)));
-
-  // Returns false if minor versions are not matching for version 6. Before
-  // version 7, minor versions are also neither forward or backward compatible.
-  EXPECT_FALSE(IsSourceCompatibleWithCudnnLibrary(
-      /*source_version=*/CudnnVersion(6, 0, 14),
-      /*loaded_version=*/CudnnVersion(6, 1, 15)));
-  EXPECT_FALSE(IsSourceCompatibleWithCudnnLibrary(
-      /*source_version=*/CudnnVersion(6, 1, 14),
-      /*loaded_version=*/CudnnVersion(6, 0, 14)));
 }
 
 }  // namespace