From fe3bd66099d6e27bf45dabbe7f4cc34276194fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Wed, 1 Aug 2018 13:37:26 +0800 Subject: [PATCH 001/362] ENH: register float64 GPU kernel for Conv3d --- tensorflow/core/kernels/conv_ops_3d.cc | 14 +++++++++++++- tensorflow/core/kernels/conv_ops_gpu_3.cu.cc | 5 +++++ tensorflow/python/kernel_tests/conv_ops_3d_test.py | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tensorflow/core/kernels/conv_ops_3d.cc b/tensorflow/core/kernels/conv_ops_3d.cc index a1eed4e68c..009fd3733a 100644 --- a/tensorflow/core/kernels/conv_ops_3d.cc +++ b/tensorflow/core/kernels/conv_ops_3d.cc @@ -525,10 +525,19 @@ namespace functor { const GPUDevice& d, typename TTypes::ConstTensor in, \ const std::array& padding_left, \ const std::array& padding_right, \ - typename TTypes::Tensor out, TensorFormat format); + typename TTypes::Tensor out, TensorFormat format); \ + template <> \ + void NHWCToNCHW::operator()( \ + const GPUDevice& d, typename TTypes::ConstTensor in, \ + typename TTypes::Tensor out); \ + template <> \ + void NCHWToNHWC::operator()( \ + const GPUDevice& d, typename TTypes::ConstTensor in, \ + typename TTypes::Tensor out); DECLARE_GPU_SPEC(Eigen::half); DECLARE_GPU_SPEC(float); +DECLARE_GPU_SPEC(double); #undef DECLARE_GPU_SPEC } // namespace functor @@ -540,6 +549,9 @@ REGISTER_KERNEL_BUILDER( REGISTER_KERNEL_BUILDER( Name("Conv3D").Device(DEVICE_GPU).TypeConstraint("T"), Conv3DOp); +REGISTER_KERNEL_BUILDER( + Name("Conv3D").Device(DEVICE_GPU).TypeConstraint("T"), + Conv3DOp); #endif // GOOGLE_CUDA } // namespace tensorflow diff --git a/tensorflow/core/kernels/conv_ops_gpu_3.cu.cc b/tensorflow/core/kernels/conv_ops_gpu_3.cu.cc index a5fa48f85e..f8520cc307 100644 --- a/tensorflow/core/kernels/conv_ops_gpu_3.cu.cc +++ b/tensorflow/core/kernels/conv_ops_gpu_3.cu.cc @@ -1068,18 +1068,23 @@ template struct functor::PadInput; template struct functor::PadInput; // For 3d ops. +template struct functor::TransformFilter; template struct functor::TransformFilter; template struct functor::TransformFilter; +template struct functor::ReverseTransformFilter; template struct functor::ReverseTransformFilter; template struct functor::ReverseTransformFilter; +template struct functor::NHWCToNCHW; template struct functor::NHWCToNCHW; template struct functor::NHWCToNCHW; +template struct functor::NCHWToNHWC; template struct functor::NCHWToNHWC; template struct functor::NCHWToNHWC; +template struct functor::PadInput; template struct functor::PadInput; template struct functor::PadInput; diff --git a/tensorflow/python/kernel_tests/conv_ops_3d_test.py b/tensorflow/python/kernel_tests/conv_ops_3d_test.py index 0b531125f3..7a0f51dfef 100644 --- a/tensorflow/python/kernel_tests/conv_ops_3d_test.py +++ b/tensorflow/python/kernel_tests/conv_ops_3d_test.py @@ -52,11 +52,11 @@ class Conv3DTest(test.TestCase): def _DtypesToTest(self, use_gpu): if use_gpu: if not test_util.CudaSupportsHalfMatMulAndConv(): - return [dtypes.float32] + return [dtypes.float64, dtypes.float32] else: # It is important that float32 comes before float16 here, # as we will be using its gradients as reference for fp16 gradients. - return [dtypes.float32, dtypes.float16] + return [dtypes.float64, dtypes.float32, dtypes.float16] else: return [dtypes.float64, dtypes.float32, dtypes.float16] -- GitLab From c475edf9513d6bceae992775869fb9dd0b2c848a Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 24 Sep 2018 05:43:36 +0000 Subject: [PATCH 002/362] Fix for tf.keras.regularizers.{l1,l2}(0.) with tf.get_variable This fix tries to address the issue in 22470 where tf.keras.regularizers.{l1,l2}(l=0.) with tf.get_variable returns ``` AttributeError: 'float' object has no attribute 'name' ``` The issue only happens when `l=0.` as in that case, `regularization = 0.` was returned directly (and `0.` does not have a `name` attribute as a float number) This fix convert regularization = 0. to tensor. This fix fixes 22470. Signed-off-by: Yong Tang --- tensorflow/python/keras/regularizers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/keras/regularizers.py b/tensorflow/python/keras/regularizers.py index 28b6ad4c65..0d139d748c 100644 --- a/tensorflow/python/keras/regularizers.py +++ b/tensorflow/python/keras/regularizers.py @@ -20,6 +20,7 @@ from __future__ import print_function import six +from tensorflow.python.framework import ops from tensorflow.python.keras import backend as K from tensorflow.python.keras.utils.generic_utils import deserialize_keras_object from tensorflow.python.keras.utils.generic_utils import serialize_keras_object @@ -54,7 +55,7 @@ class L1L2(Regularizer): self.l2 = K.cast_to_floatx(l2) def __call__(self, x): - regularization = 0. + regularization = ops.convert_to_tensor(0.) if self.l1: regularization += math_ops.reduce_sum(self.l1 * math_ops.abs(x)) if self.l2: -- GitLab From 7f51123b0e8ab0532af04a5ccad3ab9605128db4 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 24 Sep 2018 05:51:09 +0000 Subject: [PATCH 003/362] Add dtype to convert_to_tensor Signed-off-by: Yong Tang --- tensorflow/python/keras/regularizers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/keras/regularizers.py b/tensorflow/python/keras/regularizers.py index 0d139d748c..fd0748f3ae 100644 --- a/tensorflow/python/keras/regularizers.py +++ b/tensorflow/python/keras/regularizers.py @@ -55,7 +55,7 @@ class L1L2(Regularizer): self.l2 = K.cast_to_floatx(l2) def __call__(self, x): - regularization = ops.convert_to_tensor(0.) + regularization = ops.convert_to_tensor(0., dtype=K.floatx()) if self.l1: regularization += math_ops.reduce_sum(self.l1 * math_ops.abs(x)) if self.l2: -- GitLab From 7efb78e55c9993068fdc82df3d2df9d989d111e4 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 10 Oct 2018 14:22:32 +0000 Subject: [PATCH 004/362] Add test case for tf.keras.regularizers.{l1,l2}(0.) with tf.get_variable Signed-off-by: Yong Tang --- tensorflow/python/keras/integration_test.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tensorflow/python/keras/integration_test.py b/tensorflow/python/keras/integration_test.py index 3c0f73b1c3..0e6fc79dd3 100644 --- a/tensorflow/python/keras/integration_test.py +++ b/tensorflow/python/keras/integration_test.py @@ -26,6 +26,7 @@ from tensorflow.python.keras import testing_utils from tensorflow.python.layers import core as tf_core_layers from tensorflow.python.ops import nn from tensorflow.python.ops import rnn_cell +from tensorflow.python.ops import variable_scope from tensorflow.python.platform import test @@ -312,6 +313,15 @@ class KerasIntegrationTest(test.TestCase): verbose=0) self.assertGreater(history.history['val_acc'][-1], 0.7) + def test_regularizers_with_get_variable(self): + # Test case for GitHub issue 22470. + with self.cached_session(): + v = variable_scope.get_variable( + "v", + shape = [4, 4], + initializer=keras.initializers.glorot_uniform(), + regularizer=keras.regularizers.l2(0.)) + if __name__ == '__main__': test.main() -- GitLab From 1bae040045254e1ca51366391d52bb79b8c1b067 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 15 Oct 2018 22:21:21 +0000 Subject: [PATCH 005/362] Update the documentation for tf.fft This fix is related to 17332. While complex128 has been added in tf, the documentation still says: ``` tf.spectral.fft input: A Tensor. Must be one of the following types: complex64, complex128. A complex64 tensor. ``` This fix updates the documentation so that it matches the actual behavior. Signed-off-by: Yong Tang --- tensorflow/core/api_def/base_api/api_def_FFT.pbtxt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/core/api_def/base_api/api_def_FFT.pbtxt b/tensorflow/core/api_def/base_api/api_def_FFT.pbtxt index 4e48d6c169..0ba2327371 100644 --- a/tensorflow/core/api_def/base_api/api_def_FFT.pbtxt +++ b/tensorflow/core/api_def/base_api/api_def_FFT.pbtxt @@ -3,13 +3,13 @@ op { in_arg { name: "input" description: < Date: Mon, 15 Oct 2018 22:23:22 +0000 Subject: [PATCH 006/362] Update documentation for tf.ifft/ifft2d/fft2d Signed-off-by: Yong Tang --- tensorflow/core/api_def/base_api/api_def_FFT2D.pbtxt | 4 ++-- tensorflow/core/api_def/base_api/api_def_IFFT.pbtxt | 4 ++-- tensorflow/core/api_def/base_api/api_def_IFFT2D.pbtxt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tensorflow/core/api_def/base_api/api_def_FFT2D.pbtxt b/tensorflow/core/api_def/base_api/api_def_FFT2D.pbtxt index 555f8e6067..c7b780a56f 100644 --- a/tensorflow/core/api_def/base_api/api_def_FFT2D.pbtxt +++ b/tensorflow/core/api_def/base_api/api_def_FFT2D.pbtxt @@ -3,13 +3,13 @@ op { in_arg { name: "input" description: < Date: Wed, 24 Oct 2018 01:48:08 +0000 Subject: [PATCH 007/362] Resolved merge conflicts and squashed into one commit --- tensorflow/python/ops/cond_v2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tensorflow/python/ops/cond_v2.py b/tensorflow/python/ops/cond_v2.py index 998c3e08f6..175b53b1a2 100644 --- a/tensorflow/python/ops/cond_v2.py +++ b/tensorflow/python/ops/cond_v2.py @@ -136,11 +136,11 @@ def cond_v2(pred, true_fn, false_fn, name="cond"): # correct output structure tensors = tuple(array_ops.identity(t) for t in tensors) - result = tuple(tensors[:num_cond_outputs]) - if len(result) == 1: - return result[0] - else: - return result + # Packing output tensors in the same nested structure as the true and false + # functions return + result = nest.pack_sequence_as(structure=true_graph.structured_outputs, + flat_sequence=tensors[:num_cond_outputs]) + return result @ops.RegisterGradient("If") -- GitLab From ddd89530bf5022996c2f3564a5af0eda08eb81d2 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 24 Oct 2018 01:55:01 +0000 Subject: [PATCH 008/362] Forgot to update tests --- .../kernel_tests/control_flow_ops_py_test.py | 258 ++++++++---------- 1 file changed, 113 insertions(+), 145 deletions(-) diff --git a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py index 6487503ff9..7a746ca362 100644 --- a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py +++ b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py @@ -22,7 +22,6 @@ from __future__ import print_function import collections import math -import sys import time import numpy as np @@ -456,7 +455,7 @@ class ControlFlowTest(test.TestCase): self.assertTrue(ind.dtype == np.int64) def testCondColocation(self): - with self.session(use_gpu=True): + with self.test_session(use_gpu=True): with ops.device("/cpu:0"): v = variables.Variable(7.0) @@ -471,7 +470,7 @@ class ControlFlowTest(test.TestCase): self.assertDeviceEqual(op.device, "/cpu:0") def _testCond_1(self, use_gpu): - with self.cached_session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): x = constant_op.constant(10) pred = math_ops.less(1, 2) fn1 = lambda: math_ops.add(x, 1) @@ -510,40 +509,27 @@ class ControlFlowTest(test.TestCase): result = r.eval() self.assertAllEqual(12, result) - @test_util.run_in_graph_and_eager_modes - def testCondPruning(self): - v1 = variables.Variable(7) - v2 = variables.Variable(7) - v3 = variables.Variable(7) + @test_util.disable_control_flow_v2("b/113324949 (ref vars)") + def testCond_4(self): + with self.cached_session(): + v1 = variables.Variable(7) + v2 = variables.Variable(7) + v3 = variables.Variable(7) - def f(): age = constant_op.constant(3) max_age = constant_op.constant(2) pred = math_ops.greater(age, max_age) fn1 = lambda: [state_ops.assign(v1, 1).op, state_ops.assign(v2, 2).op] fn2 = lambda: [state_ops.assign(v3, 3).op, constant_op.constant(10).op] r = control_flow_ops.cond(pred, fn1, fn2) - self.assertEqual(len(r), 2) - return r[1] - f_defun = eager_function.defun(f) - - if not context.executing_eagerly(): - with self.cached_session(): - variables.global_variables_initializer().run() - result = f().eval() - self.assertEqual(True, result) - # Only second cond result was fetched, so v1 assign shouldn't run. - self.assertEqual(7, v1.eval()) - self.assertEqual(2, v2.eval()) - self.assertEqual(7, v3.eval()) - - result = f_defun() - self.assertEqual(True, self.evaluate(result)) - # Both v1 and v2 branch assignments should be run in defun. - self.assertEqual(1, self.evaluate(v1)) - self.assertEqual(2, self.evaluate(v2)) - self.assertEqual(7, self.evaluate(v3)) + variables.global_variables_initializer().run() + self.assertEqual(len(r), 2) + result = r[1].eval() + self.assertAllEqual(True, result) + self.assertAllEqual(7, v1.eval()) + self.assertAllEqual(2, v2.eval()) + self.assertAllEqual(7, v3.eval()) def testCond_5(self): with self.cached_session(): @@ -584,6 +570,85 @@ class ControlFlowTest(test.TestCase): r = control_flow_ops.cond(pred, fn1, fn2) self.assertAllEqual([11, 12], sess.run(r)) + def testCondListOutput(self): + with self.cached_session() as sess: + x = constant_op.constant(10) + y = constant_op.constant(200) + pred = math_ops.less(1, 2) + fn1 = lambda: [math_ops.add(x, y), math_ops.add(x, y)] + fn2 = lambda: [y, y] + r = control_flow_ops.cond(pred, fn1, fn2) + test_result = sess.run(r) + self.assertListEqual([210, 210], test_result) + + def testTupleOutput(self): + with self.cached_session() as sess: + x = constant_op.constant(10) + y = constant_op.constant(200) + pred = math_ops.less(1, 2) + fn1 = lambda: (math_ops.add(x, y), math_ops.add(x, y)) + fn2 = lambda: (y, y) + r = control_flow_ops.cond(pred, fn1, fn2) + test_result = sess.run(r) + self.assertTupleEqual((210, 210), test_result) + + def testDictOutput(self): + with self.cached_session() as sess: + x = constant_op.constant(10) + y = constant_op.constant(200) + pred = math_ops.less(1, 2) + fn1 = lambda: {"a": math_ops.add(x, y), "b": math_ops.add(x, y)} + fn2 = lambda: {"a": y, "b": y} + r = control_flow_ops.cond(pred, fn1, fn2) + test_result = sess.run(r) + self.assertDictEqual({"a": 210, "b": 210}, test_result) + + def testNestedListOutput(self): + with self.cached_session() as sess: + x = constant_op.constant(10) + y = constant_op.constant(200) + pred = math_ops.less(1, 2) + fn1 = lambda: [[math_ops.add(x, y), math_ops.add(x, y)]] + fn2 = lambda: [[y, y]] + # Pass strict=True flag as cond_v2 allows for tensors to be + # in nested output structures as singletons + r = control_flow_ops.cond(pred, fn1, fn2, strict=True) + test_result = sess.run(r) + self.assertListEqual([[210, 210]], test_result) + + def testNestedTupleOutput(self): + with self.cached_session() as sess: + x = constant_op.constant(10) + y = constant_op.constant(200) + pred = math_ops.less(1, 2) + fn1 = lambda: ((math_ops.add(x, y), math_ops.add(x, y))) + fn2 = lambda: ((y, y)) + r = control_flow_ops.cond(pred, fn1, fn2) + test_result = sess.run(r) + self.assertTupleEqual(((210, 210)), test_result) + + def testNestedDictOutput(self): + with self.cached_session() as sess: + x = constant_op.constant(10) + y = constant_op.constant(200) + pred = math_ops.less(1, 2) + fn1 = lambda: {"a": {"c": math_ops.add(x, y)}, "b": {"d": math_ops.add(x, y)}} + fn2 = lambda: {"a": {"c": y}, "b": {"d": y}} + r = control_flow_ops.cond(pred, fn1, fn2) + test_result = sess.run(r) + self.assertDictEqual({"a": {"c": 210}, "b": {"d": 210}}, test_result) + + def testCheckNestedOutputStruct(self): + with self.cached_session() as sess: + x = constant_op.constant(10) + y = constant_op.constant(200) + pred = math_ops.less(1, 2) + fn1 = lambda: {"a": math_ops.add(x, y), "b": math_ops.add(x, y)} + fn2 = lambda: {"c": y, "d": y} + with self.assertRaisesRegexp(ValueError, "The two structures don't have the same nested structure"): + r = control_flow_ops.cond(pred, fn1, fn2) + test_result = sess.run(r) + def testCondRef(self): with self.cached_session(): @@ -638,6 +703,8 @@ class ControlFlowTest(test.TestCase): merged_op = control_flow_ops.merge([assign_v, orig_v]) self.assertAllEqual([1.0], sess.run(merged_op.output)) + @test_util.disable_control_flow_v2( + "b/112477618 (Operation returned from cond)") def testCondSwitchIdentity(self): # Make sure the recv identity is not removed by optimization. with session.Session(config=opt_cfg()) as sess: @@ -652,6 +719,8 @@ class ControlFlowTest(test.TestCase): r = control_flow_ops.cond(pred, fn1, fn2) sess.run(r) + @test_util.disable_control_flow_v2( + "b/112477618 (Operation returned from cond)") def testCondRecvIdentity(self): # Make sure the switch identity is not removed by optimization. with session.Session(config=opt_cfg()) as sess: @@ -750,111 +819,6 @@ class ControlFlowTest(test.TestCase): ] self.assertAllEqual(dense_gv, [0.0, 2.0]) - # TODO(b/117945658): reenable - @test_util.run_in_graph_and_eager_modes - def DISABLED_testCondAutoControlDeps(self): - - def branch_fn(): - logging_ops.print_v2("A") - logging_ops.print_v2("B") - with ops.control_dependencies([logging_ops.print_v2("C")]): - return constant_op.constant(10) - - def build_cond(): - return control_flow_ops.cond( - constant_op.constant(True), branch_fn, lambda: 0) - - def build_nested_cond(): - return control_flow_ops.cond( - constant_op.constant(True), build_cond, lambda: 0) - - # In v1 graph mode, pruning should make only "C" print. - if not context.executing_eagerly(): - with self.cached_session(): - with self.captureWritesToStream(sys.stderr) as printed: - self.assertEqual(build_cond().eval(), 10) - self.assertEqual(printed.contents(), "C\n") - - with self.captureWritesToStream(sys.stderr) as printed: - self.assertEqual(build_nested_cond().eval(), 10) - self.assertEqual(printed.contents(), "C\n") - - # In defuns, all prints should execute in program order. - # This doesn't work with legacy control flow. - if control_flow_ops.ENABLE_COND_V2: - - @eager_function.defun - def cond(): - return build_cond() - - with self.captureWritesToStream(sys.stderr) as printed: - self.assertEqual(self.evaluate(cond()), 10) - self.assertEqual(printed.contents(), "A\nB\nC\n") - - @eager_function.defun - def nested_cond(): - return build_nested_cond() - - with self.captureWritesToStream(sys.stderr) as printed: - self.assertEqual(self.evaluate(nested_cond()), 10) - self.assertEqual(printed.contents(), "A\nB\nC\n") - - # TODO(b/117945658): reenable - @test_util.run_in_graph_and_eager_modes - def DISABLED_testWhileAutoControlDeps(self): - - def cond(i, unused_x): - logging_ops.print_v2("A") - return i < 2 - - def body(i, x): - logging_ops.print_v2("B") - with ops.control_dependencies([logging_ops.print_v2("C")]): - x = array_ops.identity(x) - with ops.control_dependencies([logging_ops.print_v2("D")]): - return i + 1, x - - def build_while(): - return control_flow_ops.while_loop( - cond, body, [constant_op.constant(0), constant_op.constant(0)]) - - def build_nested_while(): - return control_flow_ops.cond( - constant_op.constant(True), build_while, lambda: (0, 0)) - - # In v1 graph mode, pruning should make only "D" print. - if not context.executing_eagerly(): - with self.cached_session(): - with self.captureWritesToStream(sys.stderr) as printed: - self.assertEqual(build_while()[0].eval(), 2) - self.assertEqual(printed.contents(), "D\nD\n") - - with self.captureWritesToStream(sys.stderr) as printed: - self.assertEqual(build_nested_while()[0].eval(), 2) - self.assertEqual(printed.contents(), "D\nD\n") - - # In defuns, all prints should execute in program order. - # This doesn't work with legacy control flow. - if control_flow_ops.ENABLE_WHILE_V2: - - @eager_function.defun - def while_loop(): - return build_while()[0] - - with self.captureWritesToStream(sys.stderr) as printed: - self.assertEqual(self.evaluate(while_loop()), 2) - self.assertEqual(printed.contents(), "A\nB\nC\nD\nA\nB\nC\nD\nA\n") - - @eager_function.defun - def nested_while_loop(): - return build_nested_while()[0] - - # TODO(b/117840611): calling nested_while_loop fails in eager - if not context.executing_eagerly(): - with self.captureWritesToStream(sys.stderr) as printed: - self.assertEqual(self.evaluate(nested_while_loop()), 2) - self.assertEqual(printed.contents(), "A\nB\nC\nD\nA\nB\nC\nD\nA\n") - # Microbenchmark: 256,000 iterations/s. @test_util.disable_control_flow_v2("b/116630618 (Times out)") def testWhile_1(self): @@ -1089,7 +1053,7 @@ class ControlFlowTest(test.TestCase): final_without_xla_context = create_while_loop() - with self.session(use_gpu=False) as sess: + with self.test_session(use_gpu=False) as sess: opts = config_pb2.RunOptions(trace_level=config_pb2.RunOptions.FULL_TRACE) run_metadata = config_pb2.RunMetadata() @@ -1205,7 +1169,7 @@ class ControlFlowTest(test.TestCase): self.assertLess(len(unique_allocs), 756) def _testWhile_Gpu_1(self, use_gpu): - with self.cached_session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): n = constant_op.constant(1.0) c = lambda x: math_ops.less(x, 10.0) b = lambda x: math_ops.add(x, 1.0) @@ -1217,7 +1181,7 @@ class ControlFlowTest(test.TestCase): self._testWhile_Gpu_1(use_gpu=True) def _testWhile_Gpu_2(self, use_gpu): - with self.cached_session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): n = constant_op.constant(1.0) c = lambda x: math_ops.less(x, 10.0) @@ -1359,7 +1323,7 @@ class ControlFlowTest(test.TestCase): [i.get_shape(), tensor_shape.TensorShape([None, 5])]) def _testNestedWhile_1(self, use_gpu): - with self.cached_session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): n = constant_op.constant(0) def cpu_sum(s): @@ -1386,7 +1350,7 @@ class ControlFlowTest(test.TestCase): def _testNestedWhile_2(self, use_gpu): # Test the cases that A -> Enter and Exit -> A are partitioned. - with self.cached_session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): s0 = constant_op.constant(2.0) def inner_loop(s): @@ -1565,7 +1529,7 @@ class ControlFlowTest(test.TestCase): self.assertAllEqual(10, r.eval()) def _testCondWhile_3(self, use_gpu): - with self.cached_session(use_gpu=use_gpu) as sess: + with self.test_session(use_gpu=use_gpu) as sess: p = array_ops.placeholder(dtypes.bool) n = constant_op.constant(0.0) @@ -1947,7 +1911,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(2048.0, r.eval()) def _testWhileGrad_Mul(self, use_gpu, p_iters): - with self.cached_session(use_gpu=use_gpu) as sess: + with self.test_session(use_gpu=use_gpu) as sess: a = constant_op.constant(3.0, name="a") v = constant_op.constant(2.0, name="v") c = lambda v: math_ops.less(v, 100.0) @@ -1967,7 +1931,7 @@ class ControlFlowTest(test.TestCase): def _testNestedWhileCondWhileGrad(self, use_gpu): - with self.cached_session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): v = constant_op.constant(1.0) def inner_loop(s): @@ -2273,7 +2237,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(1.0, g.eval()) # y_f_d = x + 1.0, dy_f_d/dx = 1.0 def _testNestedWhileGrad_Simple(self, use_gpu): - with self.cached_session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): v = constant_op.constant(1.0) def inner_loop(s): @@ -2366,7 +2330,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(2.999, var.eval()) def _testWhileCondGrad_Simple(self, use_gpu): - with self.cached_session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): v = ops.convert_to_tensor(2.0, name="v") n = ops.convert_to_tensor(100.0, name="n") one = ops.convert_to_tensor(1.0, name="one") @@ -2777,6 +2741,8 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(4.0, i.eval(feed_dict={d: 1})) self.assertAllClose(2.0 * math.sqrt(2), i.eval(feed_dict={d: 2})) + @test_util.disable_control_flow_v2( + "b/112477618 (Operation returned from cond)") def testCase(self): with self.cached_session(): x = constant_op.constant(1) @@ -2829,6 +2795,8 @@ class ControlFlowTest(test.TestCase): self.assertAllEqual(r6.eval(), 0) + @test_util.disable_control_flow_v2( + "b/112477618 (Operation returned from cond)") def testCaseSideEffects(self): with self.cached_session() as sess: v0 = variables.Variable(-1) @@ -3361,7 +3329,7 @@ class TupleTest(test.TestCase): class AssertTest(test.TestCase): def testGuardedAssertDoesNotCopyWhenTrue(self): - with self.session(use_gpu=True) as sess: + with self.test_session(use_gpu=True) as sess: with ops.device(test.gpu_device_name()): value = constant_op.constant(1.0) with ops.device("/cpu:0"): -- GitLab From 5e8a5e488b80f544cf810404cfd380305638df10 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 24 Oct 2018 01:59:54 +0000 Subject: [PATCH 009/362] Commited wrong test file --- .../kernel_tests/control_flow_ops_py_test.py | 186 ++++++++++++++---- 1 file changed, 148 insertions(+), 38 deletions(-) diff --git a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py index 7a746ca362..98f8fd4e96 100644 --- a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py +++ b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py @@ -22,6 +22,7 @@ from __future__ import print_function import collections import math +import sys import time import numpy as np @@ -455,7 +456,7 @@ class ControlFlowTest(test.TestCase): self.assertTrue(ind.dtype == np.int64) def testCondColocation(self): - with self.test_session(use_gpu=True): + with self.session(use_gpu=True): with ops.device("/cpu:0"): v = variables.Variable(7.0) @@ -470,7 +471,7 @@ class ControlFlowTest(test.TestCase): self.assertDeviceEqual(op.device, "/cpu:0") def _testCond_1(self, use_gpu): - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): x = constant_op.constant(10) pred = math_ops.less(1, 2) fn1 = lambda: math_ops.add(x, 1) @@ -509,27 +510,40 @@ class ControlFlowTest(test.TestCase): result = r.eval() self.assertAllEqual(12, result) - @test_util.disable_control_flow_v2("b/113324949 (ref vars)") - def testCond_4(self): - with self.cached_session(): - v1 = variables.Variable(7) - v2 = variables.Variable(7) - v3 = variables.Variable(7) + @test_util.run_in_graph_and_eager_modes + def testCondPruning(self): + v1 = variables.Variable(7) + v2 = variables.Variable(7) + v3 = variables.Variable(7) + def f(): age = constant_op.constant(3) max_age = constant_op.constant(2) pred = math_ops.greater(age, max_age) fn1 = lambda: [state_ops.assign(v1, 1).op, state_ops.assign(v2, 2).op] fn2 = lambda: [state_ops.assign(v3, 3).op, constant_op.constant(10).op] r = control_flow_ops.cond(pred, fn1, fn2) - - variables.global_variables_initializer().run() self.assertEqual(len(r), 2) - result = r[1].eval() - self.assertAllEqual(True, result) - self.assertAllEqual(7, v1.eval()) - self.assertAllEqual(2, v2.eval()) - self.assertAllEqual(7, v3.eval()) + return r[1] + + f_defun = eager_function.defun(f) + + if not context.executing_eagerly(): + with self.cached_session(): + variables.global_variables_initializer().run() + result = f().eval() + self.assertEqual(True, result) + # Only second cond result was fetched, so v1 assign shouldn't run. + self.assertEqual(7, v1.eval()) + self.assertEqual(2, v2.eval()) + self.assertEqual(7, v3.eval()) + + result = f_defun() + self.assertEqual(True, self.evaluate(result)) + # Both v1 and v2 branch assignments should be run in defun. + self.assertEqual(1, self.evaluate(v1)) + self.assertEqual(2, self.evaluate(v2)) + self.assertEqual(7, self.evaluate(v3)) def testCond_5(self): with self.cached_session(): @@ -546,7 +560,6 @@ class ControlFlowTest(test.TestCase): self.assertAllEqual(4, count.eval()) def testCond_6(self): - with self.cached_session(): v1 = variables.Variable([7]) @@ -603,7 +616,7 @@ class ControlFlowTest(test.TestCase): test_result = sess.run(r) self.assertDictEqual({"a": 210, "b": 210}, test_result) - def testNestedListOutput(self): + def testEmbeddedListOutput(self): with self.cached_session() as sess: x = constant_op.constant(10) y = constant_op.constant(200) @@ -616,7 +629,7 @@ class ControlFlowTest(test.TestCase): test_result = sess.run(r) self.assertListEqual([[210, 210]], test_result) - def testNestedTupleOutput(self): + def testEmbeddedTupleOutput(self): with self.cached_session() as sess: x = constant_op.constant(10) y = constant_op.constant(200) @@ -627,7 +640,7 @@ class ControlFlowTest(test.TestCase): test_result = sess.run(r) self.assertTupleEqual(((210, 210)), test_result) - def testNestedDictOutput(self): + def testEmbeddedDictOutput(self): with self.cached_session() as sess: x = constant_op.constant(10) y = constant_op.constant(200) @@ -703,8 +716,6 @@ class ControlFlowTest(test.TestCase): merged_op = control_flow_ops.merge([assign_v, orig_v]) self.assertAllEqual([1.0], sess.run(merged_op.output)) - @test_util.disable_control_flow_v2( - "b/112477618 (Operation returned from cond)") def testCondSwitchIdentity(self): # Make sure the recv identity is not removed by optimization. with session.Session(config=opt_cfg()) as sess: @@ -719,8 +730,6 @@ class ControlFlowTest(test.TestCase): r = control_flow_ops.cond(pred, fn1, fn2) sess.run(r) - @test_util.disable_control_flow_v2( - "b/112477618 (Operation returned from cond)") def testCondRecvIdentity(self): # Make sure the switch identity is not removed by optimization. with session.Session(config=opt_cfg()) as sess: @@ -819,6 +828,111 @@ class ControlFlowTest(test.TestCase): ] self.assertAllEqual(dense_gv, [0.0, 2.0]) + # TODO(b/117945658): reenable + @test_util.run_in_graph_and_eager_modes + def DISABLED_testCondAutoControlDeps(self): + + def branch_fn(): + logging_ops.print_v2("A") + logging_ops.print_v2("B") + with ops.control_dependencies([logging_ops.print_v2("C")]): + return constant_op.constant(10) + + def build_cond(): + return control_flow_ops.cond( + constant_op.constant(True), branch_fn, lambda: 0) + + def build_nested_cond(): + return control_flow_ops.cond( + constant_op.constant(True), build_cond, lambda: 0) + + # In v1 graph mode, pruning should make only "C" print. + if not context.executing_eagerly(): + with self.cached_session(): + with self.captureWritesToStream(sys.stderr) as printed: + self.assertEqual(build_cond().eval(), 10) + self.assertEqual(printed.contents(), "C\n") + + with self.captureWritesToStream(sys.stderr) as printed: + self.assertEqual(build_nested_cond().eval(), 10) + self.assertEqual(printed.contents(), "C\n") + + # In defuns, all prints should execute in program order. + # This doesn't work with legacy control flow. + if control_flow_ops.ENABLE_COND_V2: + + @eager_function.defun + def cond(): + return build_cond() + + with self.captureWritesToStream(sys.stderr) as printed: + self.assertEqual(self.evaluate(cond()), 10) + self.assertEqual(printed.contents(), "A\nB\nC\n") + + @eager_function.defun + def nested_cond(): + return build_nested_cond() + + with self.captureWritesToStream(sys.stderr) as printed: + self.assertEqual(self.evaluate(nested_cond()), 10) + self.assertEqual(printed.contents(), "A\nB\nC\n") + + # TODO(b/117945658): reenable + @test_util.run_in_graph_and_eager_modes + def DISABLED_testWhileAutoControlDeps(self): + + def cond(i, unused_x): + logging_ops.print_v2("A") + return i < 2 + + def body(i, x): + logging_ops.print_v2("B") + with ops.control_dependencies([logging_ops.print_v2("C")]): + x = array_ops.identity(x) + with ops.control_dependencies([logging_ops.print_v2("D")]): + return i + 1, x + + def build_while(): + return control_flow_ops.while_loop( + cond, body, [constant_op.constant(0), constant_op.constant(0)]) + + def build_nested_while(): + return control_flow_ops.cond( + constant_op.constant(True), build_while, lambda: (0, 0)) + + # In v1 graph mode, pruning should make only "D" print. + if not context.executing_eagerly(): + with self.cached_session(): + with self.captureWritesToStream(sys.stderr) as printed: + self.assertEqual(build_while()[0].eval(), 2) + self.assertEqual(printed.contents(), "D\nD\n") + + with self.captureWritesToStream(sys.stderr) as printed: + self.assertEqual(build_nested_while()[0].eval(), 2) + self.assertEqual(printed.contents(), "D\nD\n") + + # In defuns, all prints should execute in program order. + # This doesn't work with legacy control flow. + if control_flow_ops.ENABLE_WHILE_V2: + + @eager_function.defun + def while_loop(): + return build_while()[0] + + with self.captureWritesToStream(sys.stderr) as printed: + self.assertEqual(self.evaluate(while_loop()), 2) + self.assertEqual(printed.contents(), "A\nB\nC\nD\nA\nB\nC\nD\nA\n") + + @eager_function.defun + def nested_while_loop(): + return build_nested_while()[0] + + # TODO(b/117840611): calling nested_while_loop fails in eager + if not context.executing_eagerly(): + with self.captureWritesToStream(sys.stderr) as printed: + self.assertEqual(self.evaluate(nested_while_loop()), 2) + self.assertEqual(printed.contents(), "A\nB\nC\nD\nA\nB\nC\nD\nA\n") + # Microbenchmark: 256,000 iterations/s. @test_util.disable_control_flow_v2("b/116630618 (Times out)") def testWhile_1(self): @@ -1053,7 +1167,7 @@ class ControlFlowTest(test.TestCase): final_without_xla_context = create_while_loop() - with self.test_session(use_gpu=False) as sess: + with self.session(use_gpu=False) as sess: opts = config_pb2.RunOptions(trace_level=config_pb2.RunOptions.FULL_TRACE) run_metadata = config_pb2.RunMetadata() @@ -1169,7 +1283,7 @@ class ControlFlowTest(test.TestCase): self.assertLess(len(unique_allocs), 756) def _testWhile_Gpu_1(self, use_gpu): - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): n = constant_op.constant(1.0) c = lambda x: math_ops.less(x, 10.0) b = lambda x: math_ops.add(x, 1.0) @@ -1181,7 +1295,7 @@ class ControlFlowTest(test.TestCase): self._testWhile_Gpu_1(use_gpu=True) def _testWhile_Gpu_2(self, use_gpu): - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): n = constant_op.constant(1.0) c = lambda x: math_ops.less(x, 10.0) @@ -1323,7 +1437,7 @@ class ControlFlowTest(test.TestCase): [i.get_shape(), tensor_shape.TensorShape([None, 5])]) def _testNestedWhile_1(self, use_gpu): - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): n = constant_op.constant(0) def cpu_sum(s): @@ -1350,7 +1464,7 @@ class ControlFlowTest(test.TestCase): def _testNestedWhile_2(self, use_gpu): # Test the cases that A -> Enter and Exit -> A are partitioned. - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): s0 = constant_op.constant(2.0) def inner_loop(s): @@ -1529,7 +1643,7 @@ class ControlFlowTest(test.TestCase): self.assertAllEqual(10, r.eval()) def _testCondWhile_3(self, use_gpu): - with self.test_session(use_gpu=use_gpu) as sess: + with self.cached_session(use_gpu=use_gpu) as sess: p = array_ops.placeholder(dtypes.bool) n = constant_op.constant(0.0) @@ -1911,7 +2025,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(2048.0, r.eval()) def _testWhileGrad_Mul(self, use_gpu, p_iters): - with self.test_session(use_gpu=use_gpu) as sess: + with self.cached_session(use_gpu=use_gpu) as sess: a = constant_op.constant(3.0, name="a") v = constant_op.constant(2.0, name="v") c = lambda v: math_ops.less(v, 100.0) @@ -1931,7 +2045,7 @@ class ControlFlowTest(test.TestCase): def _testNestedWhileCondWhileGrad(self, use_gpu): - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): v = constant_op.constant(1.0) def inner_loop(s): @@ -2237,7 +2351,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(1.0, g.eval()) # y_f_d = x + 1.0, dy_f_d/dx = 1.0 def _testNestedWhileGrad_Simple(self, use_gpu): - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): v = constant_op.constant(1.0) def inner_loop(s): @@ -2330,7 +2444,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(2.999, var.eval()) def _testWhileCondGrad_Simple(self, use_gpu): - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): v = ops.convert_to_tensor(2.0, name="v") n = ops.convert_to_tensor(100.0, name="n") one = ops.convert_to_tensor(1.0, name="one") @@ -2741,8 +2855,6 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(4.0, i.eval(feed_dict={d: 1})) self.assertAllClose(2.0 * math.sqrt(2), i.eval(feed_dict={d: 2})) - @test_util.disable_control_flow_v2( - "b/112477618 (Operation returned from cond)") def testCase(self): with self.cached_session(): x = constant_op.constant(1) @@ -2795,8 +2907,6 @@ class ControlFlowTest(test.TestCase): self.assertAllEqual(r6.eval(), 0) - @test_util.disable_control_flow_v2( - "b/112477618 (Operation returned from cond)") def testCaseSideEffects(self): with self.cached_session() as sess: v0 = variables.Variable(-1) @@ -3329,7 +3439,7 @@ class TupleTest(test.TestCase): class AssertTest(test.TestCase): def testGuardedAssertDoesNotCopyWhenTrue(self): - with self.test_session(use_gpu=True) as sess: + with self.session(use_gpu=True) as sess: with ops.device(test.gpu_device_name()): value = constant_op.constant(1.0) with ops.device("/cpu:0"): -- GitLab From 183324ff17b4669707731fea957a1648e754960d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 25 Oct 2018 00:34:46 +0000 Subject: [PATCH 010/362] Fixed versioning error --- tensorflow/python/ops/cond_v2.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tensorflow/python/ops/cond_v2.py b/tensorflow/python/ops/cond_v2.py index 175b53b1a2..714cfbf4db 100644 --- a/tensorflow/python/ops/cond_v2.py +++ b/tensorflow/python/ops/cond_v2.py @@ -468,6 +468,10 @@ def _check_same_outputs(true_graph, false_graph): " true_fn: %s\n" " false_fn: %s" % (true_output_types, false_output_types)) + # Make sure both structured outputs for both graphs have the same structure + nest.assert_same_structure(true_graph.structured_outputs, + false_graph.structured_outputs) + def _get_output_shapes(true_graph_outputs, false_graph_outputs): output_shapes = [ -- GitLab From 1dd6c365ef424a4757da4bf562294fb2bc51dbca Mon Sep 17 00:00:00 2001 From: BY Shen Date: Tue, 30 Oct 2018 12:40:36 +0800 Subject: [PATCH 011/362] Update .gitignore for tflite downloads directory. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1ef4c297ee..8d7808ba01 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ Pods Podfile.lock *.pbxproj *.xcworkspacedata -/tensorflow/contrib/lite/downloads/** +/tensorflow/contrib/lite/tools/make/downloads/** /tensorflow/contrib/lite/gen/** /tensorflow/contrib/lite/examples/ios/simple/data/*.txt /tensorflow/contrib/lite/examples/ios/simple/data/*.tflite -- GitLab From 2711e155b9d4ce280efe52d00d65a2b52c5be473 Mon Sep 17 00:00:00 2001 From: zldrobit Date: Wed, 31 Oct 2018 12:20:35 +0800 Subject: [PATCH 012/362] add dynamic shape support to dense_image_warp --- .../image/python/ops/dense_image_warp.py | 74 +++++++++++-------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/tensorflow/contrib/image/python/ops/dense_image_warp.py b/tensorflow/contrib/image/python/ops/dense_image_warp.py index 9c7ada7afb..2ac7ff2a6b 100644 --- a/tensorflow/contrib/image/python/ops/dense_image_warp.py +++ b/tensorflow/contrib/image/python/ops/dense_image_warp.py @@ -25,7 +25,7 @@ from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops - +from tensorflow.python.ops import check_ops def _interpolate_bilinear(grid, query_points, @@ -60,28 +60,34 @@ def _interpolate_bilinear(grid, msg = 'Grid must be 4 dimensional. Received size: ' raise ValueError(msg + str(grid.get_shape())) - batch_size, height, width, channels = shape + batch_size, height, width, channels = \ + array_ops.shape(grid)[0], \ + array_ops.shape(grid)[1], \ + array_ops.shape(grid)[2], \ + array_ops.shape(grid)[3] + shape = [batch_size, height, width, channels] query_type = query_points.dtype grid_type = grid.dtype - if (query_points.shape.rank != 3 or - query_points.shape.dims[2].value != 2): - msg = ('Query points must be 3 dimensional and size 2 in dim 2. Received ' - 'size: ') - raise ValueError(msg + str(query_points.get_shape())) - - _, num_queries, _ = query_points.get_shape().as_list() - - if height < 2 or width < 2: - msg = 'Grid must be at least batch_size x 2 x 2 in size. Received size: ' - raise ValueError(msg + str(grid.get_shape())) - - alphas = [] - floors = [] - ceils = [] - - index_order = [0, 1] if indexing == 'ij' else [1, 0] - unstacked_query_points = array_ops.unstack(query_points, axis=2) + with ops.control_dependencies([ + check_ops.assert_equal(len(query_points.get_shape()), 3, message= + 'Query points must be 3 dimensional'), + check_ops.assert_equal(array_ops.shape(query_points)[2], 2, message= + 'Query points must be size 2 in dim 2.')]): + num_queries = array_ops.shape(query_points)[1] + + with ops.control_dependencies([ + check_ops.assert_greater_equal(height, 2, message= + 'Grid must be at least batch_size' + 'x 2 x 2 in size.'), + check_ops.assert_greater_equal(width, 2, message= + 'Grid must be at least batch_size' + 'x 2 x 2 in size.')]): + alphas = [] + floors = [] + ceils = [] + index_order = [0, 1] if indexing == 'ij' else [1, 0] + unstacked_query_points = array_ops.unstack(query_points, axis=2) for dim in index_order: with ops.name_scope('dim-' + str(dim)): @@ -112,16 +118,17 @@ def _interpolate_bilinear(grid, alpha = array_ops.expand_dims(alpha, 2) alphas.append(alpha) - if batch_size * height * width > np.iinfo(np.int32).max / 8: - error_msg = """The image size or batch size is sufficiently large - that the linearized addresses used by array_ops.gather - may exceed the int32 limit.""" - raise ValueError(error_msg) - - flattened_grid = array_ops.reshape(grid, - [batch_size * height * width, channels]) - batch_offsets = array_ops.reshape( - math_ops.range(batch_size) * height * width, [batch_size, 1]) + with ops.control_dependencies([ + check_ops.assert_less_equal( + math_ops.cast(batch_size * height * width, dtype=dtypes.float32), + np.iinfo(np.int32).max / 8, + message="""The image size or batch size is sufficiently large + that the linearized addresses used by array_ops.gather + may exceed the int32 limit.""")]): + flattened_grid = array_ops.reshape( + grid, [batch_size * height * width, channels]) + batch_offsets = array_ops.reshape( + math_ops.range(batch_size) * height * width, [batch_size, 1]) # This wraps array_ops.gather. We reshape the image data such that the # batch, y, and x coordinates are pulled into the first dimension. @@ -182,7 +189,12 @@ def dense_image_warp(image, flow, name='dense_image_warp'): of dimensions. """ with ops.name_scope(name): - batch_size, height, width, channels = image.get_shape().as_list() + batch_size, height, width, channels = \ + array_ops.shape(image)[0], \ + array_ops.shape(image)[1], \ + array_ops.shape(image)[2], \ + array_ops.shape(image)[3] + # The flow is defined on the image grid. Turn the flow into a list of query # points in the grid space. grid_x, grid_y = array_ops.meshgrid( -- GitLab From 772566443a8e2f4dc962efd622967f8d2a80319d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Fri, 2 Nov 2018 11:14:03 +0800 Subject: [PATCH 013/362] TST: use session instead --- tensorflow/python/kernel_tests/conv_ops_3d_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/kernel_tests/conv_ops_3d_test.py b/tensorflow/python/kernel_tests/conv_ops_3d_test.py index b3e73fa841..3ff23852e0 100644 --- a/tensorflow/python/kernel_tests/conv_ops_3d_test.py +++ b/tensorflow/python/kernel_tests/conv_ops_3d_test.py @@ -413,7 +413,7 @@ class Conv3DTest(test.TestCase): elif data_type == dtypes.float16: tolerance = 1e-3 - with self.cached_session(use_gpu=use_gpu): + with self.session(use_gpu=use_gpu): orig_input_tensor = constant_op.constant( input_data, shape=input_shape, dtype=data_type, name="input") filter_tensor = constant_op.constant( -- GitLab From 7e14f51c49c35fe577f0700ccec8b72c17d9f1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Fri, 2 Nov 2018 11:45:00 +0800 Subject: [PATCH 014/362] ENH: register double for grad --- tensorflow/core/kernels/conv_grad_ops_3d.cc | 8 ++++++++ tensorflow/python/kernel_tests/conv_ops_3d_test.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/kernels/conv_grad_ops_3d.cc b/tensorflow/core/kernels/conv_grad_ops_3d.cc index bab91f5e86..9271bfdf04 100644 --- a/tensorflow/core/kernels/conv_grad_ops_3d.cc +++ b/tensorflow/core/kernels/conv_grad_ops_3d.cc @@ -1859,6 +1859,14 @@ class Conv3DBackpropFilterOp : public OpKernel { Conv3DBackpropFilterOp); TF_CALL_half(REGISTER_GPU_KERNEL); TF_CALL_float(REGISTER_GPU_KERNEL); +REGISTER_KERNEL_BUILDER( + Name("Conv3DBackpropInput").Device(DEVICE_GPU).TypeConstraint("T"), + Conv3DBackpropInputOp); +REGISTER_KERNEL_BUILDER(Name("Conv3DBackpropInputV2") + .Device(DEVICE_GPU) + .TypeConstraint("T") + .HostMemory("input_sizes"), + Conv3DBackpropInputOp); #undef REGISTER_GPU_KERNEL #endif // GOOGLE_CUDA diff --git a/tensorflow/python/kernel_tests/conv_ops_3d_test.py b/tensorflow/python/kernel_tests/conv_ops_3d_test.py index 3ff23852e0..dd90676f09 100644 --- a/tensorflow/python/kernel_tests/conv_ops_3d_test.py +++ b/tensorflow/python/kernel_tests/conv_ops_3d_test.py @@ -413,7 +413,7 @@ class Conv3DTest(test.TestCase): elif data_type == dtypes.float16: tolerance = 1e-3 - with self.session(use_gpu=use_gpu): + with self.test_session(use_gpu=use_gpu): orig_input_tensor = constant_op.constant( input_data, shape=input_shape, dtype=data_type, name="input") filter_tensor = constant_op.constant( -- GitLab From 92878d5ae1596858c7682a2e93e5fe8969066854 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 2 Nov 2018 20:50:36 +0000 Subject: [PATCH 015/362] Fixed import nest issue --- tensorflow/python/ops/cond_v2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow/python/ops/cond_v2.py b/tensorflow/python/ops/cond_v2.py index 714cfbf4db..7e6c95ac88 100644 --- a/tensorflow/python/ops/cond_v2.py +++ b/tensorflow/python/ops/cond_v2.py @@ -34,6 +34,8 @@ from tensorflow.python.ops import control_flow_util from tensorflow.python.ops import control_flow_util_v2 as util from tensorflow.python.ops import gen_functional_ops from tensorflow.python.ops import gradients_impl +from tensorflow.python.util import nest + # NOTE(skyewm): TensorFlow uses protected class methods and fields to signify # that they aren't part of the official public API. These protected members -- GitLab From 1994b259d998c0a5c73107beb9750ef43b3797c5 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 10 Oct 2018 14:24:13 +0000 Subject: [PATCH 016/362] Update to avoid useless node in the graph based on review Signed-off-by: Yong Tang --- tensorflow/python/keras/integration_test.py | 2 +- tensorflow/python/keras/regularizers.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tensorflow/python/keras/integration_test.py b/tensorflow/python/keras/integration_test.py index 0e6fc79dd3..dfe62276fe 100644 --- a/tensorflow/python/keras/integration_test.py +++ b/tensorflow/python/keras/integration_test.py @@ -318,7 +318,7 @@ class KerasIntegrationTest(test.TestCase): with self.cached_session(): v = variable_scope.get_variable( "v", - shape = [4, 4], + shape=[4, 4], initializer=keras.initializers.glorot_uniform(), regularizer=keras.regularizers.l2(0.)) diff --git a/tensorflow/python/keras/regularizers.py b/tensorflow/python/keras/regularizers.py index fd0748f3ae..cbcdae214f 100644 --- a/tensorflow/python/keras/regularizers.py +++ b/tensorflow/python/keras/regularizers.py @@ -55,12 +55,14 @@ class L1L2(Regularizer): self.l2 = K.cast_to_floatx(l2) def __call__(self, x): - regularization = ops.convert_to_tensor(0., dtype=K.floatx()) - if self.l1: - regularization += math_ops.reduce_sum(self.l1 * math_ops.abs(x)) - if self.l2: - regularization += math_ops.reduce_sum(self.l2 * math_ops.square(x)) - return regularization + if self.l1 or self.l2: + regularization = ops.convert_to_tensor(0., dtype=K.floatx()) + if self.l1: + regularization += math_ops.reduce_sum(self.l1 * math_ops.abs(x)) + if self.l2: + regularization += math_ops.reduce_sum(self.l2 * math_ops.square(x)) + return regularization + return None def get_config(self): return {'l1': float(self.l1), 'l2': float(self.l2)} -- GitLab From 4ff0bd48a7e06e775d86e14228e8ea9e9578f95a Mon Sep 17 00:00:00 2001 From: fcole Date: Thu, 8 Nov 2018 11:52:54 +0800 Subject: [PATCH 017/362] substitute backslashes with parentheses (line continuation) Co-Authored-By: zldrobit --- tensorflow/contrib/image/python/ops/dense_image_warp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/image/python/ops/dense_image_warp.py b/tensorflow/contrib/image/python/ops/dense_image_warp.py index 2ac7ff2a6b..13c70ff0e6 100644 --- a/tensorflow/contrib/image/python/ops/dense_image_warp.py +++ b/tensorflow/contrib/image/python/ops/dense_image_warp.py @@ -60,7 +60,10 @@ def _interpolate_bilinear(grid, msg = 'Grid must be 4 dimensional. Received size: ' raise ValueError(msg + str(grid.get_shape())) - batch_size, height, width, channels = \ + batch_size, height, width, channels = (array_ops.shape(grid)[0], + array_ops.shape(grid)[1], + array_ops.shape(grid)[2], + array_ops.shape(grid)[3]) array_ops.shape(grid)[0], \ array_ops.shape(grid)[1], \ array_ops.shape(grid)[2], \ -- GitLab From 3e19356fd840069d6dce9aee692ab189708d951c Mon Sep 17 00:00:00 2001 From: zldrobit Date: Thu, 8 Nov 2018 11:58:54 +0800 Subject: [PATCH 018/362] delete redundant code --- tensorflow/contrib/image/python/ops/dense_image_warp.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tensorflow/contrib/image/python/ops/dense_image_warp.py b/tensorflow/contrib/image/python/ops/dense_image_warp.py index 13c70ff0e6..6e0105d069 100644 --- a/tensorflow/contrib/image/python/ops/dense_image_warp.py +++ b/tensorflow/contrib/image/python/ops/dense_image_warp.py @@ -64,10 +64,7 @@ def _interpolate_bilinear(grid, array_ops.shape(grid)[1], array_ops.shape(grid)[2], array_ops.shape(grid)[3]) - array_ops.shape(grid)[0], \ - array_ops.shape(grid)[1], \ - array_ops.shape(grid)[2], \ - array_ops.shape(grid)[3] + shape = [batch_size, height, width, channels] query_type = query_points.dtype grid_type = grid.dtype -- GitLab From cc46242fc750feb8da443d6c42ef2e2cf66cb38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Fri, 2 Nov 2018 15:45:36 +0800 Subject: [PATCH 019/362] ENH: register double for grad op --- tensorflow/core/kernels/conv_grad_ops_3d.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tensorflow/core/kernels/conv_grad_ops_3d.cc b/tensorflow/core/kernels/conv_grad_ops_3d.cc index 9271bfdf04..7fe4d8e93d 100644 --- a/tensorflow/core/kernels/conv_grad_ops_3d.cc +++ b/tensorflow/core/kernels/conv_grad_ops_3d.cc @@ -1070,6 +1070,7 @@ namespace functor { DECLARE_GPU_SPEC(Eigen::half); DECLARE_GPU_SPEC(float); +DECLARE_GPU_SPEC(double); #undef DECLARE_GPU_SPEC } // namespace functor @@ -1859,14 +1860,7 @@ class Conv3DBackpropFilterOp : public OpKernel { Conv3DBackpropFilterOp); TF_CALL_half(REGISTER_GPU_KERNEL); TF_CALL_float(REGISTER_GPU_KERNEL); -REGISTER_KERNEL_BUILDER( - Name("Conv3DBackpropInput").Device(DEVICE_GPU).TypeConstraint("T"), - Conv3DBackpropInputOp); -REGISTER_KERNEL_BUILDER(Name("Conv3DBackpropInputV2") - .Device(DEVICE_GPU) - .TypeConstraint("T") - .HostMemory("input_sizes"), - Conv3DBackpropInputOp); +TF_CALL_double(REGISTER_GPU_KERNEL); #undef REGISTER_GPU_KERNEL #endif // GOOGLE_CUDA -- GitLab From 29303bc712888e3f0d57e804c93bb1e7c58368a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Thu, 8 Nov 2018 14:19:30 +0800 Subject: [PATCH 020/362] TST: use cached_session instead --- tensorflow/python/kernel_tests/conv_ops_3d_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/kernel_tests/conv_ops_3d_test.py b/tensorflow/python/kernel_tests/conv_ops_3d_test.py index dd90676f09..b3e73fa841 100644 --- a/tensorflow/python/kernel_tests/conv_ops_3d_test.py +++ b/tensorflow/python/kernel_tests/conv_ops_3d_test.py @@ -413,7 +413,7 @@ class Conv3DTest(test.TestCase): elif data_type == dtypes.float16: tolerance = 1e-3 - with self.test_session(use_gpu=use_gpu): + with self.cached_session(use_gpu=use_gpu): orig_input_tensor = constant_op.constant( input_data, shape=input_shape, dtype=data_type, name="input") filter_tensor = constant_op.constant( -- GitLab From 3d974edb6e62e3020e7c83bb28c76a0db277f87a Mon Sep 17 00:00:00 2001 From: zldrobit Date: Thu, 8 Nov 2018 14:20:08 +0800 Subject: [PATCH 021/362] change error messages after splitting condition --- tensorflow/contrib/image/python/ops/dense_image_warp.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tensorflow/contrib/image/python/ops/dense_image_warp.py b/tensorflow/contrib/image/python/ops/dense_image_warp.py index 6e0105d069..df48f0e430 100644 --- a/tensorflow/contrib/image/python/ops/dense_image_warp.py +++ b/tensorflow/contrib/image/python/ops/dense_image_warp.py @@ -78,11 +78,9 @@ def _interpolate_bilinear(grid, with ops.control_dependencies([ check_ops.assert_greater_equal(height, 2, message= - 'Grid must be at least batch_size' - 'x 2 x 2 in size.'), + 'Grid height must be at least 2'), check_ops.assert_greater_equal(width, 2, message= - 'Grid must be at least batch_size' - 'x 2 x 2 in size.')]): + 'Grid width must be at least2')]): alphas = [] floors = [] ceils = [] -- GitLab From 9ab76bfe5468f858ce71443603aa16725bb42247 Mon Sep 17 00:00:00 2001 From: zldrobit Date: Thu, 8 Nov 2018 14:27:53 +0800 Subject: [PATCH 022/362] fix some typo --- tensorflow/contrib/image/python/ops/dense_image_warp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/image/python/ops/dense_image_warp.py b/tensorflow/contrib/image/python/ops/dense_image_warp.py index df48f0e430..72cd7fe219 100644 --- a/tensorflow/contrib/image/python/ops/dense_image_warp.py +++ b/tensorflow/contrib/image/python/ops/dense_image_warp.py @@ -80,7 +80,7 @@ def _interpolate_bilinear(grid, check_ops.assert_greater_equal(height, 2, message= 'Grid height must be at least 2'), check_ops.assert_greater_equal(width, 2, message= - 'Grid width must be at least2')]): + 'Grid width must be at least 2')]): alphas = [] floors = [] ceils = [] -- GitLab From 35f9eddd98f3470e779b8834800ccf66174318d1 Mon Sep 17 00:00:00 2001 From: zldrobit Date: Thu, 8 Nov 2018 14:45:37 +0800 Subject: [PATCH 023/362] fix some indentation and typo --- .../image/python/ops/dense_image_warp.py | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tensorflow/contrib/image/python/ops/dense_image_warp.py b/tensorflow/contrib/image/python/ops/dense_image_warp.py index 72cd7fe219..554f875cad 100644 --- a/tensorflow/contrib/image/python/ops/dense_image_warp.py +++ b/tensorflow/contrib/image/python/ops/dense_image_warp.py @@ -70,17 +70,21 @@ def _interpolate_bilinear(grid, grid_type = grid.dtype with ops.control_dependencies([ - check_ops.assert_equal(len(query_points.get_shape()), 3, message= - 'Query points must be 3 dimensional'), - check_ops.assert_equal(array_ops.shape(query_points)[2], 2, message= - 'Query points must be size 2 in dim 2.')]): + check_ops.assert_equal( + len(query_points.get_shape()), + 3, + message='Query points must be 3 dimensional.'), + check_ops.assert_equal( + array_ops.shape(query_points)[2], + 2, + message='Query points must be size 2 in dim 2.')]): num_queries = array_ops.shape(query_points)[1] with ops.control_dependencies([ check_ops.assert_greater_equal(height, 2, message= - 'Grid height must be at least 2'), + 'Grid height must be at least 2.'), check_ops.assert_greater_equal(width, 2, message= - 'Grid width must be at least 2')]): + 'Grid width must be at least 2.')]): alphas = [] floors = [] ceils = [] @@ -187,11 +191,10 @@ def dense_image_warp(image, flow, name='dense_image_warp'): of dimensions. """ with ops.name_scope(name): - batch_size, height, width, channels = \ - array_ops.shape(image)[0], \ - array_ops.shape(image)[1], \ - array_ops.shape(image)[2], \ - array_ops.shape(image)[3] + batch_size, height, width, channels = (array_ops.shape(image)[0], + array_ops.shape(image)[1], + array_ops.shape(image)[2], + array_ops.shape(image)[3]) # The flow is defined on the image grid. Turn the flow into a list of query # points in the grid space. -- GitLab From 917bd04d77a6872e8ecf31bbe0a1143dc98b6e8c Mon Sep 17 00:00:00 2001 From: zldrobit Date: Thu, 8 Nov 2018 14:54:53 +0800 Subject: [PATCH 024/362] fix indentation --- .../contrib/image/python/ops/dense_image_warp.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tensorflow/contrib/image/python/ops/dense_image_warp.py b/tensorflow/contrib/image/python/ops/dense_image_warp.py index 554f875cad..7930b8317b 100644 --- a/tensorflow/contrib/image/python/ops/dense_image_warp.py +++ b/tensorflow/contrib/image/python/ops/dense_image_warp.py @@ -81,10 +81,14 @@ def _interpolate_bilinear(grid, num_queries = array_ops.shape(query_points)[1] with ops.control_dependencies([ - check_ops.assert_greater_equal(height, 2, message= - 'Grid height must be at least 2.'), - check_ops.assert_greater_equal(width, 2, message= - 'Grid width must be at least 2.')]): + check_ops.assert_greater_equal( + height, + 2, + message='Grid height must be at least 2.'), + check_ops.assert_greater_equal( + width, + 2, + message='Grid width must be at least 2.')]): alphas = [] floors = [] ceils = [] -- GitLab From 74142f67926917061134678234ebee9683562f77 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 9 Nov 2018 08:13:19 +0000 Subject: [PATCH 025/362] Fixed old tests breaking because cond_v2 implementation preserves nested output structures even with singeltons --- .../python/kernel_tests/control_flow_ops_py_test.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py index 98f8fd4e96..71e4ccddde 100644 --- a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py +++ b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py @@ -2097,8 +2097,12 @@ class ControlFlowTest(test.TestCase): [tensor_shape.unknown_shape()]) return gradients_impl.gradients(r, x) - r = control_flow_ops.cond(math_ops.less(1, 2), fn1, lambda: x) - self.assertAllClose(9.0, r.eval(feed_dict={x: 1.0})) + #placed lambda function return tensor in list and set strict flag to True + #as cond_v2 implementation preserves nested output structures even with singeltons + r = control_flow_ops.cond(math_ops.less(1, 2), fn1, lambda: [x], strict=True) + #cannot run eval() on list object so use sess.run() and save output + result = sess.run(r,feed_dict={x: 1.0}) + self.assertAllClose([9.0], result) @test_util.disable_control_flow_v2("b/116340060") def testGradInWhileWrtInitialLoopVal(self): -- GitLab From 8068b6a021e75dc20f5de5902a684e94c3a4b5ef Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 9 Nov 2018 21:54:37 +0000 Subject: [PATCH 026/362] Fixed typo --- tensorflow/python/kernel_tests/control_flow_ops_py_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py index 71e4ccddde..95e4c4ba14 100644 --- a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py +++ b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py @@ -2086,7 +2086,7 @@ class ControlFlowTest(test.TestCase): def testWhileGradInCond(self): - with self.cached_session(): + with self.cached_session() as sess: n = ops.convert_to_tensor(1.0, name="n") x = array_ops.placeholder(dtypes.float32, shape=None) c = lambda n: math_ops.less(n, 10.0) -- GitLab From 8e85fe418aa40e5e4d4d4700dd491f4cbef4b30e Mon Sep 17 00:00:00 2001 From: Peng Yu Date: Wed, 22 Aug 2018 00:05:19 -0400 Subject: [PATCH 027/362] add tensor forest inference kernels --- tensorflow/core/BUILD | 3 + ...i_def_TensorForestCreateTreeVariable.pbtxt | 17 +++ .../api_def_TensorForestTreeDeserialize.pbtxt | 17 +++ ..._def_TensorForestTreeIsInitializedOp.pbtxt | 17 +++ .../api_def_TensorForestTreePredict.pbtxt | 29 ++++ ...def_TensorForestTreeResourceHandleOp.pbtxt | 5 + .../api_def_TensorForestTreeSerialize.pbtxt | 17 +++ .../api_def_TensorForestTreeSize.pbtxt | 17 +++ tensorflow/core/kernels/BUILD | 7 + .../kernels/boosted_trees/boosted_trees.proto | 14 ++ tensorflow/core/kernels/tensor_forest/BUILD | 53 +++++++ .../kernels/tensor_forest/prediction_ops.cc | 93 ++++++++++++ .../kernels/tensor_forest/resource_ops.cc | 135 ++++++++++++++++++ .../core/kernels/tensor_forest/resources.cc | 59 ++++++++ .../core/kernels/tensor_forest/resources.h | 63 ++++++++ tensorflow/core/ops/tensor_forest_ops.cc | 79 ++++++++++ tensorflow/python/BUILD | 22 +++ tensorflow/python/ops/tensor_forest_ops.py | 110 ++++++++++++++ 18 files changed, 757 insertions(+) create mode 100644 tensorflow/core/api_def/base_api/api_def_TensorForestCreateTreeVariable.pbtxt create mode 100644 tensorflow/core/api_def/base_api/api_def_TensorForestTreeDeserialize.pbtxt create mode 100644 tensorflow/core/api_def/base_api/api_def_TensorForestTreeIsInitializedOp.pbtxt create mode 100644 tensorflow/core/api_def/base_api/api_def_TensorForestTreePredict.pbtxt create mode 100644 tensorflow/core/api_def/base_api/api_def_TensorForestTreeResourceHandleOp.pbtxt create mode 100644 tensorflow/core/api_def/base_api/api_def_TensorForestTreeSerialize.pbtxt create mode 100644 tensorflow/core/api_def/base_api/api_def_TensorForestTreeSize.pbtxt create mode 100644 tensorflow/core/kernels/tensor_forest/BUILD create mode 100644 tensorflow/core/kernels/tensor_forest/prediction_ops.cc create mode 100644 tensorflow/core/kernels/tensor_forest/resource_ops.cc create mode 100644 tensorflow/core/kernels/tensor_forest/resources.cc create mode 100644 tensorflow/core/kernels/tensor_forest/resources.h create mode 100644 tensorflow/core/ops/tensor_forest_ops.cc create mode 100644 tensorflow/python/ops/tensor_forest_ops.py diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index b7ec445e93..ea99f14aa9 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -1038,6 +1038,7 @@ tf_gen_op_libs( "batch_ops", "bitwise_ops", "boosted_trees_ops", + "tensor_forest_ops", "candidate_sampling_ops", "checkpoint_ops", "collective_ops", @@ -1187,6 +1188,7 @@ cc_library( ":batch_ops_op_lib", ":bitwise_ops_op_lib", ":boosted_trees_ops_op_lib", + ":tensor_forest_ops_op_lib", ":candidate_sampling_ops_op_lib", ":checkpoint_ops_op_lib", ":collective_ops_op_lib", @@ -1340,6 +1342,7 @@ cc_library( "//tensorflow/core/kernels:batch_kernels", "//tensorflow/core/kernels:bincount_op", "//tensorflow/core/kernels:boosted_trees_ops", + "//tensorflow/core/kernels:tensor_forest_ops", "//tensorflow/core/kernels:candidate_sampler_ops", "//tensorflow/core/kernels:checkpoint_ops", "//tensorflow/core/kernels:collective_ops", diff --git a/tensorflow/core/api_def/base_api/api_def_TensorForestCreateTreeVariable.pbtxt b/tensorflow/core/api_def/base_api/api_def_TensorForestCreateTreeVariable.pbtxt new file mode 100644 index 0000000000..fe2ccd9da6 --- /dev/null +++ b/tensorflow/core/api_def/base_api/api_def_TensorForestCreateTreeVariable.pbtxt @@ -0,0 +1,17 @@ +op { + graph_op_name: "TensorForestCreateTreeVariable" + visibility: HIDDEN + in_arg { + name: "tree_handle" + description: <