From b3aa505f6ab71591628df0341f287afe29d065d5 Mon Sep 17 00:00:00 2001
From: Vijay Vasudevan <vrv@google.com>
Date: Thu, 3 Nov 2016 14:54:56 -0700
Subject: [PATCH 1/2] Revert "Use fast IDCT for JPEG decoding by default
 (#5072)"

This reverts commit 2aeedc38c604f3e9f028d696247512ea1c8522ee.
---
 tensorflow/core/lib/jpeg/jpeg_mem.cc          | 7 ++-----
 tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc | 2 +-
 tensorflow/python/ops/image_ops_test.py       | 4 ++--
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/tensorflow/core/lib/jpeg/jpeg_mem.cc b/tensorflow/core/lib/jpeg/jpeg_mem.cc
index 56c247560b0..426120b2100 100644
--- a/tensorflow/core/lib/jpeg/jpeg_mem.cc
+++ b/tensorflow/core/lib/jpeg/jpeg_mem.cc
@@ -139,11 +139,8 @@ uint8* UncompressLow(const void* srcdata, FewerArgsForCompiler* argball) {
   cinfo.do_fancy_upsampling = boolean(flags.fancy_upscaling);
   cinfo.scale_num = 1;
   cinfo.scale_denom = ratio;
-  // Activating this has a quality/speed trade-off implication.
-  // However, most JPEGs are already compressed, and so the faster IDCT
-  // should have no effect on training. The fast setting speeds up training on the
-  // GPU, e.g. by about 30% for smaller networks such as AlexNet.
-  cinfo.dct_method = JDCT_IFAST;
+  // Activating this has a quality/speed trade-off implication:
+  // cinfo.dct_method = JDCT_IFAST;
 
   jpeg_start_decompress(&cinfo);
 
diff --git a/tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc b/tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc
index fc3961ad6ae..d0b4bef5d47 100644
--- a/tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc
+++ b/tensorflow/core/lib/jpeg/jpeg_mem_unittest.cc
@@ -165,7 +165,7 @@ TEST(JpegMemTest, Jpeg2) {
     // Compare the two images
     const int totalerr = ComputeSumAbsoluteDifference(
         imgdata1.get(), refdata1.get(), in_w, in_h, stride1, stride1);
-    CHECK_LE(totalerr, 120000);
+    CHECK_LE(totalerr, 85000);
   }
 
   // check the second image too. Should be bitwise identical to the first.
diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py
index ef9d4706d18..b47ecd2f8fb 100644
--- a/tensorflow/python/ops/image_ops_test.py
+++ b/tensorflow/python/ops/image_ops_test.py
@@ -1803,10 +1803,10 @@ class JpegTest(test_util.TensorFlowTestCase):
       jpeg0, image0, image1, image2 = sess.run([jpeg0, image0, image1, image2])
 
       # The decoded-encoded image should be similar to the input
-      self.assertLess(self.averageError(image0, image1), 0.7)
+      self.assertLess(self.averageError(image0, image1), 0.6)
 
       # We should be very close to a fixpoint
-      self.assertLess(self.averageError(image1, image2), 0.6)
+      self.assertLess(self.averageError(image1, image2), 0.02)
 
       # Smooth ramps compress well (input size is 153600)
       self.assertGreaterEqual(len(jpeg0), 5000)

From 14bc025ffb79a224d027ca29ca5a8ab128ff6646 Mon Sep 17 00:00:00 2001
From: Vijay Vasudevan <vrv@google.com>
Date: Thu, 3 Nov 2016 14:57:22 -0700
Subject: [PATCH 2/2] Revert "Fix: replace deprecated nvcc flag with its
 replacement. (#5256)"

This reverts commit 988b53e1ba38900d1cac0fe49357d7fbeab8925a.
---
 tensorflow/tensorflow.bzl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index 388dba33b53..31b4461dad6 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -416,7 +416,7 @@ def _cuda_copts():
         "@local_config_cuda//cuda:using_nvcc": (
             common_cuda_opts +
             [
-                "-nvcc_options=expt-relaxed-constexpr",
+                "-nvcc_options=relaxed-constexpr",
                 "-nvcc_options=ftz=true",
             ]
         ),