message: Enable C API for gradients_test.py
diff: @@ -78,6 +78,7 @@ def _OpsBetween(graph, to_ops, from_ops):
  return between_ops
  +@test_util.with_c_api
  class GradientsTest(test_util.TensorFlowTestCase):
  def _OpNames(self, op_list):
  @@ -264,6 +265,10 @@ class GradientsTest(test_util.TensorFlowTestCase):
  self.assertEqual(10.0, grads[1].eval())
  def testNoGradientForStringOutputs(self):
  + # This test can't be run twice because the TestStringOutput gradient can
  + # only be registered once. Just run with the C API enabled.
  + if not ops._USE_C_API: return
  +
  with ops.Graph().as_default():
  def _TestOpGrad(_, float_grad, string_grad):
  @@ -409,6 +414,7 @@ class GradientsTest(test_util.TensorFlowTestCase):
  np.testing.assert_allclose(a, b)
  +@test_util.with_c_api
  class FunctionGradientsTest(test_util.TensorFlowTestCase):
  @classmethod
  @@ -498,6 +504,7 @@ class FunctionGradientsTest(test_util.TensorFlowTestCase):
  f.add_to_graph(ops.Graph())
  +@test_util.with_c_api
  class StopGradientTest(test_util.TensorFlowTestCase):
  def testStopGradient(self):
  @@ -508,6 +515,7 @@ class StopGradientTest(test_util.TensorFlowTestCase):
  assert igrad is None
  +@test_util.with_c_api
  class PreventGradientTest(test_util.TensorFlowTestCase):
  def testPreventGradient(self):
  @@ -518,6 +526,7 @@ class PreventGradientTest(test_util.TensorFlowTestCase):
  _ = gradients.gradients(out, inp)
  +@test_util.with_c_api
  class HessianVectorProductTest(test_util.TensorFlowTestCase):
  def testHessianVectorProduct(self):
  @@ -546,6 +555,7 @@ class HessianVectorProductTest(test_util.TensorFlowTestCase):
  self.assertAllClose(hess_v_value, hess_v_actual)
  +@test_util.with_c_api
  class HessianTest(test_util.TensorFlowTestCase):
  def testHessian1D(self):
  @@ -594,6 +604,7 @@ class HessianTest(test_util.TensorFlowTestCase):
  gradients.hessians(x, x)
  +@test_util.with_c_api
  class IndexedSlicesToTensorTest(test_util.TensorFlowTestCase):
  def testIndexedSlicesToTensor(self):
  @@ -651,6 +662,9 @@ class IndexedSlicesToTensorTest(test_util.TensorFlowTestCase):
  c_sparse = ops.IndexedSlices(
  array_ops.placeholder(dtypes.float32),
  array_ops.placeholder(dtypes.int32), constant([100, 100, 100, 100]))
  + # "always" filter prevents the warning from being suppressed if it was
  + # already triggered in a different test.
  + warnings.simplefilter("always")
  with warnings.catch_warnings(record=True) as w:
  math_ops.multiply(c_sparse, 1.0)
  self.assertEqual(1, len(w))
  @@ -671,6 +685,7 @@ class IndexedSlicesToTensorTest(test_util.TensorFlowTestCase):
  str(w[0].message))
  +@test_util.with_c_api
  class OnlyRealGradientsTest(test_util.TensorFlowTestCase):
  def testRealOnly(self):
  